method to fill the background color in document window

Plugins for SynWrite and CudaText...
SamC
Posts: 208
Joined: 12.08.2023 00:49

method to fill the background color in document window

Post by SamC »

Hello,
I want to write a small plugin to change the background color of certain lines of the markdown file for focus view.(like the bookmark,can change the backgroud color of one entire line)
Please give some advise about which api should be used?

BTW, what dose the line in box in the picture below mean?
2024-01-16_09-29-21.png
2024-01-16_09-29-21.png (690 Bytes) Viewed 4930 times
Thanks!
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: method to fill the background color in document window

Post by main Alexey »

- plugin Focus Mode exists
- colored line means the https://wiki.freepascal.org/CudaText#Line_states
- API 1: ed.set_prop() with id PROP_MARKED_RANGE: 2-tuple with line indexes of "marked range"; (-1, -1) if range not set.
- API 2: ed.attr()
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: method to fill the background color in document window

Post by main Alexey »

- API 3 (AFAIR, what the Focus Mode plugin uses): ed.dim()
SamC
Posts: 208
Joined: 12.08.2023 00:49

Re: method to fill the background color in document window

Post by SamC »

Thanks, ed.set_prop() seems more simple to use,the default color is light blue,may I change it to light yellow?
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: method to fill the background color in document window

Post by main Alexey »

It is ui-theme color:
editor, marked range BG
SamC
Posts: 208
Joined: 12.08.2023 00:49

Re: method to fill the background color in document window

Post by SamC »

Got it, thanks~
SamC
Posts: 208
Joined: 12.08.2023 00:49

Re: method to fill the background color in document window

Post by SamC »

Hello,
For the background color,I find in the code block of markdown,the background color will lose in empty row,but when not in the code block,the empty row will also be filled. How to also fill the empty row in code block by PROP_MARKED_RANGE?
Thanks!
what the editor looks like by:ed.set_prop(PROP_MARKED_RANGE,(0,9))
Snipaste_2024-01-23_09-38-53.png
Snipaste_2024-01-23_09-38-53.png (9.67 KiB) Viewed 4897 times
what the editor looks like by:ed.set_prop(PROP_MARKED_RANGE,(10,21))
Snipaste_2024-01-23_09-41-03.png
Snipaste_2024-01-23_09-41-03.png (11.33 KiB) Viewed 4897 times
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: method to fill the background color in document window

Post by main Alexey »

seems I fixed this now. here is fixed beta for windows/linux, pls test:
https://github.com/Alexey-T/CudaText/issues/5377
SamC
Posts: 208
Joined: 12.08.2023 00:49

Re: method to fill the background color in document window

Post by SamC »

I over written the /data and cuda main program.
The marked range is with no more empty rows. But it seems the original background color in codeblock is disappeared now.
Also, the lexer styles mapping I set seems be reset. Where did it be stored in file?
Snipaste_2024-01-23_16-04-15.png
main Alexey
Posts: 2265
Joined: 25.08.2021 18:15

Re: method to fill the background color in document window

Post by main Alexey »

ops, I made regression in Markdown lexer.
download fixed lexer
https://raw.githubusercontent.com/Alexe ... rkdown.lcf
and put file to 'data/lexlib'.
Post Reply