Margin style
In the Scintilla editor you can set 5 margins, numbered 0 to 4. left to right.
Each margin has its own properties, like type, width etc...
When clicked each margin emits the margin-click signal, you can assign it a signal
handler to, for example, select the whole line or to implement folding.
Using a margin number outside the valid range has no effect.
By default, margin 0 is set to display line numbers, but is given a width of 0,
so it is hidden. Margin 1 is set to display non-folding symbols and is
given a width of 16 pixels, so it is visible. Margin 2 is set to display the
folding symbols, but is given a width of 0, so it is hidden.
Of course, you can set the margins to be whatever you wish.
-
gtkscintilla.Scintilla.set_margin(margin_id[, marginspec = None | **kwargs])
This sets the margin settings, with margin_id you specify the margin numbered 0
to 4, you can set the margin properties using a gtkscintilla.style.MarginStyle
instance or using keyword arguments.
Available properties (keyword arguments):
Parameters: |
- type – You can use the predefined constants
SC_MARGIN_SYMBOL (0) and SC_MARGIN_NUMBER (1) to set a margin
as either a line number or a symbol margin.
A margin with application defined text may use SC_MARGIN_TEXT (4)
or SC_MARGIN_RTEXT (5) to right justify the text.
By convention, margin 0 is used for line numbers and the next
two are used for symbols. You can also use the constants
SC_MARGIN_BACK (2) and SC_MARGIN_FORE (3) for symbol
margins that set their background colour to match the default
background and foreground colours.
- width – These routines set and get the width of a margin in pixels.
A margin with zero width is invisible.
By default, Scintilla sets margin 1 for symbols with a
width of 16 pixels, so this is a reasonable guess
if you are not sure what would be appropriate.
Line number margins widths should take into account
the number of lines in the document and the line number style.
- sensitive – Each of the five margins can be set sensitive or insensitive
to mouse clicks. A click in a sensitive margin
sends a margin-click notification to the container.
Margins that are not sensitive act as selection margins
which make it easy to select ranges of lines.
By default, all margins are insensitive.
- mask – For a symbol margin you can set to display a selection of symbols,
and to hide others, like a mask.
To set a non-folding margin use ~SC_MASK_FOLDERS.
to set a folding margin use SC_MASK_FOLDERS (This is the default set by Scintilla).
~SC_MASK_FOLDERS is 0x1FFFFFF in hexadecimal or
33554431 decimal.
Of course, you may need to display all 32 symbols in a margin,
in which case use -1.
|
-
gtkscintilla.Scintilla.get_margin(margin_id)
- This method returns an instance of gtkscintilla.style.MarginStyle that contains
all the properties of the margin identified by margin_id as attributes.
-
class gtkscintilla.style.MarginStyle(**kwargs)
This class has type, width, sensitive, mask attributes.
The constructor is like gtkscintilla.Scintilla.set_margin() without
the margin_id parameter
You can retrieve infos about the attributes simply ... retrieving it:
>>> a = MarginStyle(width=16)
>>> a.width
16