add termpty_cell_get()

This commit is contained in:
Boris Faure 2018-10-13 18:07:27 +02:00
parent 05ee717fc0
commit 258cf5c173
2 changed files with 25 additions and 0 deletions

View File

@ -1209,6 +1209,30 @@ termpty_cellrow_get(Termpty *ty, int y_requested, ssize_t *wret)
return _termpty_cellrow_from_beacon_get(ty, y_requested, wret);
}
/* @requested_y unit is in visual lines on the screen */
Termcell *
termpty_cell_get(Termpty *ty, int y_requested, int x_requested)
{
ssize_t wret = 0;
Termcell *cells;
if (y_requested >= 0)
{
if (y_requested >= ty->h)
return NULL;
if (x_requested >= ty->w)
return NULL;
return &(TERMPTY_SCREEN(ty, 0, y_requested)) + x_requested;
}
if (!ty->back)
return NULL;
cells = _termpty_cellrow_from_beacon_get(ty, y_requested, &wret);
if (!cells || x_requested >= wret)
return NULL;
return cells + x_requested;
}
void
termpty_write(Termpty *ty, const char *input, int len)
{

View File

@ -253,6 +253,7 @@ void termpty_backlog_lock(void);
void termpty_backlog_unlock(void);
Termcell *termpty_cellrow_get(Termpty *ty, int y, ssize_t *wret);
Termcell * termpty_cell_get(Termpty *ty, int y_requested, int x_requested);
ssize_t termpty_row_length(Termpty *ty, int y);
void termpty_write(Termpty *ty, const char *input, int len);
void termpty_resize(Termpty *ty, int new_w, int new_h);