Syntax Files - Dynamic Keywords
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Syntax Files - Dynamic Keywords
I would like to be able to specify more than literals for highlighting. Perhaps a regular expression in the SYN file could identify a "keyword" .. EG: in my documentation, I wish to highlight mention of my servers (Eg NTSV_WC26, NTSV_JHB02, NTSV_NATAL01.) and instead of listing each one in the syntax file, I would like to identify them with a single definition as follows:
NTSV_[^\t .,()]+
Dynamic keywords can also be used on source code, to highlight variables with specific hungarian notation. For example:
the global variables gauDendrites() and gauCategories() could be highlighted in one fashion to distinguished from local versions of the same variables: auDendrites() and auCategories()
NTSV_[^\t .,()]+
Dynamic keywords can also be used on source code, to highlight variables with specific hungarian notation. For example:
the global variables gauDendrites() and gauCategories() could be highlighted in one fashion to distinguished from local versions of the same variables: auDendrites() and auCategories()
-
- Posts: 3
- Joined: Thu Jun 26, 2003 6:00 pm
One of the really neat things about the computer language PHP is that all variable names start with $, so you never have to worry about clashing with a reserved word. But TP's syntax coloring doesn't allow for this. If you tell it that, for example, "count" is a reserved word (which it is), and that reserved words are to be colored blue, then "$count" will be colored with the substring "count" in blue. This can actually be annoying enough to force me to change the variable name, even though there's nothing wrong with it.
It would be really useful to have all PHP variable names (identifiers preceded by $) colored - and colored differently from reserved words. I believe Trids' suggestion, if implemented, would allow that to happen.
Jill
It would be really useful to have all PHP variable names (identifiers preceded by $) colored - and colored differently from reserved words. I believe Trids' suggestion, if implemented, would allow that to happen.
Jill
Not if you add the $-character to 'other characters in words' under Preferences|Document Classes|<Your Class>|Syntax.ramonsky wrote:If you tell it that, for example, "count" is a reserved word (which it is), and that reserved words are to be colored blue, then "$count" will be colored with the substring "count" in blue.
I stand corrected.
But in the spirit of the original post, I guess what I'd like to see is the ability to have all PHP variable names (words starting with "$") highlighted the same color. Essentially, most people here seem to asking for the ability to color "words starting with ..." instead of just "words which exactly equal ....".
Regexps may be unnecessary overkill. Does anyone have a need for anything more complicated than "words starting with...."?
Jill
But in the spirit of the original post, I guess what I'd like to see is the ability to have all PHP variable names (words starting with "$") highlighted the same color. Essentially, most people here seem to asking for the ability to color "words starting with ..." instead of just "words which exactly equal ....".
Regexps may be unnecessary overkill. Does anyone have a need for anything more complicated than "words starting with...."?
Jill
- Bob Hansen
- Posts: 1516
- Joined: Sun Mar 02, 2003 8:15 pm
- Location: Salem, NH
- Contact:
Yes.Regexps may be unnecessary overkill. Does anyone have a need for anything more complicated than "words starting with...."?
I like to see function and commands highlighted as keywords. And the current method allows me to make multiple syntax files for the same class of documents. And it is flexible enough to handle any languages that exist now and will show up in the future.
"words starting with..." might be good for handling variables, but the current method allows me the freedom to make my own choices about keywords. This would not work on many existing commands and functions because they do not have a common leader.
More flexibility is needed, and RegEx would be a help in that direction. Not the complete solution, but more is better here. Complete would be nice, but not necessary.
Hope this was helpful.............good luck,
Bob
Bob
is also useful for a language that uses lots of labels for routines.
Highlighting all words that end in colons is not currently possible, as far as I know. (Something like ^.+:$ or ^.+:[[:blank:]]*$ might work).
Also, the simulation language Simscript uses a dotted notation so all of its functions end in .f, constants in .c, system-wide variables with .v and so on. Regular expressions would be well-suited here!
Highlighting all words that end in colons is not currently possible, as far as I know. (Something like ^.+:$ or ^.+:[[:blank:]]*$ might work).
Also, the simulation language Simscript uses a dotted notation so all of its functions end in .f, constants in .c, system-wide variables with .v and so on. Regular expressions would be well-suited here!
-
- Posts: 9
- Joined: Tue Feb 03, 2004 5:09 pm
- Location: UK
kaspi wrote:I do not need anything more than keywords begging with a special character. I am afraid RegEx would degrade TextPad's efficiency. And efficiency is probably the most important thing why I use TextPad (my computer is not the newest one).
As someone pointed out earlier, any inefficiencies brought in by using regexp would hit you only if you chose to use it. If your keyword list didn't contain any regexp expressions then it would fly through.
Personally I like the idea.
I guess it should be brought in as a global option in the syn file. Otherwise those who are not regexp savvie may trip over by including keywords containing regexp characters.
If there are real problems with performance and the regexp concept then it could be a 3 way switch
- no pattern match
- DOS style syntax * and ? only
- True regexp
-
- Posts: 9
- Joined: Tue Feb 03, 2004 5:09 pm
- Location: UK
I don't want to cross-post the detail so here's a link to a related comment I've added to another thread - http://www.textpad.com/forum/viewtopic. ... 5835#15835
-
- Posts: 1
- Joined: Sun Mar 20, 2005 6:48 am
Regular expression syntax highlighting
I want this feature too. I find that LaTeX.syn doesn't work adequatelyburmashave wrote:I agree. I would really like to see syntax highlighting based on regular expressions, and this seems to be the way other advanced editors are going.
for my TeX files.