Module textredux.core.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. 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 API.
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).
A simple example:
local reduxindicator = textredux.core.indicator reduxindicator.RED_BOX = {style = c.INDIC_BOX, fore = '#ff0000'}
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 textredux.core.buffer.
local text = 'Text for a red box indicator\n\n' buffer:add_text(text) reduxindicator.RED_BOX:apply(0, #text) buffer:add_text(text, nil, nil, reduxindicator.RED_BOX)
Please also see the file examples/buffer_indicators.lua
.