 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Fri Jun 09, 2006 11:50 pm Post subject: Syntax highlighting support for Eclipse,FAR man and others |
|
|
I'm working on syntax highlighting support for AutoHotkey in Colorer Library take5 that can be used with Eclipse, FAR manager and others.
It's work in progress so some stuff don't work correctly or at all, if anybody tests comments are welcome.
This is a newer version than what I posted here
Keywords and other stuff should work.
Outlines should work on labels and functions but functions must have an open brace "{" on the same line as the function name.
You can change the colors by choosing a Color style/schema in colorers settings or make your own Color style/schema in colorer\hrd directory.
Updated info:
I have separated the Autohotkey syntax into 2 "modes" Basic and Advanced, Basic mode should be a stable/minimal/fast syntax highlighting and Advanced is unstable/experimental/anything that can be done with colorers syntax and my skill.
You choose which mode is default when installing, the mode can be changed by reinstalling, both modes are available within Colorers settings.
And now it uses the syntax files from AutoHotkeys extras folder.
Screenshots: Eclipse , FAR manager and FAR manager with outlines.
I will put same more info here later.
To install in Eclipse:
You need to install the Colorer Eclipse plugin more info here.
Update: In newer Eclipse versions you need to add "*.ahk" file-type in menu "Window -> Preferences... -> General -> Editors -> FileAssociations" and specify an "Colorer Editor" associated editor.
And when opening a .AHK file check that Eclipse is using a Colorer editor.
To install in FAR manager:
You need to download FarColorer and unpack to FAR manager plugin directory.
And finally my AutoHotkey support:
ColorerInstall012.exe: compiled install script, just run the exe it unpacks the needed files and when the script asks for "catalog.xml" go to Colorerplugin folder and choose the catalog file, now choose Basic or Advanced mode.
or
AHKColorer012.zip:Unpack the zipfile, run "ColorerInstall.ahk" install script and when the script asks for "catalog.xml" go to Colorerplugin and choose the catalog file, now choose Basic or Advanced mode.
In the Zipfile there are 7 files
| Code: |
ColorerInstall.ahk Install script.
protoadv.hrc Modification to Colorers proto.hrc file to add support for AHK, advanced mode.
protobasic.hrc Modification to Colorers proto.hrc file to add support for AHK, Basic mode.
ahkAdvanced.hrc This is the syntax highlighting file for AHK support, Advanced mode.
ahkBasic.hrc This is the syntax highlighting file for AHK support, Basic mode
ahkPackage.xml This is the syntax highlighting file for AHK support, used by both basic and advanced.
SyntaxTest.ahk My AutoHotkey test script, it just shows some syntax examples. |
Updated info about configuring Colorer in Eclipse.
Last edited by jonib on Mon Dec 31, 2007 9:39 am; edited 14 times in total |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Jun 10, 2006 4:20 pm Post subject: |
|
|
| Thanks for posting your work. When you feel it's read to be distributed with AutoHotkey (assuming you want that), please let me know. Also, it would be ideal to eventually have some means of auto-generating the ahk.hrc file from the master syntax files (which are contained in Extras\Editors\Syntax). However, I realize that this might be a lot of work for you. |
|
| Back to top |
|
 |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Sat Jun 10, 2006 5:43 pm Post subject: |
|
|
| Chris wrote: | | Thanks for posting your work. |
Thanks for posting your work.
| Quote: | | When you feel it's read to be distributed with AutoHotkey (assuming you want that), please let me know. |
I would want that when it's ready.
| Quote: | | Also, it would be ideal to eventually have some means of auto-generating the ahk.hrc file from the master syntax files (which are contained in Extras\Editors\Syntax). However, I realize that this might be a lot of work for you. |
Yes I will do that when it is finished.
Did you test it?
If you don't want to install Eclipse to test there is a colorer.exe in Library sources that shows syntax highlighting and can even be used to generate HTML with highlighting. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Jun 10, 2006 9:32 pm Post subject: |
|
|
| I haven't tested it yet. I remember someone once suggested finding means of doing syntax coloring/highlighting in the forum -- or perhaps just to publish individual scripts in HTML. Although I think at least one editor can already do this (perhaps PSPad), it would be nice to have a lighter-weight solution. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sun Jun 11, 2006 8:44 am Post subject: |
|
|
Well, I saw in the phpBB list of modules a special BBCode tag to do syntax highlighting for PHP code. It is easy, as PHP has a built-in function to generate such HTML code.
But perhaps someday I might hack this module to generate AutoHotkey syntax colored HTML. If you are willing to install such module, of course.
And currently, that's just vaporware, I have to finish my Scintilla lexer first (which goes a major refactoring!). _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Sun Jun 11, 2006 9:18 am Post subject: |
|
|
Hi PhiLho
Do you have any more syntax testing scripts like you posted here? |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Sun Jun 11, 2006 10:09 am Post subject: |
|
|
Some, but of course, a good test is to save some complex scripts from the Scripts & Functions section, and look at them.
I also like to use my own _Permanent.ahk file.
LexAHK.ahk
| Code: | /*
Sample file to show off syntax highlighting of AutoHotkey scripts within SciTE
*/
#SingleInstance Force ; Directive
SetTitleMatchMode 2 ; Command
Start: ; Label
abc := 11 * (180 / 3.14159265358979) + 0xBEEFF00D ; Numbers and expressions
boo := "Version`n" . A_AhkVersion "!" ; Expression string, escape char, std variable
oob = Version`n%A_AhkVersion%! ; PLain string, esc, variable reference
cot := "Unterminated string
doom =
( LTrim Join
Continuation`f
Section for %A_AhkVersion%
)
Gui +LastFound ; Special parameter
guiID := WinExist() ; Standard function
If abc + boo = %cot ; Unterminated variable ref
{
Foo(abc, boo%A_Now%) ; Function call, identifier (boo), std variable ref.
}
Else ; Flow of control kw
{
; Command, (default), escape, std var ref, key name, number, regular var ref
Send Year is `t%A_YYYY% {Tab 2} %cot% {Enter}{Incorrect}
Goto Start
}
Escape::ExitApp ; Hotkey definition
:*:ēk::[color=green][/color] ; Hotstring definition
a::z ; Remapping
|
SyntaxAmbiguity.ahk
| Code: | /* Some strange constructs that must compile and work,
and must be correctly highlighted!
*/
Goto !Code/Ambiguity?
;### Var ambiguity
77 = 7.7 ; Legal but hardly usable
0xBEEF = 48000 ; Not better...
BEEF = 0xBEEF ; 48879
BEER := 0xBEEF
MsgBox 77=%77%`n0xBEEF=%0xBEEF%`nBEEF=%BEEF%`nBEER=%BEER%
result = Result:
; Variables starting with a number are not usable in expressions...
if (77 = 7.7)
result = %result%`n77 = 11
if (0xBEEF = 0xBB80)
result = %result%`n0xBEEF = 0xBB80
if (0xBEEF = 48000)
result = %result%`n0xBEEF = 48000
if (0xBEEF = 48879) ;*
result = %result%`n0xBEEF = 48879
if (BEEF = 0xBEEF) ;*
result = %result%`nBEEF = 0xBEEF
if (BEEF = 48000)
result = %result%`nBEEF = 48000
if (BEEF = 48879) ;*
result = %result%`nBEEF = 48879
if (BEER = 0xBEEF) ;*
result = %result%`nBEER = 0xBEEF
if (BEER = 48000)
result = %result%`nBEER = 48000
if (BEER = 48879) ;*
result = %result%`nBEER = 48879
MsgBox %result%
!Code/Ambiguity?:
;### Code ambiguity and other constructs hard to highlight
Send = If (foo = bar) ; Not a command, nor a test
NumPad0 = 0 ; Not the start of a hotkey
b := true
If (F(5, 4 + 1) ; Not the end of the If expression
or b)
Gosub MsgBox
ExitApp
NumPad0::
MsgBox: ; Not a command...
MsgBox : %Send% ; Not a label
MsgBox (foo) ; Not a function call
Send :: NumPad0 ; Not a hotkey
If !b
Return ; Folding of label goes to next return, not this one!
Send:=42 ; Not a label
MsgBox => Result ; Not a MsgBox command!
If b = ( ; Not the start of an expression
F(5, 6)
Return
F(a
, b) ; Not a function call!
; Legal
{
%a% := "foo"
x%b% = bar
If ((a)&&(b))
x:=a
If (a =
(
x
)
and b)
x -= a / 2
Return a = b
}
|
SyntaxErrors.ahk
| Code: | Bad Label:
invalid variable := 1
x := unknown -* operator
x := bad + / expression
x := illegal, syntax
a =
(
continuation
section
) ouch!
)
|
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Sun Jun 11, 2006 6:53 pm Post subject: |
|
|
Thanks PhiLho.
Just what I wanted.
But I gave up after looking at SyntaxAmbiguity.ahk sorry no more updates.
Just kidding  |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Mon Jun 12, 2006 6:03 am Post subject: |
|
|
Note that my lexer is still far from handling all ambiguities correctly, and probably never will anyway: to do so, you will have to rewrite completely the parser from AHK itself!  _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Mon Jun 12, 2006 3:05 pm Post subject: |
|
|
| PhiLho wrote: | Note that my lexer is still far from handling all ambiguities correctly, and probably never will anyway: to do so, you will have to rewrite completely the parser from AHK itself!  |
Some tweaks and this is the result SyntaxAmbiguity.htm.
Nice brain teaser  |
|
| Back to top |
|
 |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Fri Nov 17, 2006 9:55 am Post subject: |
|
|
I'm going to rebuild my syntax highlighting and I'm going to use AutohotKeys master syntax files in the installer.
Should I have different highlighting for the built in functions or the same as user defined functions?
Has anybody tested it? |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Fri Nov 17, 2006 10:11 am Post subject: |
|
|
Not tested...
I use a different highlight for AutoHotkey functions, this is also a help to get the syntax right. At least, I often do that with built-in variables: A_LoopLongFilePath, mmm, no special color, A_LoopFileLongPath, right color, gotcha!  _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
jonib
Joined: 09 May 2006 Posts: 66
|
Posted: Fri Nov 17, 2006 3:47 pm Post subject: |
|
|
Yes seems most useful way to do it.
I was just thinking that other highlighters don't seem to think built in functions are special. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Fri Nov 17, 2006 5:56 pm Post subject: |
|
|
Oh, I don't know for your highligther, but that's the way it is done for most lexers of Scintilla.
Now, it depends on the language, the function list of Java or PHP isn't included by default, too big...
Come to think of it, C lexer has no style for built-in functions. But C hasn't really built-in functions, except those defined by the Ansi norm.
Lua as such lists, grouped by categories. So is POV-Ray. Well, bad examples, I worked on these... Mmm, indeed, most languages don't have a list of functions, perhaps because of their number.
Nsis lexer has a list of functions. It seems such list is useful for small languages. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
RobOtter
Joined: 30 Jan 2005 Posts: 125 Location: Darmstadt, Germany
|
Posted: Wed Mar 21, 2007 8:36 pm Post subject: |
|
|
Long time passed by...
jonib, PhiLho, anyone of you still (or again) working on this?
@jonib: Could you provide a working link to your AHKColorer.zip? The link given here is somewhat outdated...
Best regards,
Rob |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|