Re: Colorizing braces using indicators

"'seasoned_geek' via scintilla-interest" <[email protected]>
Newsgroups gmane.comp.lib.scintilla.devel
Message-ID <[email protected]>

On Tuesday, March 26, 2024 at 10:16:52 PM UTC [email protected] wrote:


Actually, I wrote my code first and since I knew you could get the line 
state from within the lexer, I figured there was a way to set an indicator 
which is how I discovered IndicatorFill(). When it wasn't working, I did a 
Google search for IndicatorFill and that's how I discovered it was being 
used in the Python lexer. The documentation isn't very clear what an 
indicator value is but near as I can tell, it's just some user-defined 
value so you can put whatever you want. I could've just used a value of 0 
but I figured maybe I do want to see which value it is 
using SCI_INDICATORVALUEAT.


No, no, no. (If I'm wrong here Neil, feel free to slap me)
Please look closely at the prototype for this function you probably 
shouldn't be using. 

[image: indicatorfill-001.png]

indicator is an int in the range of 0-43, some of which have predefined 
purposes.  https://www.scintilla.org/ScintillaDoc.html#Indicators

"value" is what I'm telling you to use 0 for. The last parameter.

[image: indicatorfill-010.png]
One of these numbers needs to be what you have for the last parameter 
"value." After you read the rest of this you will probably decide you 
shouldn't be using that piece of code. Here's how I load the indicator 
values for a given theme.

[image: indicatorfill-011.png]

Note that each indicator has a color, a visual effect, and an alpha.

[image: indicatorfill-013.png]

Those are the indicators I define based on this paragraph of the 
documentation.

[image: indicatorfill-014.png]
 Memorize that paragraph. I based all of my indicators off 
INDICATOR_CONTAINER because I didn't want to turn headlong into something a 
lexer was already using internally. There was a reason I started 4 off too, 
I just don't remember what it was. Users get to select the indicator color, 
Alpha because for some reason the alpha color channel is not use . . . if I 
remember reading correctly and they can choose the visual effect.

[image: indicatorfill-012.png]

You are using the wrong tool

*You wish to change the color of an element*

While I'm sure with a great amount of pain you could make an indicator do 
what you want, the only way I can think of for you to do it is with a 
Visual Effect of INDIC_TEXTFORE   (17) You would need to burn one indicator 
value for each { depth you wanted to color. You will also be fighting the 
match/non-match indicators/elements. I humbly suggest you choose element 
numbers not currently assigned.

[image: indicatorfill-015.png]
You can have one for each depth. I do not know what the maximum element 
number is, but 18-39 aren't used by default.
There should already be element parsing logic you could steal and repurpose 

SC_ELEMENT_BRACKET_DEPTH_1    21
SC_ELEMENT_BRACKET_DEPTH_2    22
SC_ELEMENT_BRACKET_DEPTH_3    23
SC_ELEMENT_BRACKET_DEPTH_4    24

etc.

As long as your theme doesn't have a garish clash with match/non-match 
indicator backgrounds you should be fine.

That piece of code you chose to steal is not good. It is not dealing with 
alpha.

Really really tired now, going to bed.

*Never steal code you didn't write.* Translated to modern times     Never 
cut & paste from stack overflow (or any stack property)

-- 
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scintilla-interest/8e9ab35d-a493-405f-a2af-712e9acc4826n%40googlegroups.com.
indicatorfill-014.png (image/png, 39.4 KB) - not displayed
indicatorfill-010.png (image/png, 247 KB) - not displayed
indicatorfill-013.png (image/png, 14.3 KB) - not displayed
indicatorfill-015.png (image/png, 178.9 KB) - not displayed
indicatorfill-011.png (image/png, 91.8 KB) - not displayed
indicatorfill-012.png (image/png, 22.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.