 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Tue May 31, 2005 10:40 am Post subject: |
|
|
| toralf wrote: | 1) Where am I to strikt in the above cases?
2) Where can I restrikt it even strikter? | I'm not a RegEx expert but the descriptive rules you've written seem quite appropriate. I think they will work well (refinements can always be made later).
I'll await your revision before applying the change. Thanks. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Tue May 31, 2005 1:08 pm Post subject: |
|
|
Ok, here is an update of the script.
Please keep on posting bugs or improvements. Thanks
Edit: 051114: string indicator set to "
| Code: | ;##############################################################################
;#
;# Add or update syntaxhiglighting for AutoHotKey scripts in UltraEdit
;#
;# Mod of a script done by Tekl (although not much has survived)
;# Mod done by toralf, 2005-07-18
;#
;# Tested with: AHK 1.0.36.06, Windows XP Pro, UltraEdit 10.10c/10.20/11.10a
;#
;# Requirements
;# - Syntax files for AHK in one directory
;# - UltraEdit uses standard file for highlighting => wordfile.txt
;#
;# Customize:
;# - The default color for strings is gray, change it to any color
;# you want to have "string" to appeer => Extra->Option->syntaxhiglighting
;# - Change the default color for up to 8 keyword groups
;# => Extra->Option->syntaxhiglighting
;# -specify up to 8 syntax files, each containing one keyword per line
;# => you can add your own files, for keywords that you want to highlight
;# Personally I use 3 additional: Operators, Separators and Special, see further below in this topic
;#
; Specify a list of up to 8 syntax files; the order influences the color given to them by UE by default
SyntaxFileNameList = CommandNames|Keywords|Variables|Keys|Operators|Separators|Special
;Default colors in UE: blue |red |orange |green |brown |blue |blue |blue
SyntaxExtention = .txt
PathSyntaxFiles = %ProgramFiles%\AutoHotkey\Extras\Editors\Syntax
FileUEWordFile = %ProgramFiles%\UltraEdit\wordfile.txt
;############# END of Custamization Area ##################################
;############# Ask and Check for valid input ###############################
;Search or ask for Wordfile, when it doesn't exist -> exit
IfNotExist, %FileUEWordFile%
FileSelectFile, FileUEWordFile, 1, %PathProgramFiles%, Select UltraEdit wordfile, *.txt
IfNotExist, %FileUEWordFile%
{
MsgBox, 16,, UltraEdit Wordfile cannot be found.
ExitApp
}
;Search or ask for specified syntax folder and files, when they don't exist -> exit
IfNotExist, %PathSyntaxFiles%
FileSelectFolder, PathSyntaxFiles, ,2, Select Folder of Syntax Files
MissingFile =
FileCount = 0
Loop, Parse, SyntaxFileNameList, |
{
FileCount += 1
IfNotExist, %PathSyntaxFiles%\%A_LoopField%%SyntaxExtention%
MissingFile = %MissingFile%`n%A_LoopField%%SyntaxExtention%
}
If MissingFile is not Space
{
MsgBox, 16,, AHK Syntax file(s)`n%MissingFile%`n`ncannot be found in`n`n%PathSyntaxFiles%\.
ExitApp
}
If FileCount > 8
{
MsgBox, 16,, You have specified %FileCount% Syntax files.`nOnly 8 are supported be UltraEdit.`nPlease shorten the list.
ExitApp
}
;Check the number of languages in the current wordfile, if more than 19 without AHK -> exit
NumberOfLanguages = 0
Loop, Read, %FileUEWordFile%
{
StringLeft, WFdef, A_LoopReadLine, 2
If WFdef = /L
{
StringSplit, WFname, A_LoopReadLine, "
LanguageName = %WFname2%
If LanguageName <> AutoHotkey
NumberOfLanguages +=1
}
}
If NumberOfLanguages > 19
{
MsgBox, 48,, The wordfile has %NumberOfLanguages% syntax-schemes. UltraEdit does only support 20 schemes.`nPlease Delete schemes from the file!
ExitApp
}
;############# Read keywords from syntax files into arrays ################
Loop, Parse, SyntaxFileNameList, | ;Read all syntax files
{
SyntaxFileName = %A_LoopField%
Gosub, ReadSyntaxFromFile ;SyntaxFileName will become string with keywords
}
;############# Build language specific highlight for AHK ##################
StrgAHKwf = "AutoHotkey" Nocase
StrgAHKwf = %StrgAHKwf% Line Comment = `;
StrgAHKwf = %StrgAHKwf% Line Comment Preceding Chars = [~``] ;to Escape Escaped ;
StrgAHKwf = %StrgAHKwf% Escape Char = ``
StrgAHKwf = %StrgAHKwf% String Chars = "
StrgAHKwf = %StrgAHKwf% Block Comment On = /*
StrgAHKwf = %StrgAHKwf% Block Comment Off = */
StrgAHKwf = %StrgAHKwf% File Extensions = ahk`n
StrgAHKwf = %StrgAHKwf%/DeLimiters = *~`%+-!^&(){}=|\/:"'``;<>%A_Tab%,%A_Space%.`n
StrgAHKwf = %StrgAHKwf%/Indent Strings = "{" ":"`n
StrgAHKwf = %StrgAHKwf%/Unindent Strings = "}" "Return"`n
StrgAHKwf = %StrgAHKwf%/Open Fold Strings = "{"`n
StrgAHKwf = %StrgAHKwf%/Close Fold Strings = "}"`n
StrgAHKwf = %StrgAHKwf%/Function String = "`%[^t ]++^(:[^*^?BbCcKkOoPpRrZz0-9- ]++:*`::^)"`n ; Hotstrings
StrgAHKwf = %StrgAHKwf%/Function String 1 = "`%[^t ]++^([a-zA-Z0-9 #!^^&<>^*^~^$]+`::^)"`n ; Hotkeys
StrgAHKwf = %StrgAHKwf%/Function String 2 = "`%[^t ]++^([a-zA-Z0-9äöüß#_@^$^?^[^]]+:^)"`n ; Subroutines
StrgAHKwf = %StrgAHKwf%/Function String 3 = "`%[^t ]++^([a-zA-Z0-9äöüß#_@^$^?^[^]]+(*)^)"`n ; Functions
StrgAHKwf = %StrgAHKwf%/Function String 4 = "`%[^t ]++^(#[a-zA-Z]+ ^)"`n ; Directive
/* Test Area
;HOTSTRINGS
:*:js@::
:b0*?:11::
:c :ceo::
;HOTKEYS
#n::
^Numpad0::
^!s::
RWIN::
Numpad0 & Numpad1::
#!^& <>*~$test::
;FUNCTIONS
function@(ä,ß,*)
ähnlich(zahl,Fuß)
;SUBROUTINES
Subroutine:
Fußbälle:
;DIRECTIVE
#HotkeyModifierTimeout Milliseconds
*/
Loop, Parse, SyntaxFileNameList, | ;Add the keywords from syntax strings into their Sections
{
StrgAHKwf = %StrgAHKwf%/C%A_Index%"%A_LoopField%" ;Section definition
SyntaxString = %A_LoopField% ;which Section/syntax
Gosub, ParseSyntaxString ;Parse through string and add to list
}
;############# Add or Update Wordfile #####################################
;Name of a file for temporary store the word file
TemporaryUEwordFile = TempUEwordFile.txt
FileDelete, %TemporaryUEwordFile%
Loop, Read, %FileUEWordFile%, %TemporaryUEwordFile% ;Read through Wordfile
{
StringLeft, WFdef, A_LoopReadLine, 2
If WFdef = /L
{
StringSplit, WFname, A_LoopReadLine, "
LanguageName = %WFname2%
LanguageNumber = %WFname1%
StringTrimLeft,LanguageNumber,LanguageNumber,2
If LanguageName = AutoHotkey ;when AHK Section found, place new Section at same location
{
FileAppend, /L%LanguageNumber%%StrgAHKwf%
AHKLanguageFound := True
}
}
If LanguageName <> AutoHotkey ;everything that does not belong to AHK, gets unchanged to file
FileAppend, %A_LoopReadLine%`n
}
If not AHKLanguageFound ;when AHK Section not found, append AHK Section
{
LanguageNumber += 1
FileAppend, /L%LanguageNumber%%StrgAHKwf%, %TemporaryUEwordFile%
}
FileCopy, %FileUEWordFile%, %FileUEWordFile%.ahk.bak, 1 ;Create Backup of current wordfile
FileMove, %TemporaryUEwordFile%, %FileUEWordFile%, 1 ;Replace wordfile with temporary file
; Tell user what has been done
If AHKLanguageFound
MsgBox, 64,, The AutoHotkey-Syntax for UltraEdit has been updated in your wordfile:`n`n%FileUEWordFile%`n`nA backup has been created in the same folder.
Else
MsgBox, 64,, The AutoHotkey-Syntax for UltraEdit has been added to your wordfile:`n`n%FileUEWordFile%`n`nA backup has been created in the same folder.
ExitApp ; That's it, exit
;############# SubRoutines ################################################
ReadSyntaxFromFile:
TempString =
Loop, Read , %PathSyntaxFiles%\%SyntaxFileName%%SyntaxExtention% ;read syntax file
{
StringLeft,Char, A_LoopReadLine ,1
If Char <> `; ;If line is comment, don't bother
;otherwise only add first word in line
Loop Parse, A_LoopReadLine, `,%A_Tab%%A_Space%
{
TempString = %TempString%%A_LoopField%`n
Break
}
}
%SyntaxFileName% = %TempString% ;Assign string to syntax filename
Sort, %SyntaxFileName%, U ;Sort keywords in string
Return
ParseSyntaxString:
Loop, Parse, %SyntaxString%, `n ;Parse through syntax string
{
StringLeft, Char, A_LoopField,1
If (Char = PrevChar) ;add keyword to line when first character is same with previous keyword
StrgAHKwf = %StrgAHKwf% %A_LoopField%
Else ;for every keyword with a new first letter, start a new row
StrgAHKwf = %StrgAHKwf%`n%A_LoopField%
PrevChar = %Char% ;remember first character of keyword
}
Return
;############# END of File ################################################
|
_________________ Ciao
toralf 
Last edited by toralf on Mon Nov 14, 2005 3:53 pm; edited 3 times in total |
|
| Back to top |
|
 |
blitzer99 Guest
|
Posted: Sun Jul 03, 2005 10:59 pm Post subject: |
|
|
| toralf wrote: | This is a section taht works for my Ultra Edit
|
Version 11 of UltraEdit now supports code folding. To invoke this feature you need to do two things:
1. Add the following two lines to your UltraEdit wordfile.txt file section for AutoHotKey immediately before the "/C1" section: | Code: | /Open Fold Strings = "{"
/Close Fold Strings = "}"
| Plus any other syntax that you want to invoke code folding for.
2. Make sure you have activated this option in UltraEdit: "Advanced menu/ Configuration/General tab/Display options/Enable show-hide lines and code folding". |
|
| Back to top |
|
 |
t@k
Joined: 06 Jul 2005 Posts: 10
|
Posted: Wed Jul 06, 2005 2:46 am Post subject: @toralf |
|
|
I tried the latest update but got the following error...
| Quote: | AHK Syntax file(s)
Operators.txt
Separators.txt
Special.txt
cannot be found in
G:\My Program Files\AutoHotkey\Extras\Editors\Syntax\. |
... but I noticed this in the comments...
| Quote: | Operators.txt => "=`n<`n>`n*`n/`n+`n-"
Separators.txt => "``n`n``r`n|`n,`n{`n}"
Special.txt => "** x y w h r v g`nis`nnot`nCBlue`ncRed"
|
I saved the text to the associated filenames, but I included the double-quotes. Was that correct?
If so, this script appears to work fine for UE v11.10a+1.
Thank you very much. |
|
| Back to top |
|
 |
t@k
Joined: 06 Jul 2005 Posts: 10
|
Posted: Wed Jul 06, 2005 9:59 am Post subject: |
|
|
I replace "`n" with a carriage return (new line)?
So Operators.txt => "=`n<`n>`n*`n/`n+`n-" should be ...and Separators.txt => "``n`n``r`n|`n,`n{`n}" should be...Not entirely sure about the last one.
Thanks. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Wed Jul 06, 2005 10:07 am Post subject: |
|
|
Nearly.
This is the content of my files (from Nov, I think I have to update them):
| Quote: | ;Separators in AHK
,
`n `r
|
,
{
} |
| Quote: | ;Special Keywords for highlight in UE
All
AutoSize
bold
BackgroundTrans
cBlue
cDefault
cGreen
cRed
cWhite
is
norm
not
Off
On |
| Quote: | ;Operators in AHK
%
=
<
>
*
/
+
- |
You can alter them as you like. I got used to the coloring.
Edit: 051114: added % to operators and a comma to separators. _________________ Ciao
toralf 
Last edited by toralf on Mon Nov 14, 2005 3:49 pm; edited 1 time in total |
|
| Back to top |
|
 |
t@k
Joined: 06 Jul 2005 Posts: 10
|
Posted: Wed Jul 06, 2005 10:39 am Post subject: @toralf |
|
|
| Thanks for clarifying. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Mon Jul 18, 2005 7:22 am Post subject: |
|
|
| blitzer99 wrote: |
Version 11 of UltraEdit now supports code folding. To invoke this feature you need to do two things:
1. Add the following two lines to your UltraEdit wordfile.txt file section for AutoHotKey immediately before the "/C1" section: | Code: | /Open Fold Strings = "{"
/Close Fold Strings = "}"
|
2. Make sure you have activated this option in UltraEdit: "Advanced menu/ Configuration/General tab/Display options/Enable show-hide lines and code folding". |
I added that folding stuff to the script on this page above this post. I tested it only with 11.10a. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Mon Jul 18, 2005 3:46 pm Post subject: |
|
|
Today's update (v1.0.36.07) contains the code-folding change and the symbol/syntax improvements mentioned before that.
I've only tested this on version 11.10a of UltraEdit. So if anyone has an older version and you discover any problems with the script (in AutoHotkey's Extras folder), please post here.
In the future, it would help me if changes are made directly to the version of the script included with AutoHotkey. This is because I try to avoid replacing a known-good script with a new version that I haven't reviewed and tested.
Further improvements and corrections are welcome. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Wed Jul 20, 2005 6:05 am Post subject: |
|
|
Thanks Chris. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Mon Nov 14, 2005 3:58 pm Post subject: |
|
|
I have changed the above script.
1) The string indicator I have changed from % to ".
RobOtter convinced me that this will give a highlightning.
2) I have altered the content of the extra files. the % got added to the operators and the comma got added to the separators.
@Chris: I will send you an update of the script you have in the distro.
BTW: I think I should start a new topic on this, since the actual script is so far back (page 4) in this topic. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Mon Nov 14, 2005 4:34 pm Post subject: |
|
|
I have posted an updated version here:
http://www.autohotkey.com/forum/viewtopic.php?p=38131
It contains the script that comes with the AHK distro and the content of my 3 extra files.
Please do not post any suggestions or remarks in this topic any more. Please use the other topic. Thanks. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Banderas Guest
|
Posted: Fri Aug 25, 2006 12:23 pm Post subject: |
|
|
Thanks to Tekl !
It works immediately (in UE9.0)
 |
|
| 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
|