diff --git a/src/bin/termpty.c b/src/bin/termpty.c index 74c8caee..6d93bd3d 100644 --- a/src/bin/termpty.c +++ b/src/bin/termpty.c @@ -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) { diff --git a/src/bin/termpty.h b/src/bin/termpty.h index 638c0531..7934dd76 100644 --- a/src/bin/termpty.h +++ b/src/bin/termpty.h @@ -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);