diff --git a/include/vterm.h b/include/vterm.h index bacbecf3..ad7f8b1b 100644 --- a/include/vterm.h +++ b/include/vterm.h @@ -214,6 +214,8 @@ typedef struct { void vterm_screen_get_cell(VTermScreen *screen, VTermPos pos, VTermScreenCell *cell); +int vterm_screen_is_eol(VTermScreen *screen, VTermPos pos); + void vterm_input_push_char(VTerm *vt, VTermModifier state, uint32_t c); void vterm_input_push_key(VTerm *vt, VTermModifier state, VTermKey key); diff --git a/src/screen.c b/src/screen.c index f1e54351..d79d2478 100644 --- a/src/screen.c +++ b/src/screen.c @@ -590,6 +590,18 @@ void vterm_screen_get_cell(VTermScreen *screen, VTermPos pos, VTermScreenCell *c cell->width = 1; } +int vterm_screen_is_eol(VTermScreen *screen, VTermPos pos) +{ + /* This cell is EOL if this and every cell to the right is black */ + for(; pos.col < screen->cols; pos.col++) { + ScreenCell *cell = getcell(screen, pos.row, pos.col); + if(cell->chars[0] != 0) + return 0; + } + + return 1; +} + VTermScreen *vterm_obtain_screen(VTerm *vt) { if(vt->screen) diff --git a/t/40screen_ascii.test b/t/40screen_ascii.test index b6756eb8..c2f48fab 100644 --- a/t/40screen_ascii.test +++ b/t/40screen_ascii.test @@ -13,6 +13,9 @@ PUSH "ABC" ?screen_cell 0,1 = {0x42} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0) ?screen_cell 0,2 = {0x43} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0) ?screen_row 0 = "ABC" + ?screen_eol 0,0 = 0 + ?screen_eol 0,2 = 0 + ?screen_eol 0,3 = 1 PUSH "\e[H" movecursor 0,0 ?screen_chars 0,0,1,80 = 0x41,0x42,0x43 diff --git a/t/harness.c b/t/harness.c index ae9a2107..74922777 100644 --- a/t/harness.c +++ b/t/harness.c @@ -714,6 +714,17 @@ int main(int argc, char **argv) printf("fg=rgb(%d,%d,%d) ", cell.fg.red, cell.fg.green, cell.fg.blue); printf("bg=rgb(%d,%d,%d)\n", cell.bg.red, cell.bg.green, cell.bg.blue); } + else if(strstartswith(line, "?screen_eol ")) { + char *linep = line + 12; + while(linep[0] == ' ') + linep++; + VTermPos pos; + if(sscanf(linep, "%d,%d\n", &pos.row, &pos.col) < 2) { + printf("! screen_eol unrecognised input\n"); + goto abort_line; + } + printf("%d\n", vterm_screen_is_eol(screen, pos)); + } else printf("?\n");