Inconsistent selection on double click

General questions about using TextPad

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

Post Reply
User avatar
kikosoft2
Posts: 28
Joined: Sun Apr 08, 2007 12:23 pm

Inconsistent selection on double click

Post by kikosoft2 »

Hi,

I found that, sometimes, when I double click on a variable in PHP it doesn't only select the variable name, but also the '$' in front, and '-' at the end.

For example, when I have this line of code:

$pleaseClickHere->someMethod();

and I double click on the word 'Click', I expect to select this:

$pleaseClickHere->someMethod();

but on some occasions I get this:

$pleaseClickHere->someMethod();

I checked whether this could be caused by the character encoding of the file, but there does not seem to be a relation.

I looked for a setting for double clicks, but there doesn't seem to be one. Could this be a bug?

This happens in TP 8.1.1 under Windows 10, using the php-js-css-html.syn highlighter file.
User avatar
AmigoJack
Posts: 531
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

In case you're talking about "PHP/JavaScript/CSS and HTML" at Syntax Definitions N-T then I could verify said behaviour. Change two lines in that file - find:

Code: Select all

InitKeyWordChars = A-Za-z_
KeyWordChars = A-Za-z0-9_
and replace with:

Code: Select all

InitKeyWordChars = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_
KeyWordChars = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_
That stopped said behaviour for me in PHP code. I don't understand why the $ was selected and now isn't anymore, tho.
User avatar
kikosoft2
Posts: 28
Joined: Sun Apr 08, 2007 12:23 pm

Post by kikosoft2 »

Thank you for your reply.

I gave it a try, and I am sorry to say that it made no difference.
User avatar
AmigoJack
Posts: 531
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

And you edited the file and restarted Textpad? Maybe the order of the instructions also matters - my file looks like this currently (too big for the post): http://pastebin.com/yA0HNAue
User avatar
kikosoft2
Posts: 28
Joined: Sun Apr 08, 2007 12:23 pm

Post by kikosoft2 »

Yes, I edited and restarted, of course.

There's only one difference with your file, the empty KeyWordLength parameter is in a slightly different location.

I replaced my file with yours. This, however, made no difference. I tried several other things with the syntax file, without success.

I also could not find any good documentation for the syntax files. Am I missing something here? Clearly the syntax file is the cause. My test was: After renaming a .php file to .txt the double click selection works as expected. So we are on the right track here.

I forgot to mention that I am using the 64 bit version of TP.

Ok, here's something. When you change the syntax file in TP it says:
When selecting and stepping over "words", the default set of characters in a word are letters, numbers and those used in keywords in the syntax file.
And yes, '$' and '-' are used in keywords definitions of the syntax file. When I switch to another PHP syntax file (Contributed by Amit Verma, 12 September 2009) the double click works normally. It has not got '$' in any keyword, but it does have the '-' in some.

Enough, I'll use the other PHP syntax file, it is good enough for my purposes. Still, I don't like something I cannot explain.
Art Metzer
Posts: 27
Joined: Mon Mar 06, 2006 5:31 pm

Post by Art Metzer »

kikosoft2:

I had a revelation similar to yours. Please see my forum posting, and helios's response, here.
User avatar
kikosoft2
Posts: 28
Joined: Sun Apr 08, 2007 12:23 pm

Post by kikosoft2 »

Art Metzer:

So the syntax specifications seem to have changed, or now work as they always should have?

In the end I did find the specifications of the syntax files in the 'TextPad Help' under the heading 'Syntax Definition Files'.

Would it be a good idea if TP used the 'KeyWordChars' parameter, when it is present, and only look at the characters in all the keywords, when it is absent? Then compatibility with existing syntax files would not be broken.
Post Reply