Mercurial > vim
diff src/libvterm/t/harness.c @ 30880:82336c3b679d v9.0.0774
patch 9.0.0774: the libvterm code is outdated
Commit: https://github.com/vim/vim/commit/6a12d26f3404e45ce25cf9152857e355b28f392a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 16 19:26:52 2022 +0100
patch 9.0.0774: the libvterm code is outdated
Problem: The libvterm code is outdated.
Solution: Include libvterm changes from revision 802 to 817. Revert some
changes made for C89.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 16 Oct 2022 20:30:07 +0200 |
parents | 2d2758ffd959 |
children | ac9464a32606 |
line wrap: on
line diff
--- a/src/libvterm/t/harness.c +++ b/src/libvterm/t/harness.c @@ -1,6 +1,7 @@ #include "vterm.h" #include "../src/vterm_internal.h" // We pull in some internal bits too +#include <assert.h> #include <stdio.h> #include <string.h> @@ -409,6 +410,8 @@ static struct { int conceal; int strike; int font; + int small; + int baseline; VTermColor foreground; VTermColor background; } state_pen; @@ -439,6 +442,12 @@ static int state_setpenattr(VTermAttr at case VTERM_ATTR_FONT: state_pen.font = val->number; break; + case VTERM_ATTR_SMALL: + state_pen.small = val->boolean; + break; + case VTERM_ATTR_BASELINE: + state_pen.baseline = val->number; + break; case VTERM_ATTR_FOREGROUND: state_pen.foreground = val->color; break; @@ -458,6 +467,15 @@ static int state_setlineinfo(int row UNU return 1; } +static int want_state_scrollback = 0; +static int state_sb_clear(void *user UNUSED) { + if(!want_state_scrollback) + return 1; + + printf("sb_clear\n"); + return 0; +} + VTermStateCallbacks state_cbs = { state_putglyph, // putglyph movecursor, // movecursor @@ -470,6 +488,7 @@ VTermStateCallbacks state_cbs = { NULL, // bell NULL, // resize state_setlineinfo, // setlineinfo + state_sb_clear, // sb_clear }; static int selection_set(VTermSelectionMask mask, VTermStringFragment frag, void *user UNUSED) @@ -592,6 +611,15 @@ static int screen_sb_popline(int cols, V return 1; } +static int screen_sb_clear(void *user UNUSED) +{ + if(!want_screen_scrollback) + return 1; + + printf("sb_clear\n"); + return 0; +} + VTermScreenCallbacks screen_cbs = { screen_damage, // damage moverect, // moverect @@ -600,7 +628,8 @@ VTermScreenCallbacks screen_cbs = { NULL, // bell NULL, // resize screen_sb_pushline, // sb_pushline - screen_sb_popline // sb_popline + screen_sb_popline, // sb_popline + screen_sb_clear, // sb_clear }; int main(int argc UNUSED, char **argv UNUSED) @@ -629,12 +658,14 @@ int main(int argc UNUSED, char **argv UN } else if(streq(line, "WANTPARSER")) { + assert(vt); vterm_parser_set_callbacks(vt, &parser_cbs, NULL); } else if(strstartswith(line, "WANTSTATE") && (line[9] == '\0' || line[9] == ' ')) { int i = 9; int sense = 1; + assert(vt); if(!state) { state = vterm_obtain_state(vt); vterm_state_set_callbacks(state, &state_cbs, NULL); @@ -671,6 +702,9 @@ int main(int argc UNUSED, char **argv UN case 'f': vterm_state_set_unrecognised_fallbacks(state, sense ? &fallbacks : NULL, NULL); break; + case 'b': + want_state_scrollback = sense; + break; default: fprintf(stderr, "Unrecognised WANTSTATE flag '%c'\n", line[i]); } @@ -679,6 +713,7 @@ int main(int argc UNUSED, char **argv UN else if(strstartswith(line, "WANTSCREEN") && (line[10] == '\0' || line[10] == ' ')) { int i = 10; int sense = 1; + assert(vt); if(!screen) screen = vterm_obtain_screen(vt); vterm_screen_set_callbacks(screen, &screen_cbs, NULL); @@ -712,6 +747,9 @@ int main(int argc UNUSED, char **argv UN case 'b': want_screen_scrollback = sense; break; + case 'r': + vterm_screen_enable_reflow(screen, sense); + break; default: fprintf(stderr, "Unrecognised WANTSCREEN flag '%c'\n", line[i]); } @@ -743,6 +781,8 @@ int main(int argc UNUSED, char **argv UN else if(strstartswith(line, "PUSH ")) { char *bytes = line + 5; size_t len = inplace_hex2bytes(bytes); + assert(len); + size_t written = vterm_input_write(vt, bytes, len); if(written < len) fprintf(stderr, "! short write\n"); @@ -759,6 +799,7 @@ int main(int argc UNUSED, char **argv UN else if(strstartswith(line, "ENCIN ")) { char *bytes = line + 6; size_t len = inplace_hex2bytes(bytes); + assert(len); uint32_t cp[1024]; int cpi = 0; @@ -814,6 +855,7 @@ int main(int argc UNUSED, char **argv UN } else if(strstartswith(line, "FOCUS ")) { + assert(state); char *linep = line + 6; if(streq(linep, "IN")) vterm_state_focus_in(state); @@ -869,6 +911,8 @@ int main(int argc UNUSED, char **argv UN } frag.len = inplace_hex2bytes(linep); frag.str = linep; + assert(frag.len); + linep += frag.len * 2; while(linep[0] == ' ') linep++; @@ -879,6 +923,7 @@ int main(int argc UNUSED, char **argv UN } else if(strstartswith(line, "DAMAGEMERGE ")) { + assert(screen); char *linep = line + 12; while(linep[0] == ' ') linep++; @@ -893,11 +938,13 @@ int main(int argc UNUSED, char **argv UN } else if(strstartswith(line, "DAMAGEFLUSH")) { + assert(screen); vterm_screen_flush_damage(screen); } else if(line[0] == '?') { if(streq(line, "?cursor")) { + assert(state); VTermPos pos; vterm_state_get_cursorpos(state, &pos); if(pos.row != state_pos.row) @@ -910,6 +957,7 @@ int main(int argc UNUSED, char **argv UN printf("%d,%d\n", state_pos.row, state_pos.col); } else if(strstartswith(line, "?pen ")) { + assert(state); VTermValue val; char *linep = line + 5; while(linep[0] == ' ') @@ -965,6 +1013,24 @@ int main(int argc UNUSED, char **argv UN else printf("%d\n", state_pen.font); } + else if(streq(linep, "small")) { + vterm_state_get_penattr(state, VTERM_ATTR_SMALL, &val); + if(val.boolean != state_pen.small) + printf("! pen small mismatch; state=%s, event=%s\n", + BOOLSTR(val.boolean), BOOLSTR(state_pen.small)); + else + printf("%s\n", BOOLSTR(state_pen.small)); + } + else if(streq(linep, "baseline")) { + vterm_state_get_penattr(state, VTERM_ATTR_BASELINE, &val); + if(val.number != state_pen.baseline) + printf("! pen baseline mismatch: state=%d, event=%d\n", + val.number, state_pen.baseline); + else + printf("%s\n", state_pen.baseline == VTERM_BASELINE_RAISE ? "raise" + : state_pen.baseline == VTERM_BASELINE_LOWER ? "lower" + : "normal"); + } else if(streq(linep, "foreground")) { print_color(&state_pen.foreground); printf("\n"); @@ -977,6 +1043,7 @@ int main(int argc UNUSED, char **argv UN printf("?\n"); } else if(strstartswith(line, "?lineinfo ")) { + assert(state); char *linep = line + 10; int row; const VTermLineInfo *info; @@ -996,6 +1063,7 @@ int main(int argc UNUSED, char **argv UN printf("\n"); } else if(strstartswith(line, "?screen_chars ")) { + assert(screen); char *linep = line + 13; VTermRect rect; size_t len; @@ -1028,6 +1096,7 @@ int main(int argc UNUSED, char **argv UN } } else if(strstartswith(line, "?screen_text ")) { + assert(screen); char *linep = line + 12; VTermRect rect; size_t len; @@ -1067,6 +1136,7 @@ int main(int argc UNUSED, char **argv UN } } else if(strstartswith(line, "?screen_cell ")) { + assert(screen); char *linep = line + 12; int i; VTermPos pos; @@ -1090,6 +1160,10 @@ int main(int argc UNUSED, char **argv UN if(cell.attrs.blink) printf("K"); if(cell.attrs.reverse) printf("R"); if(cell.attrs.font) printf("F%d", cell.attrs.font); + if(cell.attrs.small) printf("S"); + if(cell.attrs.baseline) printf( + cell.attrs.baseline == VTERM_BASELINE_RAISE ? "^" : + "_"); printf("} "); if(cell.attrs.dwl) printf("dwl "); if(cell.attrs.dhl) printf("dhl-%s ", cell.attrs.dhl == 2 ? "bottom" : "top"); @@ -1102,6 +1176,7 @@ int main(int argc UNUSED, char **argv UN printf("\n"); } else if(strstartswith(line, "?screen_eol ")) { + assert(screen); VTermPos pos; char *linep = line + 12; while(linep[0] == ' ') @@ -1113,6 +1188,7 @@ int main(int argc UNUSED, char **argv UN printf("%d\n", vterm_screen_is_eol(screen, pos)); } else if(strstartswith(line, "?screen_attrs_extent ")) { + assert(screen); VTermPos pos; VTermRect rect; char *linep = line + 21;