You are here: PSPad forum > English discussion forum > file specific variable hightlighting

file specific variable hightlighting

Goto Page: 1 2 Next

#1 file specific variable hightlighting

Posted by: halweg | Date: 2020-10-02 06:09 | IP: IP Logged

Hi,
I'm using PSPad for Autohotkey syntax highlighting.
It worked fine but I wished to have variables to be highlighted.

So I used the KeyWords3 section in the autohotkey.ini file and added the variable names.
Later I wrote an Autohotkey script that automatically opens each .ahk file with a special copy of autohotkey.ini. This way variable highlighting became file specific (but it doesn't work when multiple files are open at once). Moreover I coded some hotkeys for fast adding of new variable names in the current autohotkey.ini file.

This all works fine. But meanwhile I know the big scripting opportunities PSPad offers. So I wonder if there are any easier or better ways to solve the file specific variable highlighting.

Greetings, Halweg

Options: Reply | Quote | Up ^


#2 Re: file specific variable hightlighting

Posted by: pspad | Date: 2020-10-02 07:16 | IP: IP Logged

I don't know Autohotkey
Is there way how recognize variable?

Options: Reply | Quote | Up ^


#3 Re: file specific variable hightlighting

Posted by: halweg | Date: 2020-10-02 07:49 | IP: IP Logged

I'm afraid no.
Variables are everything that isn't any other thing.

But I like it to mark variables and set them to be a "keywords3". For me this must be an conscious process.

So my question is more like:
Is there a mechanism for file specific highlighting?
Is there a way to "on-the-fly" add marked variable names to any keyword section in the current syntax ini-file?

Options: Reply | Quote | Up ^


#4 Re: file specific variable hightlighting

Posted by: halweg | Date: 2020-10-06 13:25 | IP: IP Logged

Is there really no PSPad-integrated way (menu, button) to add names to a current loaded keyword section in the syntax ini-file?

Options: Reply | Quote | Up ^


#5 Re: file specific variable hightlighting

Posted by: pspad | Date: 2020-10-06 13:34 | IP: IP Logged

The way how to fill keyword list dynamically must be created. Please note that highlighting is realtime process during page painting and must be highly optimized. It can't be "delayed" by running any events, calling external scripts e.t.c.

Options: Reply | Quote | Up ^


#6 Re: file specific variable hightlighting

Posted by: halweg | Date: 2020-10-06 14:32 | IP: IP Logged

I think I understood.
So I'm happy my approach works:
1. writing the current name (under the cursor) in the keywords3 section of the current ini-file,
2. saving the ini-file,
3. calling "highlighter settings"
4. leaving the dialog with ESC.

Of course there are some further tasks: add reserved word, remove Keyword, ...
But the steps above seemed to me so easy that I wondered there's no build-in way.

Thanks for your patient help anyway.

Greetings, Halweg

Options: Reply | Quote | Up ^


#7 Re: file specific variable hightlighting

Posted by: Professor Bernd | Date: 2020-10-07 16:14 | IP: IP Logged

halweg:
Variables are everything that isn't any other thing.

Can you post a screenshot? And how are the variables declared? Maybe I can find a solution.

Options: Reply | Quote | Up ^


#8 Re: file specific variable hightlighting

Posted by: halweg | Date: 2020-10-07 17:18 | IP: IP Logged

Thanks, but finding variables in Autohotkey by syntax is hard.
Screenshot:1drv.ms
Following the rules a variable should be declared by giving it a value. This usually should be done by any := statement, but also variables came from function parameters and from the old legacy statements (in the example above the "stringreplace" command initializes the "keyname" variable).

There is a #WARN directive in AHK the gives error messages for every variable without initial declaration.

According the forum site (www.autohotkey.com) there are some other AHK programmers that use PSPad.

For me the Keywords3 section is just a good place to declare new valid variable names for the individual ahk file. Automatic recognition of variable names from some initialization statements wouldn't find misspelled names like:

this_var := 351
increase_value := 3
thisvar := increase_value + MIN(this_var,400)

Options: Reply | Quote | Up ^


#9 Re: file specific variable hightlighting

Posted by: Professor Bernd | Date: 2020-10-07 18:08 | IP: IP Logged

I sent you a PM. If you speak German, it will be easier with it. If you don't speak German, please let me know here.

Options: Reply | Quote | Up ^


#10 Re: file specific variable hightlighting

Posted by: pspad | Date: 2020-10-08 05:47 | IP: IP Logged

To highlight variables automatically, there must be possibility to find variable with regular expression - syntax must allow recognize variable in the code. I am afraid it is impossible in AHK sad smiley

Options: Reply | Quote | Up ^


Goto Page: 1 2 Next





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR