Module _M.textui.indicator
The indicator module provides support for indicators in your buffers.
Indicators lets you visually mark a certain text range using various styles and colors, and using the event mechanism you can also receive events whenever the user clicks the marked text.
The indicator definition
An indicator is defined using a simple table with the properties listed below. For the most part, these properties maps directly to fields in the buffer class. The list below will give short descriptions and refer to the corresponding field in the buffer class where applicable.
style
: The style of the indicator. Seeindic_style
.alpha
: Alpha transparency value from 0 to 255 (or 256 for no alpha), used for fill colors of rectangles . Seeindic_alpha
.outline_alpha
: Alpha transparency value from 0 to 255 (or 256 for no alpha), used for outline colors of rectangles . Seeindic_outline_alpha
.fore
: The foreground color of the indicator. The color should be specified in the'#rrggbb'
notation.under
: Whether an indicator is drawn under text or over (default). Drawing under text works only when two phase drawing is enabled for the buffer (the default).
Using indicators
Start with defining your indicators using the format described above. You can then either apply them against a range of text using apply, or pass them to one of the text insertion functions in _M.textui.buffer. If you need to get the defined indicator number for an indicator, you can retrieve it using number_for. Please note that indicator numbers are not necessarily stable between buffer switches, so problems may arise if you hold on to an indicator number.
Please see the example buffer_indicators.lua for some practical usage.
Functions
define_indicators () | Defines the currently used custom indicators for the current buffer. |
number_for (indicator) | Retrieves the indicator number used in the current buffer for the indicator. |
apply (indicator, position, length) | Applies the given indicator for the text range specified in the current buffer. |
Functions
- define_indicators ()
- Defines the currently used custom indicators for the current buffer. This must be called whenever a buffer with custom indicators is switched to. This is automatically done by the _M.textui.buffer class, and thus not something you typically have to worry about.
- number_for (indicator)
-
Retrieves the indicator number used in the current buffer for the indicator.
Parameters:
indicator
: The indicator to retrieve the number for
- apply (indicator, position, length)
-
Applies the given indicator for the text range specified in the current
buffer.
Parameters:
indicator
: The indicator to applyposition
: The start positionlength
: The length of the range to fill