Request: Recognize highlighter with RegEx

Make a request or discuss new features.
Post Reply
User avatar
micha_he
Posts: 570
Joined: 24 Jul 2011 12:16
Location: Helmstedt, NDS, Germany

Request: Recognize highlighter with RegEx

Post by micha_he »

My old feuture-request is missing !? Try it again here...

Instead of recognize the highlighter via the file-extension only, recognize it via the full filename and a RegEx-string.

With this change you could assign a separate highlighter to files like:

Rules (name begin with fixed chars, without extension)
Rules1.txt (name begin with fixed chars, extension is txt)
User avatar
Rickard Johansson
Site Admin
Posts: 6628
Joined: 19 Jul 2006 14:29

Re: Request: Recognize highlighter with RegEx

Post by Rickard Johansson »

I'm not fond of the idea... Would it work if I add an option to save the highlighter used with the file?

Ex.
Add "Save highlighter" to the "Save status for last open files" section in options.

That way you can open the file and select a highlighter. That highlighter will now always be used with that file.
User avatar
micha_he
Posts: 570
Joined: 24 Jul 2011 12:16
Location: Helmstedt, NDS, Germany

Re: Request: Recognize highlighter with RegEx

Post by micha_he »

The alternative you mentioned sounds good, but it only works if the file is always in the same location.
My the rule-files are some with identical/similar filenames, but in various locations. Then your implementation wouldn't work, or?
User avatar
Rickard Johansson
Site Admin
Posts: 6628
Joined: 19 Jul 2006 14:29

Re: Request: Recognize highlighter with RegEx

Post by Rickard Johansson »

You will have to select the highlighter manually for every file. But the next time you open a file - it will open using the saved highlighter.
User avatar
micha_he
Posts: 570
Joined: 24 Jul 2011 12:16
Location: Helmstedt, NDS, Germany

Re: Request: Recognize highlighter with RegEx

Post by micha_he »

For my case not practical :wink:

Was just an idea, to change extension to RegEx-filename. When there is no general interest, leave it as it is.
User avatar
Rickard Johansson
Site Admin
Posts: 6628
Joined: 19 Jul 2006 14:29

Re: Request: Recognize highlighter with RegEx

Post by Rickard Johansson »

I'll add the option anyway. It can be useful with files without extensions, or text files that contain code (and you want it to open with a highlighter).

BTW. I think you can create a script to change the highlighter when you open a file. It needs to be run when you open a file and contain something like:

Code: Select all

String s = Document.FileName;
string foundStr;
int n = ScriptUtils.RegExPos("<regex>", s, foundStr);
if (n > 0) {
   MainApp.SetHighlighter('C++');
};
(I haven't actually tried it though...)
Post Reply