Page 1 of 1

Syntax Files - Dynamic Keywords

Posted: Mon May 12, 2003 8:29 am
by trids
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()

Posted: Thu Jun 26, 2003 6:01 pm
by burmashave
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.

Posted: Fri Jun 27, 2003 5:48 am
by Billi
Yeah! I can think of some usefull appilcations too. Most of my own expression (newcommands) in LaTeX start with \my..., so it would be highlighted with the entry \my[_a-zA-Z0-9]*. Right?!

Billi

Posted: Tue Jul 29, 2003 7:45 pm
by kaeng
Ah, I guessed I wouldn't be the only one to demand this feature. It wouldn't automatically decrease the performance, if the regex engine would only be loaded when regex are used. Looking forward to see this in the next release. :)

Posted: Tue Dec 16, 2003 12:01 pm
by ramonsky
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

Posted: Tue Dec 16, 2003 1:01 pm
by Thomas Schremser
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.
Not if you add the $-character to 'other characters in words' under Preferences|Document Classes|<Your Class>|Syntax.

Posted: Tue Dec 16, 2003 1:12 pm
by ramonsky
I stand corrected. :oops:

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

Posted: Wed Dec 17, 2003 12:49 am
by Bob Hansen
Regexps may be unnecessary overkill. Does anyone have a need for anything more complicated than "words starting with...."?
Yes.

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.

Posted: Wed Dec 17, 2003 7:00 am
by CyberSlug
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!

Posted: Wed Jan 28, 2004 9:08 am
by kaspi
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).

Posted: Tue Feb 03, 2004 6:38 pm
by bobtarling
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
  1. no pattern match
  2. DOS style syntax * and ? only
  3. True regexp

Posted: Wed Feb 04, 2004 11:04 am
by bobtarling
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

Posted: Wed Mar 10, 2004 7:15 pm
by bjack985
I'll vote for this too. I'm looking for this feature to highlight email addresses using a regexp string.

Regular expression syntax highlighting

Posted: Sun Mar 20, 2005 7:08 am
by BobHowlett
burmashave 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.
I want this feature too. I find that LaTeX.syn doesn't work adequately
for my TeX files.