 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Thu Feb 17, 2005 6:46 am Post subject: |
|
|
I found it, it is due to missing {}
please insert this at line 74 and remove the old lines
| Code: | ;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
}
|
Thanks for reproting _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Andreas Borutta
Joined: 23 Jan 2005 Posts: 46
|
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Thu Feb 17, 2005 10:58 am Post subject: |
|
|
As I said before, hotstrings and triggers aren't highlighted, because UE doesn't support regular expressions for highlightning.
Therefore this script is not improvement for the things you want to have.
This script is an improvement to the one of Tekl, since
- it captures triggers as functions correctly
- it takes the original syntax files as base
- it doesn't write/read Registry (which I favor)
- you can specify your own syntax files to be add to the UE wordfile.
So what you can do is:
- add the triggers and hotstrings to a syntaxfile, so that they are highlighted
- play with "/Marker Characters" to see triggers more easily
- play with ":" as "/Block Comments On/Off" or "/String"
- OR since nearly all will be highlighted that is a keyword, set a strong color for normal text, then you can easily see the triggers and hotstrings.
In any case see UE help for details. Sorry, but I can't help you any further. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Andreas Borutta
Joined: 23 Jan 2005 Posts: 46
|
Posted: Thu Feb 17, 2005 11:20 am Post subject: |
|
|
| Quote: | So what you can do is:
- add the triggers and hotstrings to a syntaxfile, so that they are highlighted
- play with "/Marker Characters" to see triggers more easily
- play with ":" as "/Block Comments On/Off" or "/String"
- OR since nearly all will be highlighted that is a keyword, set a strong color for normal text, then you can easily see the triggers and hotstrings.
In any case see UE help for details. Sorry, but I can't help you any further. |
OK.
I'm don't have the knowledge to "play" with the syntaxfile.
Maybe some day someone else likes to improve the usability of the hotstring-files in Uedit?
In my view this point is quite important for all users of AHK who like to use hotstrings intensivly. The maintenance
of the file would be a lot easier with highlighting as I described.
Still I wonder, that this stuff is oviously complicated.
In my imagination very specific highlighting is for each programmer a standard-method to work, kind of a sharp knife for a cook.  _________________ Andreas
http://borumat.de/autohotkey-autotexte-und-makros-tipps (german)
http://borumat.de/thunderbird-email-tipps (german)
http://borumat.de/firefox-browser-tipps (german) |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Thu Feb 17, 2005 3:57 pm Post subject: |
|
|
An addition to the script:
- directives (#....) will be listed in the function list
Add this line after the "/Funtional String = " line (somewhere around line 116)
| Code: | StrgAHKwf = %StrgAHKwf%/Function String 1 = "`%^([#][a-zA-Z0-9 ,]+^)"`n
|
_________________ Ciao
toralf  |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Apr 24, 2005 10:03 pm Post subject: |
|
|
Toralfs code from the bottom of page 1 works for UE 11.10, thanks for that  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Thu Apr 28, 2005 9:46 pm Post subject: |
|
|
Sorry it took me so long to look at these UltraEdit scripts.
| toralf wrote: | | It uses the systax files directly, which are coming with AHK. | That's a great improvement; thanks.
| Quote: | | It doesn't write or read to/from Registry | I changed this so that it tries to get the paths from the registry first (using Tekl's method). If that fails, it falls back to your ProgramFiles method. If that fails, if asks the user for the path (as you had it already).
I also added Tekl's default editor change to the bottom, but made it optional. It asks you, "Would you like to make UltraEdit the default editor for AutoHotkey scripts (.ahk files)?"
Here is the new script that will be included in the Extras folder for the next update. Please let me know if anything should be changed.
| Code: | ;##############################################################################
;#
;# Add or update syntax higlighting for AutoHotKey scripts in UltraEdit
;#
;# Mod of a script done by Tekl (although not much has survived)
;# Mod done by toralf, 2005-02-15
;#
;# Tested with: AHK 1.0.26.00, Windows XP Pro, UltraEdit 10.10c/10.20
;#
;# 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 "%var%" 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 keywords per line
;# => you can add your own files, for keywords that you want to highlight
;# Personally I use 3 additional: Operators, Separators and Special
;# 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"
;#
; 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 ; e.g. add |Operators|Separators|Special
;Default colors in UE: blue |red |orange |green |brown |blue |blue |blue
SyntaxExtention = .txt
;############# END of Customization Area ##################################
;############# Ask and Check for valid input ###############################
RegRead, UeditPath, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\UEDIT32.exe,Path
IfNotExist, %UeditPath%\uedit32.exe
{
UeditPath = %A_ProgramFiles%\UltraEdit
IfNotExist, %UeditPath%\uedit32.exe
{
FileSelectFolder, UeditPath,, 0, Select UltraEdit program-folder
IfNotExist, %UeditPath%\uedit32.exe
{
MsgBox UltraEdit cannot be found.
ExitApp
}
}
}
UEini = %APPDATA%\IDMComp\UltraEdit\uedit32.ini
IfNotExist, %UEini%
{
UEini = %A_WinDir%\uedit32.ini
IfNotExist, %UEini%
FileSelectFile, UEini, 1, %A_ProgramFiles%\UltraEdit, Select UltraEdit INI-File, *.ini
}
IniRead, UEwordfile, %UEini%, Settings, Language File
if UEwordfile = ERROR
{
MsgBox INI-File "%UEini%" is missing the Key "Language File".
ExitApp
}
;Search or ask for Wordfile, when it doesn't exist -> exit
UEwordfile = %UeditPath%\wordfile.txt
IfNotExist, %UEwordfile%
{
FileSelectFile, UEwordfile, 1, %A_ProgramFiles%, Select UltraEdit wordfile, *.txt
IfNotExist, %UEwordfile%
{
MsgBox UltraEdit Wordfile cannot be found.
ExitApp
}
}
; Search or ask for specified syntax folder and files, when they don't exist -> exit
; Get path of AHK Installation so that syntax files can be found more reliably:
RegRead, ahkpath, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotKey, InstallDir
PathSyntaxFiles = %ahkpath%\AutoHotkey\Extras\Editors\Syntax
IfNotExist, %PathSyntaxFiles%
{
PathSyntaxFiles = %A_ProgramFiles%\AutoHotkey\Extras\Editors\Syntax
IfNotExist, %PathSyntaxFiles%
{
FileSelectFolder, PathSyntaxFiles, %A_ProgramFiles%,2, Select Folder "AutoHotkey\Extras\Editors\Syntax"
IfNotExist, %PathSyntaxFiles%
{
MsgBox Folder containing syntax files not found.
ExitApp
}
}
}
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 AHK Syntax file(s)`n%MissingFile%`n`ncannot be found in`n`n%PathSyntaxFiles%\.
ExitApp
}
If FileCount > 8
{
MsgBox 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, %UEwordfile%
{
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 = ini ahk`n
StrgAHKwf = %StrgAHKwf%/Delimiters = ~!@`%^&*()-+=|\/{}[];``:"'<%A_TAB%> ,.?`n
StrgAHKwf = %StrgAHKwf%/Indent Strings = "{" ":"`n
StrgAHKwf = %StrgAHKwf%/Unindent Strings = "}" "Return" "Else"`n
StrgAHKwf = %StrgAHKwf%/Function String = "`%[^t ]++^(:++[a-zA-Z0-9]++:++[a-zA-Z0-9_äöüß<>^~!$#+.*^^^[^]]++:+^)"`n
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, %UEwordfile%, %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, %UEwordfile%, %UEwordfile%.ahk.bak, 1 ;Create Backup of current wordfile
FileMove, %TemporaryUEwordFile%, %UEwordfile%, 1 ;Replace wordfile with temporary file
; Tell user what has been done
Question = `n`nWould you like to make UltraEdit the default editor for AutoHotkey scripts (.ahk files)?
if AHKLanguageFound
MsgBox, 4,, The AutoHotkey-Syntax for UltraEdit has been updated in your wordfile:`n`n%UEwordfile%`n`nA backup has been created in the same folder.%Question%
else
MsgBox, 4,, The AutoHotkey-Syntax for UltraEdit has been added to your wordfile:`n`n%UEwordfile%`n`nA backup has been created in the same folder.%Question%
IfMsgBox, Yes
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command,, %UeditPath%\uedit32.exe "`%1"
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
TempString = %TempString%%A_LoopReadLine%`n ;otherwise add keyword to string
}
%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 ################################################ |
|
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Thu Apr 28, 2005 10:47 pm Post subject: |
|
|
Thank you Chris,
I feel blessed and honored. I currently have no changes to add.
Until someone creates a GUI for this script, a user has to change the script, if he/she wants to change the highlightning.
Since it would be great to have also highlightning for some parameters you might think of having extra syntax files for them as well shipping with AHK.
Currently my extra highlight files are:
Separators.txt | Code: | ;Separators in AHK
`n
`r
|
,
{
} |
Special.txt | Code: | ;Special Keywords for highlight in UE
** x y w h r v g
All
AutoSize
bold
BackgroundTrans
cBlue
cDefault
cGreen
cRed
cWhite
is
norm
not
Off
On |
Operators.txt | Code: | ;Operators in AHK
=
<
>
*
/
+
- |
I know that these files do not cover all parameters but all that I often use. It might not even be a feasible or desireable to create a list of all parameters (maybe the highlight would just be too much). It was just an idea. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Fri Apr 29, 2005 1:31 pm Post subject: |
|
|
| Thanks for the suggestions. I'm don't currently use any syntax highlighting, so perhaps Rajat or anyone else who has expertise in the capabilities of these fancy editors will comment on this. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Sat Apr 30, 2005 1:33 pm Post subject: |
|
|
I received the following minor changes from Thilo:
| Thilo wrote: | | I found only one little error: When reading the syntax files the whole line and not only the first word is adopted. | I'm assuming this refers to CommandNames.txt, which contains some multi-word lines such as the following:
If Else
If Var [not] between Low and High
If Var [not] contains value1,value2,...
If Var [not] in value1,value2,...
If Var is [not] type
Loop, FilePattern
Loop, Parse
Loop, Read
Loop, Reg
Here is the modified section from the subroutine ReadSyntaxFromFile:
| Code: | ;if line is comment, don't bother, otherwise add keyword to string
If Char <> `;
{
;only add first word in line
Loop parse, A_LoopReadLine, `,%A_Tab%%A_Space%
{
TempString = %TempString%%A_LoopField%`n
break
}
} |
| Quote: | | I would only connect *.ahk files with AutoHotkey and not *.ini files as well. | Here is the new version of the affected line:
StrgAHKwf = %StrgAHKwf% File Extensions = ahk`n
| Quote: | ...the chosen delimiters are unfavorable. The author has simply adopted the defaults of UltraEdit for C++ here.
I can offer a mask for function-recognition that works considerably better as the preset and that is free of German Umlaute. | Here are the affected lines:
Changed:
StrgAHKwf = %StrgAHKwf%/Delimiters = *~`%+-!^&(){}=|\/:"'``;<>%A_Tab%,%A_Space%.`n
StrgAHKwf = %StrgAHKwf%/Function String = "`%^([a-zA-Z0-9#_@$?^[^]]+^):"`n
Added:
StrgAHKwf = %StrgAHKwf%/Function String 1 = "`%^([~; ^t^p]*^)`::"`n
I will apply the changes above but comments and further corrections are welcome from anyone. |
|
| Back to top |
|
 |
Andreas Borutta
Joined: 23 Jan 2005 Posts: 46
|
Posted: Sat May 14, 2005 8:04 am Post subject: |
|
|
Thanks to all who helped to write the script for UltraEdit.
My focus as a user of autohotkey is on autotexts.
There is a new syntax which is very useful. I love it.
Example:
::adr::
(
Andreas Borutta
Hochkirchstr. 8
10829 Berlin
)
It would be very important for the legibility, that three different parts could be displayed in three different colors.
1 Colons and the both brackets
2 Hotstring
3 Autotext
It is important, that digits or any special characters inside the autotext will not be displayed in another color than the autotext. _________________ Andreas
http://borumat.de/autohotkey-autotexte-und-makros-tipps (german)
http://borumat.de/thunderbird-email-tipps (german)
http://borumat.de/firefox-browser-tipps (german) |
|
| Back to top |
|
 |
anthomas
Joined: 28 May 2005 Posts: 3 Location: California, USA
|
Posted: Sat May 28, 2005 9:37 am Post subject: |
|
|
Toralf, Tekl, Chris thanks so much for sharing the fantastic script. It's really helped out a lot and is much appreciated.
I don't know much about the way UltraEdit does syntax highlighting for functions, but what would it take to also add support for Chris' new function() calls? For example, the following does not show up in the function list:
MyFunction(ByRef x, ByRef y)
{
...
}
Last edited by anthomas on Sat May 28, 2005 10:09 am; edited 1 time in total |
|
| Back to top |
|
 |
anthomas
Joined: 28 May 2005 Posts: 3 Location: California, USA
|
Posted: Sat May 28, 2005 9:54 am Post subject: Function()'s in the function list |
|
|
OK, this gets the new function()'s listed:
/Function String = "%^([a-zA-Z0-9#_@$?^[^]]+^{:^}^{(*)^}^)"
/Function String 1 = "%^([~; ^t^p]^)("
/Function String 2 = "%^([~; ^t^p]*^)::"
From this you also get the function parameters at-a-glance. Hope this helps any other UltraEditors out there. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10716
|
Posted: Sat May 28, 2005 5:34 pm Post subject: Re: Function()'s in the function list |
|
|
| anthomas wrote: | | From this you also get the function parameters at-a-glance. | Looks like a great improvement. If anyone else gets a chance to try this out, please post any problems that arise. Otherwise, I'll apply it as-is to the next update. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3910 Location: Bremen, Germany
|
Posted: Tue May 31, 2005 10:05 am Post subject: |
|
|
Thank you for improving the script.
I tested your regex, but had some problems. Therefore I updated my regex and added a test area.
| Code: | DoubleColon := ":" ":"
StrgAHKwf = %StrgAHKwf%/Function String = "`%[^t ]++^(:[^*^?BbCcKkOoPpRrZz0-9- ]++:*%DoubleColon%^)"`n ; Hotstrings
StrgAHKwf = %StrgAHKwf%/Function String 1 = "`%[^t ]++^([a-zA-Z0-9 #!^^&<>^*^~^$]+%DoubleColon%^)"`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
/* 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:
*/
|
As you can see, I had to apply a small workaround to create double colons without seeing AHK a hotkey.
A small excurse into UltraEdit syntax highlighting:
| Code: | % beginning of line
$ end of line
? one single character
* any character
+ previous character has to be one or more times
++ previous character has to be zero or more times
^t a tab
[...] for an array of possible characters
^(...^) specifies the name to be shown as function
^ escapes the following character from regex |
The function strings are now very specific for the different function types: HotString, HotKey, Subroutine or Function.
I do not like to use of "*", since it allows all characters. Therefore I tried to allow only the allowed characters for each.
A) For all function types spaces and tabs at the beginning are ignored
"%[^t ]++"
B) Hotstring:
A colon
plus optional characters "BbCcKkOoPpRrZz", numbers, special characters "*?-" or a space
plus the second colon
plus any string
plus a double colon
"^(:[^*^?BbCcKkOoPpRrZz0-9- ]++:*::^)"
C) Hotkeys:
modifier symbols "#!^&<>*~$"
plus characters and numbers and space
plus a double colon
"^([a-zA-Z0-9 #!^^&<>^*^~^$]+::^)"
D) Subroutines:
Characters, numbers and special characters "äöüß#_@$?[]"
plus a colon
"^([a-zA-Z0-9äöüß#_@^$^?^[^]]+:^)"
E) Functions:
Characters, numbers and special characters "äöüß#_@$?[]"
plus a opening parenthesis
plus any string
plus a closing parenthesis
"^([a-zA-Z0-9äöüß#_@^$^?^[^]]+(*)^)"
@Chris:
1) Where am I to strikt in the above cases?
2) Where can I restrikt it even strikter?
If you could give me an answer, I will create a complete update of the code. _________________ Ciao
toralf  |
|
| 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
|