Syntax Files - Dynamic Keywords

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply

How important is it to you, to have this feature implemented into future versions of TextPad?

Important, even if the size/efficiency of TextPad increases/degrades
23
37%
Somewhat important
25
40%
I'm okay either way
6
10%
Somewhat unimportant
7
11%
Unimportant, even if the size/efficiency of TextPad remains unaffected
2
3%
 
Total votes: 63

User avatar
trids
Posts: 69
Joined: Wed May 07, 2003 10:16 am
Location: South Africa

Syntax Files - Dynamic Keywords

Post 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()
burmashave
Posts: 3
Joined: Thu Jun 26, 2003 6:00 pm

Post 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.
Billi
Posts: 9
Joined: Mon Jun 16, 2003 8:48 am
Location: Radebeul, Germany
Contact:

Post 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
kaeng
Posts: 1
Joined: Tue Jul 29, 2003 7:40 pm

Post 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. :)
User avatar
ramonsky
Posts: 88
Joined: Fri Nov 14, 2003 10:54 am

Post 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
Thomas Schremser

Post 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.
User avatar
ramonsky
Posts: 88
Joined: Fri Nov 14, 2003 10:54 am

Post 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
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post 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.
Hope this was helpful.............good luck,
Bob
User avatar
CyberSlug
Posts: 120
Joined: Sat Oct 04, 2003 3:41 am

Post 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!
kaspi
Posts: 2
Joined: Tue Jan 27, 2004 9:15 pm

Post 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).
bobtarling
Posts: 9
Joined: Tue Feb 03, 2004 5:09 pm
Location: UK

Post 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
bobtarling
Posts: 9
Joined: Tue Feb 03, 2004 5:09 pm
Location: UK

Post 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
bjack985
Posts: 3
Joined: Wed Mar 10, 2004 5:09 pm

Post by bjack985 »

I'll vote for this too. I'm looking for this feature to highlight email addresses using a regexp string.
BobHowlett
Posts: 1
Joined: Sun Mar 20, 2005 6:48 am

Regular expression syntax highlighting

Post 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.
Post Reply