diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-20 18:41:41 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-20 18:41:41 +0200 |
commit | d863728913801c8fa6d633f6580edfcada533fd0 (patch) | |
tree | e2d6e12c3781ec51ffe97255ed51dcd428a9f5c9 /src/libvterm | |
parent | eaa3e0dae53acc9a345f430ef014d65c105192c3 (diff) | |
download | vim-git-d863728913801c8fa6d633f6580edfcada533fd0.tar.gz |
patch 8.2.0802: libvterm code lags behind the upstream versionv8.2.0802
Problem: Libvterm code lags behind the upstream version.
Solution: Include revisions 759 - 762.
Diffstat (limited to 'src/libvterm')
-rw-r--r-- | src/libvterm/doc/seqs.txt | 2 | ||||
-rw-r--r-- | src/libvterm/include/vterm.h | 18 | ||||
-rw-r--r-- | src/libvterm/src/pen.c | 19 | ||||
-rw-r--r-- | src/libvterm/src/screen.c | 12 | ||||
-rw-r--r-- | src/libvterm/src/state.c | 18 | ||||
-rw-r--r-- | src/libvterm/src/vterm.c | 1 | ||||
-rw-r--r-- | src/libvterm/src/vterm_internal.h | 3 | ||||
-rw-r--r-- | src/libvterm/t/12state_scroll.test | 8 | ||||
-rw-r--r-- | src/libvterm/t/harness.c | 15 |
9 files changed, 85 insertions, 11 deletions
diff --git a/src/libvterm/doc/seqs.txt b/src/libvterm/doc/seqs.txt index c03fa51d7..aa15fec3d 100644 --- a/src/libvterm/doc/seqs.txt +++ b/src/libvterm/doc/seqs.txt @@ -170,6 +170,7 @@ between states. SGR 4:x = Underline style 123 SGR 5 = Blink on 123 SGR 7 = Reverse on + SGR 8 = Conceal on SGR 9 = Strikethrough on SGR 10-19 = Select font SGR 21 = Underline double @@ -178,6 +179,7 @@ between states. 23 SGR 24 = Underline off 23 SGR 25 = Blink off 23 SGR 27 = Reverse off + SGR 28 = Conceal off SGR 29 = Strikethrough off SGR 30-37 = Foreground ANSI SGR 38 = Foreground alternative palette diff --git a/src/libvterm/include/vterm.h b/src/libvterm/include/vterm.h index 8b6a64d96..b6491f1f7 100644 --- a/src/libvterm/include/vterm.h +++ b/src/libvterm/include/vterm.h @@ -128,6 +128,7 @@ typedef enum { VTERM_ATTR_ITALIC, // bool: 3, 23 VTERM_ATTR_BLINK, // bool: 5, 25 VTERM_ATTR_REVERSE, // bool: 7, 27 + VTERM_ATTR_CONCEAL, // bool: 8, 28 VTERM_ATTR_STRIKE, // bool: 9, 29 VTERM_ATTR_FONT, // number: 10-19 VTERM_ATTR_FOREGROUND, // color: 30-39 90-97 @@ -314,13 +315,19 @@ typedef struct { // useful to add protocol? } VTermMouseState; +typedef struct { + int (*control)(unsigned char control, void *user); + int (*csi)(const char *leader, const long args[], int argcount, const char *intermed, char command, void *user); + int (*osc)(int command, VTermStringFragment frag, void *user); + int (*dcs)(const char *command, size_t commandlen, VTermStringFragment frag, void *user); +} VTermStateFallbacks; + VTermState *vterm_obtain_state(VTerm *vt); void vterm_state_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user); void *vterm_state_get_cbdata(VTermState *state); -// Only invokes control, csi, osc, dcs -void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user); +void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermStateFallbacks *fallbacks, void *user); void *vterm_state_get_unrecognised_fbdata(VTermState *state); // Initialize the state. @@ -349,6 +356,7 @@ typedef struct { unsigned int italic : 1; unsigned int blink : 1; unsigned int reverse : 1; + unsigned int conceal : 1; unsigned int strike : 1; unsigned int font : 4; // 0 to 9 unsigned int dwl : 1; // On a DECDWL or DECDHL line @@ -395,8 +403,7 @@ VTermScreen *vterm_obtain_screen(VTerm *vt); void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user); void *vterm_screen_get_cbdata(VTermScreen *screen); -// Only invokes control, csi, osc, dcs -void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user); +void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermStateFallbacks *fallbacks, void *user); void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen); // Enable support for using the alternate screen if "altscreen" is non-zero. @@ -438,8 +445,9 @@ typedef enum { VTERM_ATTR_FONT_MASK = 1 << 6, VTERM_ATTR_FOREGROUND_MASK = 1 << 7, VTERM_ATTR_BACKGROUND_MASK = 1 << 8, + VTERM_ATTR_CONCEAL_MASK = 1 << 9, - VTERM_ALL_ATTRS_MASK = (1 << 9) - 1 + VTERM_ALL_ATTRS_MASK = (1 << 10) - 1 } VTermAttrMask; int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTermAttrMask attrs); diff --git a/src/libvterm/src/pen.c b/src/libvterm/src/pen.c index 5619f276d..831d1803f 100644 --- a/src/libvterm/src/pen.c +++ b/src/libvterm/src/pen.c @@ -170,6 +170,7 @@ INTERNAL void vterm_state_resetpen(VTermState *state) state->pen.italic = 0; setpenattr_bool(state, VTERM_ATTR_ITALIC, 0); state->pen.blink = 0; setpenattr_bool(state, VTERM_ATTR_BLINK, 0); state->pen.reverse = 0; setpenattr_bool(state, VTERM_ATTR_REVERSE, 0); + state->pen.conceal = 0; setpenattr_bool(state, VTERM_ATTR_CONCEAL, 0); state->pen.strike = 0; setpenattr_bool(state, VTERM_ATTR_STRIKE, 0); state->pen.font = 0; setpenattr_int( state, VTERM_ATTR_FONT, 0); @@ -192,6 +193,7 @@ INTERNAL void vterm_state_savepen(VTermState *state, int save) setpenattr_bool(state, VTERM_ATTR_ITALIC, state->pen.italic); setpenattr_bool(state, VTERM_ATTR_BLINK, state->pen.blink); setpenattr_bool(state, VTERM_ATTR_REVERSE, state->pen.reverse); + setpenattr_bool(state, VTERM_ATTR_CONCEAL, state->pen.conceal); setpenattr_bool(state, VTERM_ATTR_STRIKE, state->pen.strike); setpenattr_int( state, VTERM_ATTR_FONT, state->pen.font); setpenattr_col( state, VTERM_ATTR_FOREGROUND, state->pen.fg); @@ -293,6 +295,11 @@ INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argco setpenattr_bool(state, VTERM_ATTR_REVERSE, 1); break; + case 8: // Conceal on + state->pen.conceal = 1; + setpenattr_bool(state, VTERM_ATTR_CONCEAL, 1); + break; + case 9: // Strikethrough on state->pen.strike = 1; setpenattr_bool(state, VTERM_ATTR_STRIKE, 1); @@ -334,6 +341,11 @@ INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argco setpenattr_bool(state, VTERM_ATTR_REVERSE, 0); break; + case 28: // Conceal off (Reveal) + state->pen.conceal = 0; + setpenattr_bool(state, VTERM_ATTR_CONCEAL, 0); + break; + case 29: // Strikethrough off state->pen.strike = 0; setpenattr_bool(state, VTERM_ATTR_STRIKE, 0); @@ -433,6 +445,9 @@ INTERNAL int vterm_state_getpen(VTermState *state, long args[], int argcount UNU if(state->pen.reverse) args[argi++] = 7; + if(state->pen.conceal) + args[argi++] = 8; + if(state->pen.strike) args[argi++] = 9; @@ -512,6 +527,10 @@ int vterm_state_get_penattr(const VTermState *state, VTermAttr attr, VTermValue val->boolean = state->pen.reverse; return 1; + case VTERM_ATTR_CONCEAL: + val->boolean = state->pen.conceal; + return 1; + case VTERM_ATTR_STRIKE: val->boolean = state->pen.strike; return 1; diff --git a/src/libvterm/src/screen.c b/src/libvterm/src/screen.c index 0dd6276a1..1e2439c49 100644 --- a/src/libvterm/src/screen.c +++ b/src/libvterm/src/screen.c @@ -21,6 +21,7 @@ typedef struct unsigned int italic : 1; unsigned int blink : 1; unsigned int reverse : 1; + unsigned int conceal : 1; unsigned int strike : 1; unsigned int font : 4; // 0 to 9 @@ -420,6 +421,9 @@ static int setpenattr(VTermAttr attr, VTermValue *val, void *user) case VTERM_ATTR_REVERSE: screen->pen.reverse = val->boolean; return 1; + case VTERM_ATTR_CONCEAL: + screen->pen.conceal = val->boolean; + return 1; case VTERM_ATTR_STRIKE: screen->pen.strike = val->boolean; return 1; @@ -544,6 +548,7 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new dst->pen.italic = src->attrs.italic; dst->pen.blink = src->attrs.blink; dst->pen.reverse = src->attrs.reverse ^ screen->global_reverse; + dst->pen.conceal = src->attrs.conceal; dst->pen.strike = src->attrs.strike; dst->pen.font = src->attrs.font; @@ -553,6 +558,8 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new if(src->width == 2 && pos.col < (new_cols-1)) (dst + 1)->chars[0] = (uint32_t) -1; } + for( ; pos.col < new_cols; pos.col++) + clearcell(screen, &new_buffer[pos.row * new_cols + pos.col]); new_row--; if(active) @@ -815,6 +822,7 @@ int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCe cell->attrs.italic = intcell->pen.italic; cell->attrs.blink = intcell->pen.blink; cell->attrs.reverse = intcell->pen.reverse ^ screen->global_reverse; + cell->attrs.conceal = intcell->pen.conceal; cell->attrs.strike = intcell->pen.strike; cell->attrs.font = intcell->pen.font; @@ -890,7 +898,7 @@ void *vterm_screen_get_cbdata(VTermScreen *screen) return screen->cbdata; } -void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user) +void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermStateFallbacks *fallbacks, void *user) { vterm_state_set_unrecognised_fallbacks(screen->state, fallbacks, user); } @@ -935,6 +943,8 @@ static int attrs_differ(VTermAttrMask attrs, ScreenCell *a, ScreenCell *b) return 1; if((attrs & VTERM_ATTR_REVERSE_MASK) && (a->pen.reverse != b->pen.reverse)) return 1; + if((attrs & VTERM_ATTR_CONCEAL_MASK) && (a->pen.conceal != b->pen.conceal)) + return 1; if((attrs & VTERM_ATTR_STRIKE_MASK) && (a->pen.strike != b->pen.strike)) return 1; if((attrs & VTERM_ATTR_FONT_MASK) && (a->pen.font != b->pen.font)) diff --git a/src/libvterm/src/state.c b/src/libvterm/src/state.c index 42f61f256..15579d2c4 100644 --- a/src/libvterm/src/state.c +++ b/src/libvterm/src/state.c @@ -1478,6 +1478,14 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha state->scrollregion_bottom = -1; } + // Setting the scrolling region restores the cursor to the home position + state->pos.row = 0; + state->pos.col = 0; + if(state->mode.origin) { + state->pos.row += state->scrollregion_top; + state->pos.col += SCROLLREGION_LEFT(state); + } + break; case 0x73: // DECSLRM - DEC custom @@ -1499,6 +1507,14 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha state->scrollregion_right = -1; } + // Setting the scrolling region restores the cursor to the home position + state->pos.row = 0; + state->pos.col = 0; + if(state->mode.origin) { + state->pos.row += state->scrollregion_top; + state->pos.col += SCROLLREGION_LEFT(state); + } + break; case 0x74: @@ -1979,7 +1995,7 @@ void *vterm_state_get_cbdata(VTermState *state) return state->cbdata; } -void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user) +void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermStateFallbacks *fallbacks, void *user) { if(fallbacks) { state->fallbacks = fallbacks; diff --git a/src/libvterm/src/vterm.c b/src/libvterm/src/vterm.c index d03b7b4d7..a9fd3eda7 100644 --- a/src/libvterm/src/vterm.c +++ b/src/libvterm/src/vterm.c @@ -261,6 +261,7 @@ VTermValueType vterm_get_attr_type(VTermAttr attr) case VTERM_ATTR_ITALIC: return VTERM_VALUETYPE_BOOL; case VTERM_ATTR_BLINK: return VTERM_VALUETYPE_BOOL; case VTERM_ATTR_REVERSE: return VTERM_VALUETYPE_BOOL; + case VTERM_ATTR_CONCEAL: return VTERM_VALUETYPE_BOOL; case VTERM_ATTR_STRIKE: return VTERM_VALUETYPE_BOOL; case VTERM_ATTR_FONT: return VTERM_VALUETYPE_INT; case VTERM_ATTR_FOREGROUND: return VTERM_VALUETYPE_COLOR; diff --git a/src/libvterm/src/vterm_internal.h b/src/libvterm/src/vterm_internal.h index 7321d0d85..1cfe9383d 100644 --- a/src/libvterm/src/vterm_internal.h +++ b/src/libvterm/src/vterm_internal.h @@ -53,6 +53,7 @@ struct VTermPen unsigned int italic:1; unsigned int blink:1; unsigned int reverse:1; + unsigned int conceal:1; unsigned int strike:1; unsigned int font:4; // To store 0-9 }; @@ -73,7 +74,7 @@ struct VTermState const VTermStateCallbacks *callbacks; void *cbdata; - const VTermParserCallbacks *fallbacks; + const VTermStateFallbacks *fallbacks; void *fbdata; int rows; diff --git a/src/libvterm/t/12state_scroll.test b/src/libvterm/t/12state_scroll.test index ca305d499..c1f2791d0 100644 --- a/src/libvterm/t/12state_scroll.test +++ b/src/libvterm/t/12state_scroll.test @@ -40,8 +40,8 @@ PUSH "\n" ?cursor = 20,0 !Index in DECSTBM -PUSH "\e[10H" PUSH "\e[9;10r" +PUSH "\e[10H" PUSH "\eM" ?cursor = 8,0 PUSH "\eM" @@ -148,3 +148,9 @@ PUSH "\e[2T" moverect 0..23,0..80 -> 2..25,0..80 erase 0..2,0..80 ?cursor = 0,0 + +!DECSTBM resets cursor position +PUSH "\e[5;5H" + ?cursor = 4,4 +PUSH "\e[r" + ?cursor = 0,0 diff --git a/src/libvterm/t/harness.c b/src/libvterm/t/harness.c index 92882fdfd..fd129b715 100644 --- a/src/libvterm/t/harness.c +++ b/src/libvterm/t/harness.c @@ -206,7 +206,14 @@ static VTermParserCallbacks parser_cbs = { NULL // resize }; -// These callbacks are shared by State and Screen +static VTermStateFallbacks fallbacks = { + parser_control, // control + parser_csi, // csi + parser_osc, // osc + parser_dcs // dcs +}; + +/* These callbacks are shared by State and Screen */ static int want_movecursor = 0; static VTermPos state_pos; @@ -319,6 +326,7 @@ static struct { int italic; int blink; int reverse; + int conceal; int strike; int font; VTermColor foreground; @@ -342,6 +350,9 @@ static int state_setpenattr(VTermAttr attr, VTermValue *val, void *user UNUSED) case VTERM_ATTR_REVERSE: state_pen.reverse = val->boolean; break; + case VTERM_ATTR_CONCEAL: + state_pen.conceal = val->boolean; + break; case VTERM_ATTR_STRIKE: state_pen.strike = val->boolean; break; @@ -552,7 +563,7 @@ int main(int argc UNUSED, char **argv UNUSED) want_settermprop = sense; break; case 'f': - vterm_state_set_unrecognised_fallbacks(state, sense ? &parser_cbs : NULL, NULL); + vterm_state_set_unrecognised_fallbacks(state, sense ? &fallbacks : NULL, NULL); break; default: fprintf(stderr, "Unrecognised WANTSTATE flag '%c'\n", line[i]); |