termbox2
termbox2 copied to clipboard
add `tb_get_cell`
Useful or bloat?
There's currently no way to fetch cells from the front buffer. This does close that gap. Otherwise this is a safer version of tb_cell_buffer
which returns a pointer to the entire back buffer.
I tested change and it works as supposed to.
A use case for this would be:
- Suppose we are writing a function that draws a dialog on top of the screen. We want to write a character for, say, left border, “│” =
0x2502
at position (x, y). - At position (x-1, y) there is a wide character, say “索” =
0x7d22
. - After drawing the character “│”, it is still covered by “索”.
The workaround would be to use this function to retrieve the character at position (x-1, y), test it with wcwidth
(3) and if it returns value greater than one, write, say, “ ” = 0x20 at that position, then write “│” at (x, y).
If the concern is about the safety, the function could return a copy of the (wide) character at position (x, y), which would help this use case while still not allowing direct access to the buffer.