termbox2 icon indicating copy to clipboard operation
termbox2 copied to clipboard

add `tb_get_cell`

Open adsr opened this issue 10 months ago • 2 comments

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.

adsr avatar Mar 31 '24 02:03 adsr

I tested change and it works as supposed to.

ledinscak avatar Apr 14 '24 18:04 ledinscak

A use case for this would be:

  1. 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).
  2. At position (x-1, y) there is a wide character, say “索” = 0x7d22.
  3. 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.

Strahinja avatar Jul 14 '24 11:07 Strahinja