Margins are the sidebars on the side of your editor. When working with margins, you should absolutely remember the following stuff:
You don’t have to create margins – as you would normally do to make objects. They are just there, but invisible by default. How many margins exist? By default you’ve got five. But since QScintilla 2.10 you can change it simply with the function
setMargins(. The function nr_of_margins) margins()returns the current amount.
Margin identifier:0, 1, 2, ..
Each margin is identified by a unique number. Counting starts from zero.
Margin visibility:width ≠ 0
Normally you’ve got 5 margins (unless you’ve called
setMargins() – but all are invisible to start with. If you want to make one or more visible, just give them a width > 0. nr_of_margins)
Margin type:NumberMargin, SymbolMargin, …
Not all margins are equal. Several types exist.
Take a look at the following example. The figure shows an editor with four margins. Margin 0 is a line number margin, margin 1 and 3 are symbol margins and margin 2 is for short texts:
Four margin types exist:
- Line number margin
I think it’s obvious what this one displays. Please keep in mind that the margin doesn’t resize automatically when the line number grows. So you’ve got to resize it manually if needed.
- Symbol margin
This margin can display custom symbols.
- Folding margin
The folding margin displays the folding symbols that are used for folding (-) and unfolding (+) code that has been styled for this.
- Text margin
The text margin displays text (duh..). The font size, family, color, .. are all selectable.
Later we’ll dive into each type, one-by-one.
This function sets the width of the specified margin in pixels.
A string (for example “0000”) is used to calculate the needed margin width, based on its font style.
Please remember that there is NO function
To change the margin foreground (text) color to blue, fill in the following parameter value:
In older versions, the function name has no
This function applies to one single margin. Unfortunately, it won’t work always. Take the symbol margin for example. If you’ve defined the margin as a simple