Colors
Color Objects
Colors in lib-st are tables of color values.
<tt>-- red, barely visible local color = { ["r"] = 1.0, ["g"] = 0.0, ["b"] = 0.0, ["a"] = 0.2, };</tt>
In most places where you would specify a color object, you can instead specify a function that will return a color object. if this function needs arguments, they can be supplied wrapped in a table ( an array of args ) and assigned to colorargs.
Example
For example, if you wanted to define a column that had text with a color based on which column left-to-right it was, then you would define your columns something like this:
<tt>ColumnColor = function(index) return { ["r"] = index/10, -- must be a number from 0 to 1. ["g"] = index/10, ["b"] = index/10, ["a"] = 1.0, }, -- will go from black to white, left to right. end; cols = { { ["name"] = "Column 1", ["width"] = 50, ["color"] = ColumnColor, ["colorargs"] = {1,}, }, -- [1] { ["name"] = "Column 2", ["width"] = 50, ["color"] = ColumnColor, ["colorargs"] = {2,}, }, -- [2] };</tt>
You would then use cols when constructing your scrolling table.
This technique can be used to color rows or even an individual cell's text. Row and cell coloring is controlled in the table data... table... -- yay, lua...
The library is really great! However, these docs are sadly incomplete and/or outdated. Search the library source code for:
Around that area, you will see what args it passes to your custom color function. Currently, the code is passing the following (but it may change in the future, so always check the source code of the library):
However, IF you provide a non-nil "colorargs" value in your "cols" table, your function will receive the "colorargs" table's values as arguments, and ONLY those arguments. And it won't receive all of the ones I listed above.
So your choice is one or the other... I prefer not providing "colorargs", and thereby getting all of the nice data I listed above.