Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK Syntax Highlighting for AkelPad


  • Please log in to reply
16 replies to this topic
mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005
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:
[*:1vthljpl]Open the ahk.highlight in notepad.exe
[*:1vthljpl]Select Menu File -> Save As...
[*:1vthljpl]In the save-dialog find the dropdown-box "Encoding"
[*:1vthljpl]Select "Unicode".
[*:1vthljpl]Save the file
[*:1vthljpl]You might have to rename it from ahk.highlight.txt back to ahk.highlight, overwriting the not-Unicode-oneHere comes the 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


hobby
  • Guests
  • Last active:
  • Joined: --
I have problems to run your script to highlight AHK syntax for AkelPad Editor!
As you have a working script, please post the result for ahk.highlight.




Thanks

mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005
Spoiler


r
  • Guests
  • Last active:
  • Joined: --
does this script allow for highlighting commented lines?

thanks!

mbirth
  • Members
  • 40 posts
  • Last active: Jul 31 2008 11:12 AM
  • Joined: 03 Oct 2005

does this script allow for highlighting commented lines?


AFAIK, AkelPad doesn't support such things. It can only highlight specific keywords, nothing more.

Cheers,
-mARKUS

RandomHeart
  • Members
  • 22 posts
  • Last active: Mar 17 2012 08:11 AM
  • Joined: 24 Mar 2009
Beginning from version 4.2.2 AkelPad supports such things

AkelPad 4.2.2 (Apr 26, 2009)
----------------------------
Added: messages for syntax highlighting in AkelEdit:
- Opportunity to highlight delimiters, words, the text between words
(for example: line comments, quoted text, etc.);
- Opportunity to specify text color and background color.
- Opportunity to specify font style (normal, bold, italic, bold italic).


Maybe someone could update the highlight file? The one posted doesn't work

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Spoiler


RandomHeart
  • Members
  • 22 posts
  • Last active: Mar 17 2012 08:11 AM
  • Joined: 24 Mar 2009
HotKeyIt, I thank you.

For those of you who put the ahk.highlight file to the highlight plugin directory and wonder why still text in ahk files is not in color - delete the file "cache" in the same directory

ZeLen1y
  • Members
  • 44 posts
  • Last active: Oct 13 2014 09:43 PM
  • Joined: 11 Oct 2006
anyone have same but for coder plugin (comes with new versions of akelpad) with code folding feature ?

Lenchik
  • Guests
  • Last active:
  • Joined: --
http://akelpad.sourc... ... /ahk.coder

TedStriker
  • Members
  • 30 posts
  • Last active: Jul 31 2013 09:33 PM
  • Joined: 15 Jan 2008

http://akelpad.sourceforge.net/files/plugs/Coder/ahk.coder

Thank you! :shock: :D 8)

Akelpad is already a great editor, but now being able to use it with colors, code folding and auto-complete is just wonderful.

iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
By the way, you all are welcome to the issue tracker on github of the ahk.coder file.

magusneo
  • Members
  • 51 posts
  • Last active: May 10 2014 03:15 PM
  • Joined: 30 May 2012

https://github.com/L...aster/ahk.coder does not work in my AkelPad 4.7.6(x86).I copy it into "Coder" folder,when I open an ahk file,it does nothing.



iDrug
  • Members
  • 389 posts
  • Last active: Oct 11 2015 09:24 PM
  • Joined: 13 Oct 2009
magusneo, just read this.

magusneo
  • Members
  • 51 posts
  • Last active: May 10 2014 03:15 PM
  • Joined: 30 May 2012

I tried.It still does not work.Only ahk coder does not work,other coders like cpp,python,sql works.