Page 1 of 2

How to edit a lexer

Posted: 11.09.2024 11:42
by sl23
I am using the Rainmeter lexer for INI files, but am wanting to change how it shows a Section. I really don't know anything about adjusting lexers though.
EG, currently, the Rainmeter lexer shows a Section in one of two ways.
1. A section named like this: [MySectionName] shows correctly, nicely highlighted easy to see when scanning through a file.
2. But, a section name like this: [My Section Name] or with any symbols in like this: [My-Section.Name] causes it to display as normal text with highlighted brackets and not in bold.

The lexer I used to use for INI files works better and always shows the Section name bold and highlighted.
Is there any way to adjust the Rainmeter lexer without affecting the rest of the highlighting options/settings?

Thanks ;)

Re: How to edit a lexer

Posted: 11.09.2024 12:26
by main Alexey
1. I fixed the Rainmeter lexer, it's updated in addons-manager.
changed regex for sections to simple: ^\[.+\]$

2. how to edit --
Lexers modification and creation
in the wiki https://wiki.freepascal.org/CudaText

Re: How to edit a lexer

Posted: 11.09.2024 12:38
by sl23
Oh that's great thanks for that! :)

Re: How to edit a lexer

Posted: 16.09.2024 12:35
by sl23
Hi Alexey, this has been working perfectly, until today I noticed that single words no longer show in bold or highlighted as they originally did. Sort of the opposite of what I was getting in the first post.
Would you be able to adjust to fix that please. :)

EDIT: No worries, there was a space after the closed square bracket! Sorry. :oops:

Re: How to edit a lexer

Posted: 17.09.2024 05:50
by main Alexey
you are right, I fixed this regex again. to allow trailing spaces. updated the lexer.

Re: How to edit a lexer

Posted: 17.09.2024 21:08
by sl23
Ah ok thanks for the fix! ;)

Re: How to edit a lexer

Posted: 09.05.2025 22:15
by sl23
Hi Alexey,
I just updated the plugins using the built in updater and now the Rainmeter lexer has reverted back to the problem mentioned in the OP, I then copied the lexers back as I had changed the colours for syntax highlighting, but it didn't fix the issue. What is the cause and can it be solved once and for all or will it do this every time I update the plugins?

Thank you for your help.

EDIT: It's ok, I reinstalled using the Addons Manager and it's fixed it. :D

Re: How to edit a lexer

Posted: 10.05.2025 12:37
by sl23
Actually, there is also one enhancement that would help:
Similar to the Section names in the OP, keys do not keep their highlighting if they have spaces and/or symbols.
So this works ok: MouseOverAction=....
But this does not: Mouse Over.Action=....
The reason for it is that INI files are useful for note taking. I use INI for everything where notes are required. Not comments btw, but separate files for note taking. So having spaces/symbols is often helpful here.

Here's an example of note taking:
Minimum= NVIDIA GeForce GT 1050 4GB / AMD Radeon RX 550 4GB
Recommended= NVIDIA GeForce GTX 1660 6GB / AMD Radeon RX 5500 8GB (with “Force maximum clocks” enabled) / Adreno
Optimal= NVIDIA Geforce RTX 3060 12GB / AMD Radeon RX 6700 10GB (with “Force maximum clocks” enabled)
Integrated Graphics (Minimum)= Intel UHD Graphics 730 / AMD Radeon Vega 3
Integrated Graphics (Recommended)= Intel Iris Xe Graphics / AMD Radeon 680M / Qualcomm Adreno 740 / ARM Mali G720
The Keys of the last two lines aren't coloured the same as the first three lines of Keys.

FR: Please could you add that to the Rainmeter lexer.
Thank you. :)

Re: How to edit a lexer

Posted: 10.05.2025 20:12
by main Alexey
I just added this to the Rainmeter lexer. lexer is updated in addons-manager.

Re: How to edit a lexer

Posted: 10.05.2025 20:28
by sl23
Ah your the best! Thank you :)