Highlighting all variables defined in a file in whole file

Highlighting all variables defined in a file in whole file

3
NewbieNewbie
3

    Jul 15, 2009#1

    Interesting Idea here, was wondering if say i was to do "/declare VarName1 string outer"

    Any way to make say anything After Declare and Before String be it's own color say Purple, Though out the whole code.

    My Programming Language use's the following for Declare's

    /declare varname|varname[array extents] [type] [local|global|outer] [defaultvalue]

    Types:

    Code: Select all

        * altability
        * argb
        * array
        * body
        * bool
        * buff
        * byte
        * character
        * class
        * corpse
        * currentzone
        * deity
        * dynamiczone
        * dzmember
        * evolving
        * fellowship
        * fellowshipmember
        * float
        * ground
        * group
        * groupmember
        * heading
        * int
        * invslot
        * item
        * macro
        * macroquest
        * math
        * merchant
        * plugin
        * race
        * raid
        * raidmember
        * skill
        * spawn
        * spell
        * string
        * switch
        * ticks
        * time
        * timer
        * type
        * window
        * zone
    I was looking for more of a way to do like this

    /declare hold-msg string outer 5

    /if (${hold-msg} == 5) {
    /varset hold-msg "Please hold on until I catch up"
    /echo ${hold-msg}
    }

    So no matter how i use the declared Variable "hold-msg" it will be purple throw out that file.

    I'm not even sure if something like this is possible just a cool thought i got in my head thought i would ask.

    6,683583
    Grand MasterGrand Master
    6,683583

      Jul 16, 2009#2

      Well, again a user who wants to know if it is possible to highlight the own defined symbols (function names, variable names, preprocessor definitions, etc.) with a specific color. The short answer is: NO.

      UltraEdit is not capable to create and update dynamically a list of words for highlighting on every modification of a file (every key hit which modifies the file) or every file saved. UEStudio supports creation of a symbol database for some common programming languages, but also does not use that symbol database for syntax highlighting.

      The approach I use to see im my files my own symbols with a color is to highlight everything else not being variable. So my wordfiles contain appropriate settings to highlight double and single quoted strings, numbers, comments, fixed keywords depending on the programming languages, fixed symbols of all the libraries offered by the compiler (names of the standard libraries, function names, preprocessor definitions, type definitions of the standard library functions), all the braces and all the operators. So the only strings in my files displayed as normal text are my function names, my variables, my preprocessor definitions and the file names of my header files and libraries.

      Sometimes I use for special symbols like global variables a fixed string before the real symbol name like gl_ for global variables, or gc_ for global constants and gb_ for global bit variables. Those variables are then highlighted with using a substring definition in the wordfile of the project (only used in project specific wordfiles):

      ** gb_ gc_ gl_

      Of course you could write a macro or script which you execute manually or is automatically executed on every file save
      • to scan the whole active file for the symbols with variable names in the active file based on your own rules (regular expressions),
      • collect them in an array or user clipboard,
      • open the wordfile used to highlight this file,
      • selects the already existing list of variable symbol names,
      • replaces the selection (list of words) with the just extracted symbols,
      • sorts them correct within the color group according to Nocase keyword in the wordfile for that language,
      • saves the wordfile which should trigger UltraEdit to reread it and apply it later accordingly,
      • closes the wordfile and
      • restores the cursor position remembered before starting the scan
      I have never tried if that really works, although I have suggested it already a few times for user having the same question of you. If you are good in writing scripts and macros, feel free to code it and post the result. I would be really interested if such an update macro/script for a dynamic word list really works. A macro automatically executed on every save of a file with extension ??? would be really cool for such a syntax highlighting requirement. But arrays are not supported in the macro environment and collecting the symbols in a clipboard has the problem how to separate them with line breaks or another character because appending a string is also not possible in macros. Also remembering the current cursor position would be possible with a macro only by using either a bookmark when not normally using bookmarks or by inserting a special string at current cursor position and search for that string before macro exit with deleting it (results in undo step(s). A script solution would not have all this limitations. But it is not possible to execute a script automatically on every file save except a script is assigned to Ctrl+S and does the file save job after with evaluating if based on the file extension of the active file all above should be done too.
      Best regards from an UC/UE/UES for Windows user from Austria