mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 9.0.1684: Update libvterm to rev 839
Problem: libvterm slightly outdated Solution: Update libvterm from rev 818 to rev 839 Notable fix: libvterm now handles DECSM/DECRM with multiple arguents, so several ncurses programs (e.g. nnn) can enable mouse properly when run in Vim's terminal in XTerm. closes: #12746 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
committed by
Christian Brabandt
parent
8f5a8d8a8b
commit
b00df7aa38
66
src/libvterm/CODE-MAP
Normal file
66
src/libvterm/CODE-MAP
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
CODE-MAP
|
||||||
|
- high-level list and description of files in the repository
|
||||||
|
|
||||||
|
CONTRIBUTING
|
||||||
|
- documentation explaining how developers can contribute fixes and features
|
||||||
|
|
||||||
|
doc/
|
||||||
|
- contains documentation
|
||||||
|
|
||||||
|
doc/seqs.txt
|
||||||
|
- documents the sequences recognised by the library
|
||||||
|
|
||||||
|
include/vterm.h
|
||||||
|
- main include file
|
||||||
|
|
||||||
|
include/vterm_keycodes.h
|
||||||
|
- include file containing the keyboard input keycode enumerations
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
- legalese
|
||||||
|
|
||||||
|
Makefile
|
||||||
|
- main build file
|
||||||
|
|
||||||
|
src/
|
||||||
|
- contains the source code for the library
|
||||||
|
|
||||||
|
src/encoding.c
|
||||||
|
- handles mapping ISO/IEC 2022 alternate character sets into Unicode
|
||||||
|
codepoints
|
||||||
|
|
||||||
|
src/keyboard.c
|
||||||
|
- handles sending reported keyboard events to the output stream
|
||||||
|
|
||||||
|
src/mouse.c
|
||||||
|
- handles sending reported mouse events to the output stream
|
||||||
|
|
||||||
|
src/parser.c
|
||||||
|
- parses bytes from the input stream into parser-level events
|
||||||
|
|
||||||
|
src/pen.c
|
||||||
|
- interprets SGR sequences and maintains current rendering attributes
|
||||||
|
|
||||||
|
src/screen.c
|
||||||
|
- uses state-level events to maintain a buffer of current screen contents
|
||||||
|
|
||||||
|
src/state.c
|
||||||
|
- follows parser-level events to keep track of the overall terminal state
|
||||||
|
|
||||||
|
src/unicode.c
|
||||||
|
- utility functions for Unicode and UTF-8 handling
|
||||||
|
|
||||||
|
src/vterm.c
|
||||||
|
- toplevel object state and miscellaneous functions
|
||||||
|
|
||||||
|
src/vterm_internal.h
|
||||||
|
- include file for definitions private to the library's internals
|
||||||
|
|
||||||
|
t/
|
||||||
|
- contains unit tests
|
||||||
|
|
||||||
|
t/harness.c
|
||||||
|
- standalone program to embed the library into for unit-test purposes
|
||||||
|
|
||||||
|
t/run-test.pl
|
||||||
|
- invokes the test harness to run a single unit test script
|
@@ -36,14 +36,11 @@ INCFILES=$(TBLFILES:.tbl=.inc)
|
|||||||
|
|
||||||
HFILES_INT=$(sort $(wildcard src/*.h)) $(HFILES)
|
HFILES_INT=$(sort $(wildcard src/*.h)) $(HFILES)
|
||||||
|
|
||||||
VERSION_MAJOR=0
|
|
||||||
VERSION_MINOR=3
|
|
||||||
|
|
||||||
VERSION_CURRENT=0
|
VERSION_CURRENT=0
|
||||||
VERSION_REVISION=0
|
VERSION_REVISION=0
|
||||||
VERSION_AGE=0
|
VERSION_AGE=0
|
||||||
|
|
||||||
VERSION=$(VERSION_MAJOR).$(VERSION_MINOR)
|
VERSION=0.3.3
|
||||||
|
|
||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
BINDIR=$(PREFIX)/bin
|
BINDIR=$(PREFIX)/bin
|
||||||
|
@@ -23,6 +23,7 @@ typedef unsigned int uint32_t;
|
|||||||
|
|
||||||
#define VTERM_VERSION_MAJOR 0
|
#define VTERM_VERSION_MAJOR 0
|
||||||
#define VTERM_VERSION_MINOR 3
|
#define VTERM_VERSION_MINOR 3
|
||||||
|
#define VTERM_VERSION_PATCH 3
|
||||||
|
|
||||||
#define VTERM_CHECK_VERSION \
|
#define VTERM_CHECK_VERSION \
|
||||||
vterm_check_version(VTERM_VERSION_MAJOR, VTERM_VERSION_MINOR)
|
vterm_check_version(VTERM_VERSION_MAJOR, VTERM_VERSION_MINOR)
|
||||||
@@ -255,6 +256,7 @@ typedef enum {
|
|||||||
VTERM_PROP_REVERSE, // bool
|
VTERM_PROP_REVERSE, // bool
|
||||||
VTERM_PROP_CURSORSHAPE, // number
|
VTERM_PROP_CURSORSHAPE, // number
|
||||||
VTERM_PROP_MOUSE, // number
|
VTERM_PROP_MOUSE, // number
|
||||||
|
VTERM_PROP_FOCUSREPORT, // bool
|
||||||
VTERM_PROP_CURSORCOLOR, // VIM - string
|
VTERM_PROP_CURSORCOLOR, // VIM - string
|
||||||
|
|
||||||
VTERM_N_PROPS
|
VTERM_N_PROPS
|
||||||
@@ -422,6 +424,11 @@ typedef struct {
|
|||||||
void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
|
void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
|
||||||
void *vterm_parser_get_cbdata(VTerm *vt);
|
void *vterm_parser_get_cbdata(VTerm *vt);
|
||||||
|
|
||||||
|
/* Normally NUL, CAN, SUB and DEL are ignored. Setting this true causes them
|
||||||
|
* to be emitted by the 'control' callback
|
||||||
|
*/
|
||||||
|
void vterm_parser_set_emit_nul(VTerm *vt, int emit);
|
||||||
|
|
||||||
// -----------
|
// -----------
|
||||||
// State layer
|
// State layer
|
||||||
// -----------
|
// -----------
|
||||||
@@ -645,6 +652,12 @@ int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);
|
|||||||
*/
|
*/
|
||||||
void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col);
|
void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *col);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to vterm_state_set_default_colors(), but also resets colours in the
|
||||||
|
* screen buffer(s)
|
||||||
|
*/
|
||||||
|
void vterm_screen_set_default_colors(VTermScreen *screen, const VTermColor *default_fg, const VTermColor *default_bg);
|
||||||
|
|
||||||
// ---------
|
// ---------
|
||||||
// Utilities
|
// Utilities
|
||||||
// ---------
|
// ---------
|
||||||
|
@@ -148,11 +148,15 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
|
|||||||
string_fragment(vt, string_start, bytes + pos - string_start, FALSE);
|
string_fragment(vt, string_start, bytes + pos - string_start, FALSE);
|
||||||
string_start = bytes + pos + 1;
|
string_start = bytes + pos + 1;
|
||||||
}
|
}
|
||||||
|
if(vt->parser.emit_nul)
|
||||||
|
do_control(vt, c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(c == 0x18 || c == 0x1a) { // CAN, SUB
|
if(c == 0x18 || c == 0x1a) { // CAN, SUB
|
||||||
vt->parser.in_esc = FALSE;
|
vt->parser.in_esc = FALSE;
|
||||||
ENTER_NORMAL_STATE();
|
ENTER_NORMAL_STATE();
|
||||||
|
if(vt->parser.emit_nul)
|
||||||
|
do_control(vt, c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(c == 0x1b) { // ESC
|
else if(c == 0x1b) { // ESC
|
||||||
@@ -402,3 +406,8 @@ void *vterm_parser_get_cbdata(VTerm *vt)
|
|||||||
{
|
{
|
||||||
return vt->parser.cbdata;
|
return vt->parser.cbdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vterm_parser_set_emit_nul(VTerm *vt, int emit)
|
||||||
|
{
|
||||||
|
vt->parser.emit_nul = emit;
|
||||||
|
}
|
||||||
|
@@ -259,15 +259,17 @@ void vterm_state_get_palette_color(const VTermState *state, int index, VTermColo
|
|||||||
|
|
||||||
void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
|
void vterm_state_set_default_colors(VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
|
||||||
{
|
{
|
||||||
/* Copy the given colors */
|
if(default_fg) {
|
||||||
state->default_fg = *default_fg;
|
state->default_fg = *default_fg;
|
||||||
state->default_bg = *default_bg;
|
state->default_fg.type = (state->default_fg.type & ~VTERM_COLOR_DEFAULT_MASK)
|
||||||
|
| VTERM_COLOR_DEFAULT_FG;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure the correct type flags are set */
|
if(default_bg) {
|
||||||
state->default_fg.type = (state->default_fg.type & ~VTERM_COLOR_DEFAULT_MASK)
|
state->default_bg = *default_bg;
|
||||||
| VTERM_COLOR_DEFAULT_FG;
|
state->default_bg.type = (state->default_bg.type & ~VTERM_COLOR_DEFAULT_MASK)
|
||||||
state->default_bg.type = (state->default_bg.type & ~VTERM_COLOR_DEFAULT_MASK)
|
| VTERM_COLOR_DEFAULT_BG;
|
||||||
| VTERM_COLOR_DEFAULT_BG;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
|
void vterm_state_set_palette_color(VTermState *state, int index, const VTermColor *col)
|
||||||
|
@@ -292,7 +292,11 @@ static int erase_internal(VTermRect rect, int selective, void *user)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
cell->chars[0] = 0;
|
cell->chars[0] = 0;
|
||||||
cell->pen = screen->pen;
|
cell->pen = (ScreenPen){
|
||||||
|
/* Only copy .fg and .bg; leave things like rv in reset state */
|
||||||
|
.fg = screen->pen.fg,
|
||||||
|
.bg = screen->pen.bg,
|
||||||
|
};
|
||||||
cell->pen.dwl = info->doublewidth;
|
cell->pen.dwl = info->doublewidth;
|
||||||
cell->pen.dhl = info->doubleheight;
|
cell->pen.dhl = info->doubleheight;
|
||||||
}
|
}
|
||||||
@@ -603,8 +607,15 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new
|
|||||||
new_row_start, new_row_end, old_row_start, old_row_end, width);
|
new_row_start, new_row_end, old_row_start, old_row_end, width);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(new_row_start < 0)
|
if(new_row_start < 0) {
|
||||||
|
if(old_row_start <= old_cursor.row && old_cursor.row < old_row_end) {
|
||||||
|
new_cursor.row = 0;
|
||||||
|
new_cursor.col = old_cursor.col;
|
||||||
|
if(new_cursor.col >= new_cols)
|
||||||
|
new_cursor.col = new_cols-1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for(new_row = new_row_start, old_row = old_row_start; new_row <= new_row_end; new_row++) {
|
for(new_row = new_row_start, old_row = old_row_start; new_row <= new_row_end; new_row++) {
|
||||||
int count = width >= new_cols ? new_cols : width;
|
int count = width >= new_cols ? new_cols : width;
|
||||||
@@ -674,8 +685,9 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new
|
|||||||
|
|
||||||
if(old_row >= 0 && bufidx == BUFIDX_PRIMARY) {
|
if(old_row >= 0 && bufidx == BUFIDX_PRIMARY) {
|
||||||
/* Push spare lines to scrollback buffer */
|
/* Push spare lines to scrollback buffer */
|
||||||
for(int row = 0; row <= old_row; row++)
|
if(screen->callbacks && screen->callbacks->sb_pushline)
|
||||||
sb_pushline_from_row(screen, row);
|
for(int row = 0; row <= old_row; row++)
|
||||||
|
sb_pushline_from_row(screen, row);
|
||||||
if(active)
|
if(active)
|
||||||
statefields->pos.row -= (old_row + 1);
|
statefields->pos.row -= (old_row + 1);
|
||||||
}
|
}
|
||||||
@@ -1204,3 +1216,36 @@ void vterm_screen_convert_color_to_rgb(const VTermScreen *screen, VTermColor *co
|
|||||||
{
|
{
|
||||||
vterm_state_convert_color_to_rgb(screen->state, col);
|
vterm_state_convert_color_to_rgb(screen->state, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reset_default_colours(VTermScreen *screen, ScreenCell *buffer)
|
||||||
|
{
|
||||||
|
for(int row = 0; row <= screen->rows - 1; row++)
|
||||||
|
for(int col = 0; col <= screen->cols - 1; col++) {
|
||||||
|
ScreenCell *cell = &buffer[row * screen->cols + col];
|
||||||
|
if(VTERM_COLOR_IS_DEFAULT_FG(&cell->pen.fg))
|
||||||
|
cell->pen.fg = screen->pen.fg;
|
||||||
|
if(VTERM_COLOR_IS_DEFAULT_BG(&cell->pen.bg))
|
||||||
|
cell->pen.bg = screen->pen.bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vterm_screen_set_default_colors(VTermScreen *screen, const VTermColor *default_fg, const VTermColor *default_bg)
|
||||||
|
{
|
||||||
|
vterm_state_set_default_colors(screen->state, default_fg, default_bg);
|
||||||
|
|
||||||
|
if(default_fg && VTERM_COLOR_IS_DEFAULT_FG(&screen->pen.fg)) {
|
||||||
|
screen->pen.fg = *default_fg;
|
||||||
|
screen->pen.fg.type = (screen->pen.fg.type & ~VTERM_COLOR_DEFAULT_MASK)
|
||||||
|
| VTERM_COLOR_DEFAULT_FG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(default_bg && VTERM_COLOR_IS_DEFAULT_BG(&screen->pen.bg)) {
|
||||||
|
screen->pen.bg = *default_bg;
|
||||||
|
screen->pen.bg.type = (screen->pen.bg.type & ~VTERM_COLOR_DEFAULT_MASK)
|
||||||
|
| VTERM_COLOR_DEFAULT_BG;
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_default_colours(screen, screen->buffers[0]);
|
||||||
|
if(screen->buffers[1])
|
||||||
|
reset_default_colours(screen, screen->buffers[1]);
|
||||||
|
}
|
||||||
|
@@ -837,6 +837,7 @@ static void set_dec_mode(VTermState *state, int num, int val)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1004:
|
case 1004:
|
||||||
|
settermprop_bool(state, VTERM_PROP_FOCUSREPORT, val);
|
||||||
state->mode.report_focus = val;
|
state->mode.report_focus = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -993,6 +994,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
|||||||
|
|
||||||
switch(intermed[0]) {
|
switch(intermed[0]) {
|
||||||
case ' ':
|
case ' ':
|
||||||
|
case '!':
|
||||||
case '"':
|
case '"':
|
||||||
case '$':
|
case '$':
|
||||||
case '\'':
|
case '\'':
|
||||||
@@ -1370,8 +1372,10 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LEADER('?', 0x68): // DEC private mode set
|
case LEADER('?', 0x68): // DEC private mode set
|
||||||
if(!CSI_ARG_IS_MISSING(args[0]))
|
for(int i = 0; i < argcount; i++) {
|
||||||
set_dec_mode(state, CSI_ARG(args[0]), 1);
|
if(!CSI_ARG_IS_MISSING(args[i]))
|
||||||
|
set_dec_mode(state, CSI_ARG(args[i]), 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x6a: // HPB - ECMA-48 8.3.58
|
case 0x6a: // HPB - ECMA-48 8.3.58
|
||||||
@@ -1392,8 +1396,10 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LEADER('?', 0x6c): // DEC private mode reset
|
case LEADER('?', 0x6c): // DEC private mode reset
|
||||||
if(!CSI_ARG_IS_MISSING(args[0]))
|
for(int i = 0; i < argcount; i++) {
|
||||||
set_dec_mode(state, CSI_ARG(args[0]), 0);
|
if(!CSI_ARG_IS_MISSING(args[i]))
|
||||||
|
set_dec_mode(state, CSI_ARG(args[i]), 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x6d: // SGR - ECMA-48 8.3.117
|
case 0x6d: // SGR - ECMA-48 8.3.117
|
||||||
@@ -1486,7 +1492,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case LEADER('!', 0x70): // DECSTR - DEC soft terminal reset
|
case INTERMED('!', 0x70): // DECSTR - DEC soft terminal reset
|
||||||
vterm_state_reset(state, 0);
|
vterm_state_reset(state, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1769,8 +1775,18 @@ static void osc_selection(VTermState *state, VTermStringFragment frag)
|
|||||||
frag.len--;
|
frag.len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!frag.len)
|
if(!frag.len) {
|
||||||
|
/* Clear selection if we're already finished but didn't do anything */
|
||||||
|
if(frag.final && state->selection.callbacks->set) {
|
||||||
|
(*state->selection.callbacks->set)(state->tmp.selection.mask, (VTermStringFragment){
|
||||||
|
.str = NULL,
|
||||||
|
.len = 0,
|
||||||
|
.initial = state->tmp.selection.state != SELECTION_SET,
|
||||||
|
.final = TRUE,
|
||||||
|
}, state->selection.user);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(state->tmp.selection.state == SELECTION_SELECTED) {
|
if(state->tmp.selection.state == SELECTION_SELECTED) {
|
||||||
if(frag.str[0] == '?') {
|
if(frag.str[0] == '?') {
|
||||||
@@ -1788,6 +1804,9 @@ static void osc_selection(VTermState *state, VTermStringFragment frag)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(state->tmp.selection.state == SELECTION_INVALID)
|
||||||
|
return;
|
||||||
|
|
||||||
if(state->selection.callbacks->set) {
|
if(state->selection.callbacks->set) {
|
||||||
size_t bufcur = 0;
|
size_t bufcur = 0;
|
||||||
char *buffer = state->selection.buffer;
|
char *buffer = state->selection.buffer;
|
||||||
@@ -1823,11 +1842,21 @@ static void osc_selection(VTermState *state, VTermStringFragment frag)
|
|||||||
uint8_t b = unbase64one(frag.str[0]);
|
uint8_t b = unbase64one(frag.str[0]);
|
||||||
if(b == 0xFF) {
|
if(b == 0xFF) {
|
||||||
DEBUG_LOG1("base64decode bad input %02X\n", (uint8_t)frag.str[0]);
|
DEBUG_LOG1("base64decode bad input %02X\n", (uint8_t)frag.str[0]);
|
||||||
|
|
||||||
|
state->tmp.selection.state = SELECTION_INVALID;
|
||||||
|
if(state->selection.callbacks->set) {
|
||||||
|
(*state->selection.callbacks->set)(state->tmp.selection.mask, (VTermStringFragment){
|
||||||
|
.str = NULL,
|
||||||
|
.len = 0,
|
||||||
|
.initial = TRUE,
|
||||||
|
.final = TRUE,
|
||||||
|
}, state->selection.user);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
x = (x << 6) | b;
|
x = (x << 6) | b;
|
||||||
n++;
|
n++;
|
||||||
}
|
|
||||||
frag.str++, frag.len--;
|
frag.str++, frag.len--;
|
||||||
|
|
||||||
if(n == 4) {
|
if(n == 4) {
|
||||||
@@ -1847,7 +1876,7 @@ static void osc_selection(VTermState *state, VTermStringFragment frag)
|
|||||||
state->selection.buffer, // str
|
state->selection.buffer, // str
|
||||||
bufcur, // len
|
bufcur, // len
|
||||||
state->tmp.selection.state == SELECTION_SET_INITIAL, // initial
|
state->tmp.selection.state == SELECTION_SET_INITIAL, // initial
|
||||||
frag.final // final
|
frag.final && !frag.len // final
|
||||||
};
|
};
|
||||||
(*state->selection.callbacks->set)(state->tmp.selection.mask,
|
(*state->selection.callbacks->set)(state->tmp.selection.mask,
|
||||||
setfrag, state->selection.user);
|
setfrag, state->selection.user);
|
||||||
@@ -2004,7 +2033,7 @@ static void request_status_string(VTermState *state, VTermStringFragment frag)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vterm_push_output_sprintf_str(state->vt, C1_DCS, TRUE, "0$r%s", tmp);
|
vterm_push_output_sprintf_str(state->vt, C1_DCS, TRUE, "0$r");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int on_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user)
|
static int on_dcs(const char *command, size_t commandlen, VTermStringFragment frag, void *user)
|
||||||
@@ -2354,6 +2383,9 @@ int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val)
|
|||||||
if(val->number == VTERM_PROP_MOUSE_MOVE)
|
if(val->number == VTERM_PROP_MOUSE_MOVE)
|
||||||
state->mouse_flags |= MOUSE_WANT_MOVE;
|
state->mouse_flags |= MOUSE_WANT_MOVE;
|
||||||
return 1;
|
return 1;
|
||||||
|
case VTERM_PROP_FOCUSREPORT:
|
||||||
|
state->mode.report_focus = val->boolean;
|
||||||
|
return 1;
|
||||||
|
|
||||||
case VTERM_N_PROPS:
|
case VTERM_N_PROPS:
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -73,6 +73,8 @@ VTerm *vterm_build(const struct VTermBuilder *builder)
|
|||||||
vt->parser.callbacks = NULL;
|
vt->parser.callbacks = NULL;
|
||||||
vt->parser.cbdata = NULL;
|
vt->parser.cbdata = NULL;
|
||||||
|
|
||||||
|
vt->parser.emit_nul = FALSE;
|
||||||
|
|
||||||
vt->outfunc = NULL;
|
vt->outfunc = NULL;
|
||||||
vt->outdata = NULL;
|
vt->outdata = NULL;
|
||||||
|
|
||||||
@@ -314,6 +316,7 @@ VTermValueType vterm_get_prop_type(VTermProp prop)
|
|||||||
case VTERM_PROP_REVERSE: return VTERM_VALUETYPE_BOOL;
|
case VTERM_PROP_REVERSE: return VTERM_VALUETYPE_BOOL;
|
||||||
case VTERM_PROP_CURSORSHAPE: return VTERM_VALUETYPE_INT;
|
case VTERM_PROP_CURSORSHAPE: return VTERM_VALUETYPE_INT;
|
||||||
case VTERM_PROP_MOUSE: return VTERM_VALUETYPE_INT;
|
case VTERM_PROP_MOUSE: return VTERM_VALUETYPE_INT;
|
||||||
|
case VTERM_PROP_FOCUSREPORT: return VTERM_VALUETYPE_BOOL;
|
||||||
case VTERM_PROP_CURSORCOLOR: return VTERM_VALUETYPE_STRING;
|
case VTERM_PROP_CURSORCOLOR: return VTERM_VALUETYPE_STRING;
|
||||||
|
|
||||||
case VTERM_N_PROPS: return 0;
|
case VTERM_N_PROPS: return 0;
|
||||||
|
@@ -169,6 +169,7 @@ struct VTermState
|
|||||||
SELECTION_QUERY,
|
SELECTION_QUERY,
|
||||||
SELECTION_SET_INITIAL,
|
SELECTION_SET_INITIAL,
|
||||||
SELECTION_SET,
|
SELECTION_SET,
|
||||||
|
SELECTION_INVALID,
|
||||||
} state : 8;
|
} state : 8;
|
||||||
uint32_t recvpartial;
|
uint32_t recvpartial;
|
||||||
uint32_t sendpartial;
|
uint32_t sendpartial;
|
||||||
@@ -238,6 +239,8 @@ struct VTerm
|
|||||||
void *cbdata;
|
void *cbdata;
|
||||||
|
|
||||||
int string_initial;
|
int string_initial;
|
||||||
|
|
||||||
|
int emit_nul;
|
||||||
} parser;
|
} parser;
|
||||||
|
|
||||||
/* len == malloc()ed size; cur == number of valid bytes */
|
/* len == malloc()ed size; cur == number of valid bytes */
|
||||||
|
@@ -55,6 +55,10 @@ MOUSEBTN d 4 0
|
|||||||
output "\e[M\x60\x36\x2b"
|
output "\e[M\x60\x36\x2b"
|
||||||
MOUSEBTN d 5 0
|
MOUSEBTN d 5 0
|
||||||
output "\e[M\x61\x36\x2b"
|
output "\e[M\x61\x36\x2b"
|
||||||
|
MOUSEBTN d 6 0
|
||||||
|
output "\e[M\x62\x36\x2b"
|
||||||
|
MOUSEBTN d 7 0
|
||||||
|
output "\e[M\x63\x36\x2b"
|
||||||
|
|
||||||
!DECRQM on mouse button mode
|
!DECRQM on mouse button mode
|
||||||
PUSH "\e[?1000\$p"
|
PUSH "\e[?1000\$p"
|
||||||
@@ -179,3 +183,9 @@ RESET
|
|||||||
MOUSEMOVE 0,0 0
|
MOUSEMOVE 0,0 0
|
||||||
MOUSEBTN d 1 0
|
MOUSEBTN d 1 0
|
||||||
MOUSEBTN u 1 0
|
MOUSEBTN u 1 0
|
||||||
|
|
||||||
|
!DECSM can set multiple modes at once
|
||||||
|
PUSH "\e[?1002;1006h"
|
||||||
|
settermprop 8 2
|
||||||
|
MOUSEBTN d 1 0
|
||||||
|
output "\e[<0;1;1M"
|
||||||
|
@@ -148,7 +148,9 @@ FOCUS IN
|
|||||||
FOCUS OUT
|
FOCUS OUT
|
||||||
|
|
||||||
!Focus reporting enabled
|
!Focus reporting enabled
|
||||||
|
WANTSTATE +p
|
||||||
PUSH "\e[?1004h"
|
PUSH "\e[?1004h"
|
||||||
|
settermprop 9 true
|
||||||
FOCUS IN
|
FOCUS IN
|
||||||
output "\e[I"
|
output "\e[I"
|
||||||
FOCUS OUT
|
FOCUS OUT
|
||||||
|
@@ -123,3 +123,11 @@ PUSH "\e[74m"
|
|||||||
PUSH "\e[75m"
|
PUSH "\e[75m"
|
||||||
?pen small = off
|
?pen small = off
|
||||||
?pen baseline = normal
|
?pen baseline = normal
|
||||||
|
|
||||||
|
!DECSTR resets pen attributes
|
||||||
|
PUSH "\e[1;4m"
|
||||||
|
?pen bold = on
|
||||||
|
?pen underline = 1
|
||||||
|
PUSH "\e[!p"
|
||||||
|
?pen bold = off
|
||||||
|
?pen underline = 0
|
||||||
|
@@ -26,6 +26,30 @@ PUSH "\e]52;c;SGVsbG"
|
|||||||
PUSH "8s\e\\"
|
PUSH "8s\e\\"
|
||||||
selection-set mask=0001 "lo,"]
|
selection-set mask=0001 "lo,"]
|
||||||
|
|
||||||
|
!Set clipboard; empty first chunk
|
||||||
|
PUSH "\e]52;c;"
|
||||||
|
PUSH "SGVsbG8s\e\\"
|
||||||
|
selection-set mask=0001 ["Hello,"]
|
||||||
|
|
||||||
|
!Set clipboard; empty final chunk
|
||||||
|
PUSH "\e]52;c;SGVsbG8s"
|
||||||
|
selection-set mask=0001 ["Hello,"
|
||||||
|
PUSH "\e\\"
|
||||||
|
selection-set mask=0001 ]
|
||||||
|
|
||||||
|
!Set clipboard; longer than buffer
|
||||||
|
PUSH "\e]52;c;" . "LS0t"x10 . "\e\\"
|
||||||
|
selection-set mask=0001 ["-"x15
|
||||||
|
selection-set mask=0001 "-"x15]
|
||||||
|
|
||||||
|
!Clear clipboard
|
||||||
|
PUSH "\e]52;c;\e\\"
|
||||||
|
selection-set mask=0001 []
|
||||||
|
|
||||||
|
!Set invalid data clears and ignores
|
||||||
|
PUSH "\e]52;c;SGVs*SGVsbG8s\e\\"
|
||||||
|
selection-set mask=0001 []
|
||||||
|
|
||||||
!Query clipboard
|
!Query clipboard
|
||||||
PUSH "\e]52;c;?\e\\"
|
PUSH "\e]52;c;?\e\\"
|
||||||
selection-query mask=0001
|
selection-query mask=0001
|
||||||
|
@@ -41,21 +41,31 @@ PUSH "x\e[74m0\e[73m2\e[m"
|
|||||||
?screen_cell 0,9 = {0x30} width=1 attrs={S_} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
?screen_cell 0,9 = {0x30} width=1 attrs={S_} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
||||||
?screen_cell 0,10 = {0x32} width=1 attrs={S^} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
?screen_cell 0,10 = {0x32} width=1 attrs={S^} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
||||||
|
|
||||||
!EL sets reverse and colours to end of line
|
!EL sets only colours to end of line, not other attrs
|
||||||
PUSH "\e[H\e[7;33;44m\e[K"
|
PUSH "\e[H\e[7;33;44m\e[K"
|
||||||
?screen_cell 0,0 = {} width=1 attrs={R} fg=idx(3) bg=idx(4)
|
|
||||||
?screen_cell 0,79 = {} width=1 attrs={R} fg=idx(3) bg=idx(4)
|
|
||||||
|
|
||||||
!DECSCNM xors reverse for entire screen
|
|
||||||
PUSH "\e[?5h"
|
|
||||||
?screen_cell 0,0 = {} width=1 attrs={} fg=idx(3) bg=idx(4)
|
?screen_cell 0,0 = {} width=1 attrs={} fg=idx(3) bg=idx(4)
|
||||||
?screen_cell 0,79 = {} width=1 attrs={} fg=idx(3) bg=idx(4)
|
?screen_cell 0,79 = {} width=1 attrs={} fg=idx(3) bg=idx(4)
|
||||||
|
|
||||||
|
!DECSCNM xors reverse for entire screen
|
||||||
|
PUSH "R\e[?5h"
|
||||||
|
?screen_cell 0,0 = {0x52} width=1 attrs={} fg=idx(3) bg=idx(4)
|
||||||
?screen_cell 1,0 = {} width=1 attrs={R} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
?screen_cell 1,0 = {} width=1 attrs={R} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
||||||
PUSH "\e[?5\$p"
|
PUSH "\e[?5\$p"
|
||||||
output "\e[?5;1\$y"
|
output "\e[?5;1\$y"
|
||||||
PUSH "\e[?5l"
|
PUSH "\e[?5l"
|
||||||
?screen_cell 0,0 = {} width=1 attrs={R} fg=idx(3) bg=idx(4)
|
?screen_cell 0,0 = {0x52} width=1 attrs={R} fg=idx(3) bg=idx(4)
|
||||||
?screen_cell 0,79 = {} width=1 attrs={R} fg=idx(3) bg=idx(4)
|
|
||||||
?screen_cell 1,0 = {} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
?screen_cell 1,0 = {} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
||||||
PUSH "\e[?5\$p"
|
PUSH "\e[?5\$p"
|
||||||
output "\e[?5;2\$y"
|
output "\e[?5;2\$y"
|
||||||
|
|
||||||
|
!Set default colours
|
||||||
|
RESET
|
||||||
|
PUSH "ABC\e[31mDEF\e[m"
|
||||||
|
?screen_cell 0,0 = {0x41} width=1 attrs={} fg=rgb(240,240,240) bg=rgb(0,0,0)
|
||||||
|
?screen_cell 0,3 = {0x44} width=1 attrs={} fg=idx(1) bg=rgb(0,0,0)
|
||||||
|
SETDEFAULTCOL rgb(252,253,254)
|
||||||
|
?screen_cell 0,0 = {0x41} width=1 attrs={} fg=rgb(252,253,254) bg=rgb(0,0,0)
|
||||||
|
?screen_cell 0,3 = {0x44} width=1 attrs={} fg=idx(1) bg=rgb(0,0,0)
|
||||||
|
SETDEFAULTCOL rgb(250,250,250) rgb(10,20,30)
|
||||||
|
?screen_cell 0,0 = {0x41} width=1 attrs={} fg=rgb(250,250,250) bg=rgb(10,20,30)
|
||||||
|
?screen_cell 0,3 = {0x44} width=1 attrs={} fg=idx(1) bg=rgb(10,20,30)
|
||||||
|
@@ -77,3 +77,12 @@ RESIZE 5,16
|
|||||||
?lineinfo 3 =
|
?lineinfo 3 =
|
||||||
?screen_row 3 = "> "
|
?screen_row 3 = "> "
|
||||||
?cursor = 3,2
|
?cursor = 3,2
|
||||||
|
|
||||||
|
!Cursor goes missing
|
||||||
|
# For more context: https://github.com/neovim/neovim/pull/21124
|
||||||
|
RESET
|
||||||
|
RESIZE 5,5
|
||||||
|
RESIZE 3,1
|
||||||
|
PUSH "\x1b[2;1Habc\r\n\x1b[H"
|
||||||
|
RESIZE 1,1
|
||||||
|
?cursor = 0,0
|
||||||
|
@@ -82,6 +82,26 @@ static void print_color(const VTermColor *col)
|
|||||||
printf(")");
|
printf(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VTermColor strpe_color(char **strp)
|
||||||
|
{
|
||||||
|
uint8_t r, g, b, idx;
|
||||||
|
int len = 0;
|
||||||
|
VTermColor col;
|
||||||
|
|
||||||
|
if(sscanf(*strp, "rgb(%hhu,%hhu,%hhu)%n", &r, &g, &b, &len) == 3 && len > 0) {
|
||||||
|
*strp += len;
|
||||||
|
vterm_color_rgb(&col, r, g, b);
|
||||||
|
}
|
||||||
|
else if(sscanf(*strp, "idx(%hhu)%n", &idx, &len) == 1 && len > 0) {
|
||||||
|
*strp += len;
|
||||||
|
vterm_color_indexed(&col, idx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vterm_color_rgb(&col, 127, 127, 127);
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
static VTerm *vt;
|
static VTerm *vt;
|
||||||
static VTermState *state;
|
static VTermState *state;
|
||||||
static VTermScreen *screen;
|
static VTermScreen *screen;
|
||||||
@@ -669,7 +689,10 @@ int main(int argc UNUSED, char **argv UNUSED)
|
|||||||
if(!state) {
|
if(!state) {
|
||||||
state = vterm_obtain_state(vt);
|
state = vterm_obtain_state(vt);
|
||||||
vterm_state_set_callbacks(state, &state_cbs, NULL);
|
vterm_state_set_callbacks(state, &state_cbs, NULL);
|
||||||
vterm_state_set_selection_callbacks(state, &selection_cbs, NULL, NULL, 1024);
|
/* In some tests we want to check the behaviour of overflowing the
|
||||||
|
* buffer, so make it nicely small
|
||||||
|
*/
|
||||||
|
vterm_state_set_selection_callbacks(state, &selection_cbs, NULL, NULL, 16);
|
||||||
vterm_state_set_bold_highbright(state, 1);
|
vterm_state_set_bold_highbright(state, 1);
|
||||||
vterm_state_reset(state, 1);
|
vterm_state_reset(state, 1);
|
||||||
}
|
}
|
||||||
@@ -942,6 +965,23 @@ int main(int argc UNUSED, char **argv UNUSED)
|
|||||||
vterm_screen_flush_damage(screen);
|
vterm_screen_flush_damage(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if(strstartswith(line, "SETDEFAULTCOL ")) {
|
||||||
|
assert(screen);
|
||||||
|
char *linep = line + 14;
|
||||||
|
while(linep[0] == ' ')
|
||||||
|
linep++;
|
||||||
|
VTermColor fg = strpe_color(&linep);
|
||||||
|
if(linep[0]) {
|
||||||
|
while(linep[0] == ' ')
|
||||||
|
linep++;
|
||||||
|
VTermColor bg = strpe_color(&linep);
|
||||||
|
|
||||||
|
vterm_screen_set_default_colors(screen, &fg, &bg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vterm_screen_set_default_colors(screen, &fg, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
else if(line[0] == '?') {
|
else if(line[0] == '?') {
|
||||||
if(streq(line, "?cursor")) {
|
if(streq(line, "?cursor")) {
|
||||||
assert(state);
|
assert(state);
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1684,
|
||||||
/**/
|
/**/
|
||||||
1683,
|
1683,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user