0

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?

絢瀬絵里
  • 1,013
  • 2
  • 14
  • 27
  • Could you give a bit more background information? Some code or some information on why you want to use this method would help. – acattle May 13 '12 at 10:14
  • Background information added. – 絢瀬絵里 May 13 '12 at 10:29
  • I honestly spent a few hours today trying to find some tutorial, ANY tutorial to help me understand how to use StyledTextCtrl and I can't find any! Can you explain a bit more about what you plan to do? MAybe I can help you find an alternative? – acattle May 13 '12 at 14:25
  • Yes it is hard to find an example or tutorial. I myself have a lot of trouble doing this. The closest tutorial on how to use StyledTextCtrl would be the wxPython 2.8 Application Development Cookbok. But that itself didn't explain how the mask in StartStyling works and how do we determine what integer number should we use as the mask. – 絢瀬絵里 May 13 '12 at 15:13

1 Answers1

2

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.

FogleBird
  • 74,300
  • 25
  • 125
  • 131