yet another syntax highlighting question

General questions about using TextPad

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

Post Reply
Brian Rogers

yet another syntax highlighting question

Post by Brian Rogers »

I am using TextPad (great product, by the way) to edit .JSP files and want to take full advantage of the syntax highlighting. I have downloaded version 2 of the jsp.syn files and set everything up so that it will color my files appropriately, but I have run into a problem while tweaking the .syn file to my needs.

Specifically, I am trying to get certain keywords to show up colored regardless of whether there is a period (.) after them or not. For example, I have the word "request" in my [Keywords 1] section. In my .jsp document when I have "request.anything" the word "request" does not show up blue, but when I put any of the operator characters or a space after it, it does show up blue (e.g. "request+anything" or "request anything"). I thought adding a period to the set of operator characters would solve the problem, but it does not seem to make a difference. (And yes I did try closing and re-opening the document as well as closing and re-opening TextPad.) Is this a bug?

Any help would be appreciated.

Brian Rogers
Interface Software, Inc.
brogers@interfacesoftware.com
Brian Rogers

Re: yet another syntax highlighting question

Post by Brian Rogers »

After digging through tons of old posts I think I have found the answer to this. The keywords lists in the jsp.syn contained some items that had periods in them. Apparently this causes TextPad to treat all periods as part of the set of characters that can make up a keyword even though the period was not specified in the "KeyWordChars=" setting in the [Syntax] section! I went through the jsp.syn file and removed all keywords that had periods in them; now everything lights up as I would expect it to.

It would be nice if there was better documentation as to how the syntax highlighting worked so users wouldn't have to spend so much trial-and-error time setting up .syn files. For example, questions I still have which are unanswered by the documentation or any posts I have read here are:

- Exactly what effect does changing C=1 to HTML=1 have on the highlighting? What if you are doing a .syn file for JSP or ASP, which contain some elements that match both syntaxes?

- The doc mentions "namespaces" and says that there are two namespaces when HTML=1. I assume this means you can have two keywords of the same name and have them colored differently depending on certain factors. What are the factors? How do you take advantage of these different namespaces? How does TextPad tell the difference between one or the other?

After battling with some of this stuff I would tend to agree with other users who have suggested supporting regular expressions or at least some sort of simple wildcard mechanism in .syn files might be a good thing. I do realize this would cause a bit of a performance hit, but as machines continue to get faster it may be worth considering for a future release. Perhaps adding an option as to whether or not to use regular expressions so users can choose based on the speed of their machines.

-Brian
Randall McDougall

Re: yet another syntax highlighting question

Post by Randall McDougall »

For your two unanswered questions:

C=1 has syntax hiliting on all the time. HTML=1 is a "Markup" language, and turns syntax checking on/off (ie. only within "< >" or whatever you define in the .syn file), and also allows 2 namespaces ...

And you're right that the second namespace allows duplicate keywords (properly -- just throwing in duplicate in namespace=1 won't kill anything), but *NO* it doesn't hilite in a different color -- there's no criteria for selecting one over the other it just uses the last one (and I know and agree that that seems pointless, but for now that's the way it works) ...
Brian Rogers

Re: yet another syntax highlighting question

Post by Brian Rogers »

Thanks, Randall, for taking the time to answer my questions. It definitely clears some things up for me. It does seem odd to have two namespaces if you can't do anything useful with them, but I guess that's the way it goes. I do have to give TextPad a lot of credit though-- it may not be perfect at syntax highlighting, but it does a pretty decent job given that it's trying to be generic enough to tackle every single programming language out there!

-Brian
John Davidson

Re: yet another syntax highlighting question

Post by John Davidson »

Regarding the above mention of TextPad ignoring a . as the end of a keyword, I have noticed the same effect if a ( is used in a keyword. It is ignored for the purposes of detecting the end of a keyword.
Brian Rogers

Re: yet another syntax highlighting question

Post by Brian Rogers »

Look through your list of keywords. If any of the keywords have a left paren in them, that could be causing the problem. Remove the paren from ALL your keywords and then try it. It appears that Textpad scans the list of keywords and compiles its list of keyword characters from that rather than (in addition to?) just going by the "KeyWordChars" setting in the syntax section. Also make sure there's not a left paren in the KeyWordChars setting itself.

Hope this helps,
Brian
Post Reply