The main problem is knowing:
* The correct *cell* (to be able to render the *content* when erasing
the old cursor)
* Whether the cursor has moved (to determine whether to stop the
rendering loop or not)
* Where on the *screen* the cursor is/was (since the terminal may be
partly scrolled back)
This patch stores three static variables:
* last_cursor is used to compare against current cursor to see if the
cursor has moved or not
* last_cursor_on_screen is the actual screen coordinates the cursor
was rendered at (typically the same as last_cursor, but may be
offset by the view)
* last_cursor_cell is a pointer to the cell to render
The default is to reverse the foreground/background colors in the cell
with the cursor.
But, if the user configures a specific set of cursor colors, those
will always be used, regardless of other cell attributes (dim, reverse
etc).
The cursor color is specified as two color values, 'text' and
'cursor'.
The block cursor uses the 'cursor' color as background, and the 'text'
color for the glyph.
All other cursor styles uses the 'cursor' color for the cursor, but
uses the cell's foreground color for the glyph (meaning,
dim/reverse/etc applies).
I.e. it issues a \E[2 q regardless of what we've configured the
terminfo Se entry to.
So, make \E[2 q mean "the user configured cursor style" (which
defaults to 'block').
According to the specs, \E[0 q means a blinking block cursor. However,
since it also states that \E[1 q *also* is a blinking block cursor,
and that it is the default, *and* given that fact that parameter-less
CSIs typically means "reset", let's make it mean "reset to the user
configured cursor style".
Use our own escape sequence for the 'flash' terminfo entry.
Implemented by arming a timer FD and setting a boolean that indicates
we're currently "flashing".
The renderer draws a semi-transparent yellowish layer over the entire
window when "flashing" is active.
22;0|1|2t pushes the current window title/icon to the stack, while 23
pops it.
The second parameter, 0|1|2 has the following meaning:
0 - push/pop icon+title
1 - push/pop icon
2 - push/pop title
The 16 first entries in the 256-color array are the regular and bright
colors. However, since they can be changed (eventually) at runtime, we
can't statically initialize the 256-color array.
Instead, pick the regular+bright colors directly from the terminal
struct. I.e. the first 16 entries of the 256-color array are now
unused.