Question

I'm in the middle of creating a custom lexer. Then I found StyledTextCtrl.StartStyling() is the method to use to start applying style to text, but I have no idea what the mask is. I typed StartStyling.__doc__ and got this

StyledTextCtrl.StartStyling(self, int pos, int mask)
Set the current styling position to pos and the styling mask to mask.
The styling mask can be used to protect some bits in each styling byte from modification.

How does the styling mask applied here and how to choose what mask number should we give?

Was it helpful?

Solution

This page explains most of it:

http://www.yellowbrain.com/stc/styling.html

The integer parameter pos sets the position where you'd like to begin styling operations. The integer parameter mask indicates which bits of the style bytes to modify.

From the Scintilla documentation: The mask allows styling to occur over several passes, with, for example, basic styling done on an initial pass to ensure that the text of the code is seen quickly and correctly, and then a second slower pass, detecting syntax errors and using indicators to show where these are. For example, with the standard settings of 5 style bits and 3 indicator bits, you would use a mask value of 31 (0x1f) if you were setting text styles and did not want to change the indicators.

You probably want your mask to be 0x1f (low 5 bits), this is by convention. The low 5 bits are used for styles (up to 32 different styles) while the high 3 bits are used for indicators.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top