Clipper/xHarbour Wordfiles - syntax highlighting and code folding

Clipper/xHarbour Wordfiles - syntax highlighting and code folding

1
NewbieNewbie
1

    Apr 10, 2009#1

    Hi

    I'm evaluating UE for use with xHarbour/Clipper and have had a go at setting up a wordfile to provide syntax highlighting and code folding for Clipper/xHarbour, but it's not at all pretty (yet) !

    The problems I'm having are:

    1. Syntax highlighting is not working consistently.

    For example, the C1 wordlist is:
    hbcheckbox hblistbox hbobject hbpersistent hbpushbutton hbradiobutton hbradiogroup hbscrollbar menuitem popup 
    tbcolumn tbrowse thtmldocument thtmliterator thtmliteratorregex thtmliteratorscan thtmlnode tipclient tipclientftp
    tipclienthttp tipclientpop tipclientsmtp tipmail topbarmenu tstream tstreamfilereader tstreamfilewriter turl
    txmldocument txmliterator txmliteratorregex txmliteratorscan txmlnode win32bmp win32prn

    But when UE displays a .prg file containing all of the above C1 words, not all of them are highlighted in the color assigned to that category of keywords. Specifically, the following words aren't correctly highlighted:
    menuitem popup tipclientftp turl win32bmp win32prn.

    As another example, the C2 wordlist is:
    #command #define #error #if #ifdef #ifndef #include #pragma #stdout #translate #uncommand #undef #untranslate #xcommand #xtranslate #xuncommand #xuntranslate

    But when UE displays a .prg file containing all of the above C2 words, it correctly highlights all of the above words except for #xuntranslate.

    As another example, the C3 wordlist is:
    access announce assign associate begin break case catch class classdata classmethod data delegate destructor do each enable end endclass error exit exported extend external field for from function global handler hidden if init inline local memvar message method object operator override parameters pragma private procedure protected public readonly recover request return sequence shared static struct switch try type typedef var virtual while with

    When UE displays a .prg file containing all of the above C3 words, the following words are not highlighted: begin break case catch class classdata classmethod data delegate destructor do each enable end endclass error exit exported extend external function global handler hidden if init inline local memvar message method object operator override parameters pragma private procedure protected public sequence shared static struct switch try type typedef var virtual while with

    And one more example: The C4 wordlist is:
    accept all alternate append autopen autorder autoshare average background backgroundtick bell blank box cancel century checkbox clear close
    color commit confirm console continue copy count create cursor date dbflockscheme decimals default delete deleted delimiters descending device dircase
    dirseparator eject eol epoch erase errorlog errorloop escape eventmask exact exclusive extended file filecase filter find fixed
    gets go hardcommit index input   intensity join key keyboard list listbox locate log margin memoblock memory menu optimize order
    pack path printer prompt pushbutton quit radiogroup read recall reindex relation release rename replace restore run save say scope
    scopebottom scopetop scoreboard screen seek select set skip softseek sort store strictread structure style sum tag tasks text time to
    total trace typeahead unique unlock update use videomode wait wrap zap

    When UE displays a file containing all of the above C4 words, the following words are not highlighted:
    background backgroundtick bell blank box cancel century checkbox clear close date dbflockscheme decimals default delete deleted delimiters descending device dircase
    eject eol epoch erase errorlog errorloop escape eventmask exact exclusive extended file filecase filter find fixed
    hardcommit index input   intensity join key keyboard list listbox locate log margin memoblock memory menu optimize order
    quit radiogroup read recall reindex relation release rename replace restore run save say scope
    tag tasks text time to
    unique unlock update use videomode wait wrap zap


    2. Code folding not working consistently.

    Code folding works consistently for the following constructs:

    Code: Select all

      // example 1
        function <function_name>
        ..
        return ( <return_value> )
    
      // example 2
        do while <condition>
        ..
        enddo
    
      // example 3
        if <condition>
        ..
        endif
    But not for the following constructs:

    Code: Select all

      // example 4
        init procedure <procedure_name>
        ..
        return
    
      // example 5
        class <class_name>
        ..
        endclass
    
    
      // example 6
        method <method_name>
        ..
        return
    
      // example 7
        static procedure <procedure_name>
        ..
        return
    3. Jump to include file
    Also, I'd like to be able to place the cursor on a line containing an #include statement, eg. #include 'Stdio.ch' and get UE to locate and open the #include file by pressing a hotkey.

    These problems I'm experiencing are probably the result of some dumb mistake of mine in my wordfile (included below), so if you have any pointers or suggestions I'd be thankful to hear them.

    Any pointers or suggestions would be appreciated.

    Thanks

    rl

    Here is the complete contents of my wordfile (xHarbour.uew) between the ('- - - - - cut here - - - - -' lines)

    - - - - - cut here - - - - -
    /L20"Clipper/xHarbour" Line Comment = // Nocase Line Comment Alt = * Block Comment On = /* Block Comment Off = */ Escape Char = \ String Chars = "' File Extensions = PRG CH
    /Colors = 12632256,12632256,8421376,8421504,255,
    /Colors Back = 0,0,16777215,16777215,16777215,
    /Colors Auto Back = 0,1,1,1,1,
    /Font Style = 0,0,0,0,0,
    Colors Back = 0,0,16777215,16777215,16777215,
    Font Style = 0,0,0,0,0,
    Colors Back = 0,0,16777215,16777215,16777215,
    Font Style = 0,0,0,0,0,
    Colors Back = 0,0,16777215,16777215,16777215,
    Font Style = 0,0,0,0,0,
    Colors Back = 0,0,16777215,16777215,16777215,
    Font Style = 0,0,0,0,0,
    /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> , .?
    /Function String 1 = "%[CLASS]+CLASS"
    /Function String 2 = "%[METHOD]+METHOD"
    /Function String 3 = "%[PROCEDURE]+PROCEDURE"
    /Function String 4 = "%[FUNCTION]+FUNCTION"
    /Ignore Strings SOL = "*" "//" "/*" "*/" "#"
    /Open Fold Strings = "{" "class" "method" "procedure" "exit procedure" "init procedure" "function" "if" "do case" "do while" "for"
    /Close Fold Strings = "}" "endclass" "return" "return" "return" "return" "return" "endif" "endcase" "enddo" "next"

    /C1 Colors = 16711680 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
    hbcheckbox hblistbox hbobject hbpersistent hbpushbutton hbradiobutton hbradiogroup hbscrollbar menuitem popup 
    tbcolumn tbrowse thtmldocument thtmliterator thtmliteratorregex thtmliteratorscan thtmlnode tipclient tipclientftp
    tipclienthttp tipclientpop tipclientsmtp tipmail topbarmenu tstream tstreamfilereader tstreamfilewriter turl
    txmldocument txmliterator txmliteratorregex txmliteratorscan txmlnode win32bmp win32prn
    /C2 Colors = 255 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
    #command #define #error #if #ifdef #ifndef #include #pragma #stdout #translate #uncommand #undef #untranslate #xcommand #xtranslate #xuncommand #xuntranslate
    /C3 Colors = 33023 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
    access announce assign associate begin break case catch classdata classmethod data delegate destructor do each enable end endclass error exit exported extend external
    field for from global handler hidden if init inline local memvar message object operator override parameters pragma private protected public
    readonly recover request return sequence shared static struct switch try type typedef var virtual while with
    /C4 Colors = 32768 Colors Back = 16777215 Colors Auto Back = 1 Font Style = 0
    accept all alternate append autopen autorder autoshare average background backgroundtick bell blank box cancel century checkbox clear close
    color commit confirm console continue copy count create cursor date dbflockscheme decimals default delete deleted delimiters descending device dircase
    dirseparator eject eol epoch erase errorlog errorloop escape eventmask exact exclusive extended file filecase filter find fixed
    gets go hardcommit index input   intensity join key keyboard list listbox locate log margin memoblock memory menu optimize order
    pack path printer prompt pushbutton quit radiogroup read recall reindex relation release rename replace restore run save say scope
    scopebottom scopetop scoreboard screen seek select set skip softseek sort store strictread structure style sum tag tasks text time to
    total trace typeahead unique unlock update use videomode wait wrap zap
    - - - - - cut here - - - - -

    119
    Power UserPower User
    119

      Apr 10, 2009#2

      The keywords in the /C sections have to be sorted. Keywords with different initial characters must be on different lines.
      Help of UE wrote:Keywords
      Note that ALL words starting with the same character may be on the same line or spread across multiple lines, however if they are spread across multiple lines the lines must be one after the other with no empty lines or other line lines between them.

      If the language is case sensitive, the letter 'A' is different from 'a' and so words starting with 'A' MUST be on a different line from words starting with 'a'.  If the language is case insensitive words starting with the letter 'A' must be on the same line as words starting with the letter 'a'.
      Mofi's macros in the ultimate syntax highlighting tools thread might be helpful.

      6,686585
      Grand MasterGrand Master
      6,686585

        Apr 11, 2009#3

        I used my macro SortLanguage to fix the sorts in the color groups. That should fix all your keywords highlighting problems.

        Furthermore I removed the lines starting with Color at top of the wordfile because these are remains from a beta version of UE v15.00.

        I changed also the function strings, because %[CLASS]+CLASS means
        • find at start of the line
        • a string consisting of the letters ACLSacls
        • followed by the word CLASS in any case
        I'm sure that this is not the search you want.

        The code folding problem should be fixed too. You can't specify "procedure" "exit procedure" "init procedure" because "procedure" exists in all 3 strings and UltraEdit simply searches for the open fold strings as specified and does not look on the rest of the line once one of the strings is found in a line.

        I'm not sure about /Ignore Strings SOL = "*" "//" "/*" "*/" "#" Why do you specify here the line and block comment characters too?

        About opening the include file: Normally you can right click on a file name to open this file. For file names without an absolute path the file must be found relative to active working directory which is normally the directory of the active file - see How to open a highlighted file name for more details and a script solution if a file without path is not in the same directory as the active file.

        UEStudio has for C/C++ programmers the feature to open the corresponding file for a header (*.h) or source code file (*.c;*.cpp). UltraEdit does not have this feature. But you can use Edit - Copy File Path/Name, followed by File - Quick Open, Ctrl+V to paste the file name of the active file into the edit field, replace the extension and press RETURN to open the corresponding header/source file. Well, with an appropriate script this can be done with a single hotkey press.

        But C/C++ programmers prefer using Search - Find Symbol to set the cursor to the definition line of a symbol (function, global variable, define, constant, etc.) independent in which file the symbol definition line is. With Search - Back (last position) we can quickly go back to previous position to continue editing. But to be able to use Search - Find Symbol you need to work with a project and setup Ctags which creates the symbol database. Ctags can be highly customized and therefore can be used also for non standard programming languages.
        Clipper_xHarbour.zip (1.54 KiB)   520
        Updated/corrected wordfile for Clipper/xHarbour.
        Best regards from an UC/UE/UES for Windows user from Austria