AutoHotkey Community

It is currently May 26th, 2012, 7:25 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: May 31st, 2005, 11:40 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 31st, 2005, 2:08 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Last edited by toralf on November 14th, 2005, 4:53 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2005, 11:59 pm 
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".


Report this post
Top
  
Reply with quote  
 Post subject: @toralf
PostPosted: July 6th, 2005, 3:46 am 
Offline

Joined: July 6th, 2005, 2:36 am
Posts: 10
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2005, 10:59 am 
Offline

Joined: July 6th, 2005, 2:36 am
Posts: 10
I replace "`n" with a carriage return (new line)?

So Operators.txt => "=`n<`n>`n*`n/`n+`n-" should be ...
Code:
=
<
>
*
/
+
-
and Separators.txt => "``n`n``r`n|`n,`n{`n}" should be...
Code:
`

``r
|
,
{
}
Not entirely sure about the last one.

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 6th, 2005, 11:07 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Last edited by toralf on November 14th, 2005, 4:49 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: @toralf
PostPosted: July 6th, 2005, 11:39 am 
Offline

Joined: July 6th, 2005, 2:36 am
Posts: 10
Thanks for clarifying.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 18th, 2005, 8:22 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 18th, 2005, 4:46 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 20th, 2005, 7:05 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Thanks Chris.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2005, 4:58 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2005, 5:34 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2006, 1:23 pm 
Thanks to Tekl !
It works immediately (in UE9.0)
:D


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 58 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], Scratch, Xx7 and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group