How do I configure eclipse (zend studio 6) to hint and code complete several languages? - zend-studio

My dream IDE does full code hints, explains and completes PHP, Javascript, HTML and CSS. I know it exists!
so far, Zend studio 6, under the Eclipse IDE does a great job at hinting PHP, some Javascript and HTML, any way I can expand this?
edit: a bit more information: right now, using zend-6 under eclipse, i type in
<?php
p //(a single letter "p")
and I get a hint tooltip with all the available php functions that begin with "p" (phpinfo(), parse_ini_file(), parse_str(), etc...), each with its own explanation: phpinfo()->"outputs lots of PHP information", the same applies for regular HTML (no explanations however).
However, I get nothing when I do:
<style>
b /* (a single letter "b") */
I'd love it if I could get, from that "b" suggestions for "border", "bottom", etc. The same applies for Javascript.
Any ideas?

I think the JavaScript and CSS need to be in separate files for this to work.
Example of CSS autocomplete in Eclipse:
Starting to type border
Then setting thickness
Then choosing the color
Chose red, and it added the ; for me
Works pretty good IMHO.

The default CSS and HTML editors for Eclipse are really good. The default javascript editor does an OK job, but it needs a little work.
I just tested this in Eclipse 3.3.2
function test(){
}
te<CTRL+SPACE>
and it completed the method for me as did this:
var test = function(){
};
te<CTRL+SPACE>
Can you expand on what more you wanted it to do?

Related

ckeditor - Pure HTML source mode without ANY alterations of the code

I know this question has been asked 1000 times, but after 6 hours of research I still couldn't find any solution.
Unfortunately, I am bound to a CMS that's using ckeditor. I don't like WYSIWYG editors at all, but I have to deal with it. I want the editor to not touch ANY of my code, doesn't matter if it's wrong or not, if I place block elements into inline elements, etc.
This is the config I am using atm:
CKEDITOR.editorConfig = function( config ) {
config.language = 'en';
config.allowedContent = true;
config.height = 600;
config.startupMode = 'source';
// Prevent CK from removing empty HTML-tags
$.each(CKEDITOR.dtd.$removeEmpty, function (i, value) {
CKEDITOR.dtd.$removeEmpty[i] = false;
});};
Well, with these settings the editor still seems to alter the code. For instance, it realigns <a> or <span> tags and just adds new code. This is so incredible annoying. I know it's not the purpose of the editor to behave like a pure webdev editor, but there must be a way to configure it somehow to just leave the code completely alone, right? Can anyone tell me what settings I need to add in order to achieve this?
there must be a way to configure it somehow to just leave the code completely alone, right?
Wrong.
Libraries like this make use of the contentEditable feature provided by browsers.
The browser will take the HTML, parse it into a DOM, and then provide an API to manipulate it. Later, that DOM can be serialised back to HTML, but this is entirely disconnected from the original HTML. Everything will have been normalised.

CKEditor with HTML content stores, displays but cannot display for edit

I have used CKEditor for a few years without really understanding it. I now want to use it to display text which will include HTML, CSS, JavaScript and PHP example code. None of that needs to execute it is just to show the code to others.
Currently I used the textarea replace method to edit content and I need to carry on that way. When I add the content first time it is sanitised (mysqli_real_escape_string) and stored in a MySQL database correctly. It also then displays correctly with the CKEditor markup working as markup and the HTML/PHP showing as a code example. However, when I edit the content a second time the HTML examples become "real" HTML and are no longer visible as examples.
For example this:
<?php echo "hello"; ?>
<p>Hello</p>
is correctly (?) stored as:
<p><?php echo "me"; ?></p>
<p><p>Hello</p></p>
and displays on the page as shown in the first code snippet (which is what I want). When I then hit edit again the code examples vanish into the background as real HTML (part of the page). If I put the code examples in as code snippets (which I would rather not have to do because of the intended users) the result in the editor (second edit) looks like this:
<!--?php echo "me"; ?-->
Hello
I am sure i am missing a basic understanding of what is going on behind the scenes but can anyone explain how to allow users to type in text which includes HTML, CSS, JavaScript, PHP and MySQL code examples which must then appear as examples and not markup (and be editable as examples).
I have played with config.entities and config.protectedSource after some research but they do not seem to be relevant (or to work). Weirdly a couple of times it seemed to work fine and I thought I had cracked it but then stopped with no further changes to the config. That means I now have less idea what I am doing than when I started!
You don't mention which version you are using, but if it's relatively new (4.4+) you can use the Code Snippets plugin that was designed exactly for this. See the demo at http://ckeditor.com/demo#widgets. It might help with the encoding issues too. There's docs on it too.
Th help with the current encoding issue, it would help a LOT if you showed us how you output the data and load it into CKEditor. For example "When I then hit edit again" doesn't really describe anything without context. For example, do you use setData() with AJAX? Do you use an inline editor? Code examples would be the best.

Is there any syntaxhighlighter for SAS?

I need to post SAS code on my website. However, if I do write my HTML to highlight SAS cod it would take me a long time.
How can I transform the SAS code into nice looking HTML counterpart?
I would simply copy/paste from your editor into a rich text editor (ie, MS Word or similar) that is capable of producing an HTML file. Alternately, some text editors like UltraEdit are capable of doing SAS markup.
I just discovered that Gist actually supports SAS Syntax highlighting!
This is what you see if you create a hello_world.sas file on Gist.
If you'd like to embed SAS codes into (say) a Wordpress.org blog article (like myself), the way I usually do this is:
Create a Markdown file on Gist. For example, see this Gist Markdown file that I created ). Notice that an "embed link" is created for you:
In your Wordpress.org website, already have the plugin oEmbed Gist already installed.
When you create a new blog post in Wordpress, in the body field (where you'd normally type out content of your blog post), simply copy and paste the Gist embedded link into the the body.
Publish that blog post and you shall see it renders beautifully!
(alternatively, if you wish to write your Wordpress blog post normally, and embed multiple Gist SAS codes, just simply save the gist files as .sas files (instead of one .md file), and embed multiple embed URLs (corresponding to each code blogs).
More info see this stackoverflow forum - where I learnt about the awesome Gist and Wordpress Gist oEmbed combo!
As of SAS Entreprise Guide v5.1, you can right-click on the editor window and select 'Copy HTML source to clipboard'.
You can then paste the HTML directly into the HTML source of your page.
Note that this may even work in earlier versions of the SAS Entreprise Guide - version 5.1 just happens to be the version I have installed.
Thanks to #otto for providing the original idea of using Enterprise Guide.
I have found no great solution. SAS does not seem to be supported by any of the javascript highlighters.
At least three text editors I know of can export coloured HTML to the clipboard (and hence your page, or Word or PowerPoint).
Ultraedit
Notepad++
Emacs (ESS) (on Mac I use Aquamacs)
(possibly) SAS enhanced editor... not sure about this.
Another possibility is TextWrangler on Mac for which a SAS syntax colouring file is available. But I have not tried this. [update: it is not very good. many keywords missing.
A fifth possibility is SublimeText 3. It has a great syntax colouring plugin. It even gets
y = X * z ;
* but this really is a comment ;
coloured correcty.
The SAS colouring package is not included by default but is downloadable from implementing-vdw.blogspot.ch/2012/10/new-sublime-text-package-available-for.html
A trial version is free and ST is cross platform]
Somewhat off-topic -- but is the next question :-)
For preparing papers and documents there is a LaTeX package listings (which works if you use BeraMono instead of Courier) and a newer package based on it called SASnRdisplay. These packages produce great output and it is easy to add keywords. Also for listings you need to allow lowercase keywords with the sensitive=false option.
Can you use Enterprise Guide?
When I copy and paste from the EG edit window into something that supports rich text (word, an outlook email, etc), I get all of my colors and highlighting.
From here, you just have to grab the HTML and stick it online. It may not be the prettiest HTML (WYSIWYG output rarely is), but it works. In Outlook 2010, you can right click and "View Source" on any mails that have been sent/received (or as a trick, you can paste it into a blank email and then close it and view source in your "Drafts" folder).
As I said, it is some ugly HTML (and all on one line), but I'd assume that the output of any javascript highlighter is also fairly ugly:
<b><span style='font-family:"Courier New";color:navy;background:white'>data</span></b><span style='font-family:"Courier New";color:black;background:white'> test;<o:p></o:p></span></p><p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span style='font-family:"Courier New";color:black;background:white'><span style='mso-spacerun:yes'> </span></span><span style='font-family:"Courier New";color:blue;background:white'>set</span><span style='font-family:"Courier New";color:black;background:white'> test;<o:p></o:p></span></p><p class=MsoNormal style='mso-layout-grid-align:none;text-autospace:none'><span style='font-family:"Courier New";color:black;background:white'><span style='mso-spacerun:yes'> </span></span><span style='font-family:"Courier New";color:blue;background:white'>length</span><span style='font-family:"Courier New";color:black;background:white'> fakevar $</span><b><span style='font-family:"Courier New";color:teal;background:white'>16</span></b><span style='font-family:"Courier New";color:black;background:white'>;<o:p></o:p></span></p><p class=MsoNormal><b><span style='font-family:"Courier New";color:navy;background:white'>run</span></b><span style='font-family:"Courier New";color:black;background:white'>;</span><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p>
You can see it rendered here:
http://rendera.heroku.com/usercode/9e1bfaeb9bceb4c052d6747e8e73c1846bad433b
I think you can the following:
Store your codes on https://gist.github.com/
Use the embed URL code (provided in https://gist.github.com/) in your site as...(Run Code Snippet):
<script src="https://gist.github.com/AlyssonJalles/b22bc10a707ef909024b.js"></script>
*Maybe this isn't a 100% solution, but is good because when you update your code on Gist, the code will be updated in your website. Futhermore, if you use wordpress.com, you just copy the URL and paste in your page editor to see the code.
If you're creating your own HTML page (and find the gist solution undesirable), checkout CodeMirror.
http://codemirror.net/mode/sas/index.html
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: 'sas',
styleActiveLine: true,
lineNumbers: true,
readOnly: true
});
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/codemirror.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/codemirror.min.js"></script>
<!-- sas language mode -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/mode/sas/sas.min.js"></script>
<!-- optional plugins -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/addon/selection/active-line.min.js"></script>
<form><textarea id="code" name="code">
libname foo "/tmp/foobar";
%let count=1;
/* Multi line
Comment
*/
data _null_;
x=ranuni();
* single comment;
x2=x**2;
sx=sqrt(x);
if x=x2 then put "x must be 1";
else do;
put x=;
end;
run;
/* embedded comment
* comment;
*/
proc glm data=sashelp.class;
class sex;
model weight = height sex;
run;
proc sql;
select count(*)
from sashelp.class;
create table foo as
select * from sashelp.class;
select *
from foo;
quit;
</textarea></form>
And a sixth answer is pspad. Which has a SAS addin to get build capabilities.
http://www.pspad.com/
SAS utils here: http://www.pspad.com/en/pspad-extensions.php?stranka=3
maybe this repo helps.
https://github.com/Jiangtang/sas.tmbundle
reference:
http://www.jiangtanghu.com/blog/2012/07/13/sublimetext2-sas/
Emacs can do this using Emacs Speaks Statistics (ESS). There are two contexts which I find useful for editing SAS code. The first is sas-mode for editing whole SAS files, the second is using a source block within org-mode for literate programming.
I highly recommend reading the Emacs tutorial. If you've just installed Emacs, just open it and press Enter (on the 'Emacs Tutorial' link). Otherwise, press C-h t.
1. Install ESS
Press M-x list-packages and search for Emacs Speaks Statistics via C-s emacs speaks statistics. Press i to mark the package for install. Press x to install all marked packages.
2. Load ESS
To load ESS run M-: (require 'ess-site). For more details, refer to the install instructions.
SAS Mode
Load SAS mode within the current buffer via M-x sas-mode. This provides syntax highlighting according to your current theme. For example, this is a light theme.
Org Mode
Load org-mode via M-x org-mode. Create a source block by typing <s and pressing TAB to autocomplete. This creates a source code block:
#+BEGIN_SRC
#+END_SRC
Then type sas to let Org Mode know that the source code is SAS code.
#+BEGIN_SRC sas
#+END_SRC
To toggle syntax highlighting within the source block, run M-: (setq org-src-fontify-natively t).
Any code within the block then takes on the syntax highlighting for SAS. The coloring is dependent on your theme. This is an example of a dark theme:
Org-mode allows for exporting to HTML using C-c C-e h o. With htmlize, the syntax highlighting will be exported too.
If you want to merely highlight the code for programming purposes, then the best option for you as highlighted above is a text editor. I have worked on SAS for close to a decade across platforms and organizations. I find the old crimson editor the best as it is freeware, is very light and supports many functions that are typically needed.
To ensure SAS specific syntax highlighting, you need to select the sas keyword and syntax files. These files are provided with installation only.
Please follow the following steps
1. Install crimson editor (i am using version 3.70)
2. Click on Tools->Preferences->File->Syntax Type
3. In the syntax type, select the button with three dots on bottom right. It will give you a pop up and select sas.spc
4. In the Keywords, select the button with three dots on bottom right. It will give you a pop up and select sas.key
5. In the description type SAS
6. In the Top right frame/panel, select SAS from the last option
And you are good to go
Edit: The Crimson Editor can be obtained from http://www.crimsoneditor.com/
An old question an an old programming language, but maybe somebody (like me) is still interested in yet another answer:
How to generate SAS code highlighting using Notepad++
There is a [https://blogs.sas.com/content/sasdummy/2017/08/25/npp-with-sas/] (blog entry by SAS themselves) explaining how to use syntax highlighting for SAS code in Notepad++. It basically refers to a freely available Notepad++ plugin at https://github.com/cjdinger/sas-npp
The next step is optional: You can export the highlighted code from Notepad++ to HTML using the NppExport plugin, see e.g. https://www.addictivetips.com/windows-tips/nppexport-for-notepad-export-highlighted-code-in-html-rtf-format/
How to highlight SAS code in VIM
There is a nice introduction on how to use VIM for editing SAS code from the SAS community: http://www.sascommunity.org/planet/blog/category/vim/
The basic idea is that you obtain a syntax definition file for VIM and install that, see
https://www.vim.org/scripts/script.php?script_id=1999
To highlight text in a macro input the following line:
%macro __enable_eg_syntax_highlight; %mend __enable_eg_syntax_highlight;
So where everything was just black the above line will bring back the SAS formatting.
Regards Terry

Building an add-on to hide a <div> block on an HTML page

There's a webpage with something annoying on it which I'd like to hide every time I visit it. I thought a good way to do this would be to make an add-on for Firefox.
I've never done this before, and came across the web-based Firefox add-on builder. I'm not too sure where to go from here though. I know it should be quite easy to do this though. I suppose all I need to do is check if a block with a certain id is used on a website, and if it is, then delete/hide it from my view.
Is that the best way to do about this? If not, what do you suggest? If so, can you give me any tips to help me accomplish this?
Right, I got it:
Using just a standalone Firefox Add-On use the following code:
exports.main = function() {
var pageMod = require("page-mod");
pageMod.PageMod({
include: "*.ca",
contentScriptWhen: 'end',
contentScript: 'document.getElementById("DIVID").style.visibility="hidden";'
});
};
Just replace DIVID with whatever you want.
Similarly, in Greasemonkey, just add this to the script:
document.getElementById('DIVID').style.visibility='hidden';
The only reason I didn't want to use Greasemonkey is that it isn't as easy to share. But it's convenience can't be beat!
Install the latest FF
Install the latest AdBlock Plus
Go to the website right click on specific element and then Inspect Element(Q)
Right bottom corner there is Hide with ABP(AdBlock Plus) button, click on it, then Add Element Hiding Rule
You can just use GreaseMonkey which is a very useful plugin for firefox. You can write your own script in JavaScript which operates on the page.
However, chances are that someone might have already written a script for the site in question that you can install from the http://userscripts.org/ repository.
In well-formed HTML, any particular value for the id attribute should occur at most once in a document. If your mission is to seek and destroy a recurring phenomenon, it might be labeled (if at all) with a class. This is the case with Twitter's "promoted tweets", for example.
var promotedTweets = document.getElementsByClassName("promoted-tweet");
for (k=0; k<promotedTweets.length; k++) {
promotedTweets[k].parentNode.removeChild(promotedTweets[k]);
}
Wouldn't Adblock Plus do the trick here? You can feed it an element hiding rule (based on the class or ID attribute) on any given website, if I recall correctly.
I used the up-and-coming jpm tool to write this, and incorporated the suggestions here. It is specifically for filtering certain div tags here on StackOverflow—how fitting. The code and the xpi add-on file is at Github.
An alternative in Firefox is to create a userContent.css file and add css which hides the div.
See https://superuser.com/a/319322/ and note the comment which points out that "Starting with Firefox 69, you need to set the toolkit.legacyUserProfileCustomizations.stylesheets preference to true".

Printing from Joomla using the print icon

Can anyone help me understand what is happening when I try to print from a joomla site:
When I use the print icon I get the expected result of just printing the article (ie no headers, side modules etc) but I also lose all the default.css that is used for my template. ie no type styling and only see the style that has been included inline in the article. The result is pretty grim as the text size is all wrong.
However, if I try to print directly from the browser I keep the format applied from the default.css of my template but do not see any of the images that are included in JCE ImageManager PopsUps- presumeably because the browser is blocking pop-ups.
Can anyone explain what I need to add to a print.css and how joomla knows to use this when printing using the print icon.
Many thanks in anticipation of a reply!
You can identify a print stylesheet by doing something like this:
<link rel="stylesheet" media="print" href="print.css">
I am not sure though if joomla can identify it by this. On Joomla do it like this:
$doc =& JFactory::getDocument();
$doc->addStyleSheet( 'http://www.example.com/css/mystylesheet.css', 'text/css', 'print' );
Have a look here: http://docs.joomla.org/JDocument/addStyleSheet on the Joomla part. Maybe this is sufficient, but it may also depend on the version

Resources