I just found
AkelPad and it seems to be a good editor for notepad.exe replacement. Since there's a highlight
plugin, I puzzled a highlighter-compiler. (In case you wonder: I just took the useful code snippets from the other compilers.)
The only drawback: The highlighter-Plugin only understands Unicode files, so you have to manually convert it to Unicode once you have created the file. Do to that:
- Open the ahk.highlight in notepad.exe
- Select Menu File -> Save As...
- In the save-dialog find the dropdown-box "Encoding"
- Select "Unicode".
- Save the file
- You might have to rename it from ahk.highlight.txt back to ahk.highlight, overwriting the not-Unicode-one
Here comes the code:
Code:
;___________________________________________
; AkelPad Syntax Generator Script
; mbirth
;___________________________________________
SetBatchLines -1 ; Speeds up file operations.
SetWorkingDir ..\.. ; Set it to the Editors folder.
ColDelimiters = #cc3333
ColCommands = #3333cc
ColKeywords = #339933
ColFunctions = #3399cc
ColVariables = #3333cc
ColKeys = #0000ff
TargetFile = AkelPad\ahk.highlight
FileDelete %TargetFile%
FileAppend `;Auto-generated by AutoHotkey`n, %TargetFile%
FileAppend `;============================`n`n, %TargetFile%
FileAppend `;Note:`n`;Color need to be in #RRGGBB format`, if value`n`;equal to zero`, then color ignored.`n`n, %TargetFile%
FileAppend Extensions:`n, %TargetFile%
FileAppend ahk`n`n, %TargetFile%
FileAppend `;================================`n`;Char Color Color in`n`; selection`n`;================================`n, %TargetFile%
FileAppend Delimiters:`n, %TargetFile%
FileAppend ( %ColDelimiters% 0`n, %TargetFile%
FileAppend ) %ColDelimiters% 0`n, %TargetFile%
FileAppend { %ColDelimiters% 0`n, %TargetFile%
FileAppend } %ColDelimiters% 0`n, %TargetFile%
FileAppend `= %ColDelimiters% 0`n, %TargetFile%
FileAppend `, %ColDelimiters% 0`n, %TargetFile%
FileAppend : %ColDelimiters% 0`n, %TargetFile%
FileAppend + %ColDelimiters% 0`n, %TargetFile%
FileAppend - %ColDelimiters% 0`n, %TargetFile%
FileAppend * %ColDelimiters% 0`n, %TargetFile%
FileAppend / %ColDelimiters% 0`n, %TargetFile%
FileAppend < %ColDelimiters% 0`n, %TargetFile%
FileAppend > %ColDelimiters% 0`n, %TargetFile%
FileAppend `n`;===============================================`n`;Word Color Color in Case`n`; selection sensitive`n`;===============================================`n, %TargetFile%
FileAppend Words:`n, %TargetFile%
;this doesn't require fancy cmd names for human reading,
;it just requires names to be highlighted. so getting first name only
Loop Read, Syntax\Commands.txt, %TargetFile%
{
CurrCmd =
FullCmd = %a_loopreadline%
;directives don't have first comma but a first space
;so whichever is first, take it as end of cmd name
StringGetPos cPos, a_loopreadline, `,
StringGetPos sPos, a_loopreadline, %A_Space%
IfLess sPos, %cPos%
IfGreater sPos, 0
StringLeft CurrCmd, a_loopreadline, %sPos%
IfLess cPos, %sPos%
IfGreater cPos, 0
StringLeft CurrCmd, a_loopreadline, %cPos%
IfLess cPos, %sPos%
IfLess cPos, 0
StringLeft CurrCmd, a_loopreadline, %sPos%
IfLess sPos, %cPos%
IfLess sPos, 0
StringLeft CurrCmd, a_loopreadline, %cPos%
StringReplace FullCmd, FullCmd, ``n, `n, a
StringReplace FullCmd, FullCmd, ``t, `t, a
StringReplace CurrCmd, CurrCmd, [,, a
StringReplace CurrCmd, CurrCmd, %a_space%,, a
;For a directive that has no parameters
IfEqual CurrCmd,
CurrCmd = %a_loopreadline%
;this check removes duplicates for loop and if
IfNotEqual CurrCmd, %LastCmd%
FileAppend %CurrCmd% %ColCommands% 0 FALSE`n
LastCmd = %CurrCmd%
}
;Adding keywords
Loop Read, Syntax\Keywords.txt, %TargetFile%
{
CurrCmd = %a_loopreadline%
checkLine=%CurrCmd%
gosub checkComment
IfNotEqual rc, 0
{
;this check removes duplicates for loop and if
IfNotEqual CurrCmd,
IfNotEqual CurrCmd, %LastCmd%
FileAppend %CurrCmd% %ColKeywords% 0 FALSE`n
}
LastCmd = %CurrCmd%
}
;variables
Loop Read, Syntax\Variables.txt, %TargetFile%
FileAppend %A_LoopReadLine% %ColVariables% 0 FALSE`n
;keys are added with and without {}
Loop Read, Syntax\Keys.txt, %TargetFile%
{
CurrCmd = %a_loopreadline%
checkLine=%CurrCmd%
gosub checkComment
IfNotEqual rc, 0
{
;this check removes duplicates for loop and if
;keys are added with and without {}
IfNotEqual CurrCmd,
IfNotEqual CurrCmd, %LastCmd%
{
FileAppend %CurrCmd% %ColKeys% 0 FALSE`n
}
}
LastCmd = %CurrCmd%
}
;functions
Loop Read, Syntax\Functions.txt, %TargetFile%
{
CurrCmd =
FullCmd = %a_loopreadline%
StringGetPos pPos, a_loopreadline, (
StringLeft CurrCmd, a_loopreadline, %pPos%
StringReplace FullCmd, FullCmd, ``n, `n, a
StringReplace FullCmd, FullCmd, ``t, `t, a
StringReplace CurrCmd, CurrCmd, (,, a
StringReplace CurrCmd, CurrCmd, %a_space%,, a
;For a directive that has no parameters
IfEqual CurrCmd,
CurrCmd = %a_loopreadline%
;this check removes duplicates for loop and if
IfNotEqual CurrCmd, %LastCmd%
FileAppend %CurrCmd% %ColFunctions% 0 FALSE`n
LastCmd = %CurrCmd%
}
MsgBox You now have to convert the ahk.highlight to Unicode. To do that, open it in notepad.exe and choose File -> Save As and select Encoding: Unicode.
return
checkComment:
;comment check
StringReplace check, checkLine , %A_Space%,, A
StringReplace check, check, %A_Tab%,, A
StringLeft check, check, 1
IfEqual check, `;
rc=0
else
rc=1
return