When dumping commands dump stop_pending_mode at the correct place

This commit is contained in:
Kovid Goyal 2021-07-03 12:07:46 +05:30
parent 38ae370202
commit 1ef895e246
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 19 additions and 12 deletions

View File

@ -1382,7 +1382,7 @@ pending_dcs(Screen *screen, PyObject *dump_callback DUMP_UNUSED) {
REPORT_COMMAND(screen_start_pending_mode);
screen->pending_mode.activated_at = monotonic();
} else {
REPORT_COMMAND(screen_stop_pending_mode);
screen->pending_mode.stop_escape_code_type = DCS;
screen->pending_mode.activated_at = 0;
}
} else pending_escape_code(screen, DCS, ST);
@ -1395,8 +1395,8 @@ pending_csi(Screen *screen, PyObject *dump_callback DUMP_UNUSED) {
REPORT_COMMAND(screen_set_mode, 2026, 1);
screen->pending_mode.activated_at = monotonic();
} else {
REPORT_COMMAND(screen_reset_mode, 2026, 1);
screen->pending_mode.activated_at = 0;
screen->pending_mode.stop_escape_code_type = CSI;
}
} else pending_escape_code(screen, CSI, pb(screen->parser_buf_pos));
}
@ -1456,6 +1456,11 @@ do_parse_bytes(Screen *screen, const uint8_t *read_buf, const size_t read_buf_sz
_parse_bytes(screen, screen->pending_mode.buf, screen->pending_mode.used, dump_callback);
screen->pending_mode.used = 0;
screen->pending_mode.activated_at = 0; // ignore any pending starts in the pending bytes
if (screen->pending_mode.stop_escape_code_type) {
if (screen->pending_mode.stop_escape_code_type == DCS) { REPORT_COMMAND(screen_stop_pending_mode); }
else if (screen->pending_mode.stop_escape_code_type == CSI) { REPORT_COMMAND(screen_reset_mode, 2026, 1); }
screen->pending_mode.stop_escape_code_type = 0;
}
state = START;
break;
@ -1467,6 +1472,7 @@ do_parse_bytes(Screen *screen, const uint8_t *read_buf, const size_t read_buf_sz
case QUEUE_PENDING: {
const size_t needed_space = read_buf_sz * 2;
screen->pending_mode.stop_escape_code_type = 0;
if (screen->pending_mode.capacity - screen->pending_mode.used < needed_space) {
if (screen->pending_mode.capacity >= READ_BUF_SZ) {
dump_partial_escape_code_to_pending(screen);

View File

@ -119,6 +119,7 @@ typedef struct {
size_t capacity, used;
uint8_t *buf;
monotonic_t activated_at, wait_time;
unsigned stop_escape_code_type;
} pending_mode;
DisableLigature disable_ligatures;
PyObject *marker;

View File

@ -347,7 +347,7 @@ class TestParser(BaseTest):
pb('\033P=1s\033\\', ('screen_start_pending_mode',))
pb('a')
self.ae(str(s.line(0)), '')
pb('\033P=2s\033\\', ('screen_stop_pending_mode',), ('draw', 'a'))
pb('\033P=2s\033\\', ('draw', 'a'), ('screen_stop_pending_mode',))
self.ae(str(s.line(0)), 'a')
pb('\033P=1s\033\\', ('screen_start_pending_mode',))
pb('b')
@ -356,20 +356,20 @@ class TestParser(BaseTest):
pb('c', ('draw', 'bc'))
self.ae(str(s.line(0)), 'abc')
pb('\033P=1s\033\\d', ('screen_start_pending_mode',))
pb('\033P=2s\033\\', ('screen_stop_pending_mode',), ('draw', 'd'))
pb('\033P=2s\033\\', ('draw', 'd'), ('screen_stop_pending_mode',))
pb('\033P=1s\033\\e', ('screen_start_pending_mode',))
pb('\033P'), pb('='), pb('2s')
pb('\033\\', ('screen_stop_pending_mode',), ('draw', 'e'))
pb('\033P=1sxyz;.;\033\\''\033P=2skjf".,><?_+)98\033\\', ('screen_start_pending_mode',), ('screen_stop_pending_mode',))
pb('\033\\', ('draw', 'e'), ('screen_stop_pending_mode',))
pb('\033P=1sxyz;.;\033\\''\033P=2skjf".,><?_+)98\033\\', ('screen_start_pending_mode',))
pb('\033P=1s\033\\f\033P=1s\033\\', ('screen_start_pending_mode',), ('screen_start_pending_mode',))
pb('\033P=2s\033\\', ('screen_stop_pending_mode',), ('draw', 'f'))
pb('\033P=1s\033\\XXX\033P=2s\033\\', ('screen_start_pending_mode',), ('screen_stop_pending_mode',), ('draw', 'XXX'))
pb('\033P=2s\033\\', ('draw', 'f'), ('screen_stop_pending_mode',))
pb('\033P=1s\033\\XXX\033P=2s\033\\', ('screen_start_pending_mode',), ('draw', 'XXX'), ('screen_stop_pending_mode',))
pb('\033[?2026hXXX\033[?2026l', ('screen_set_mode', 2026, 1), ('screen_reset_mode', 2026, 1), ('draw', 'XXX'))
pb('\033[?2026h\033[32ma\033[?2026l', ('screen_set_mode', 2026, 1), ('screen_reset_mode', 2026, 1), ('select_graphic_rendition', '32 '), ('draw', 'a'))
pb('\033[?2026hXXX\033[?2026l', ('screen_set_mode', 2026, 1), ('draw', 'XXX'), ('screen_reset_mode', 2026, 1))
pb('\033[?2026h\033[32ma\033[?2026l', ('screen_set_mode', 2026, 1), ('select_graphic_rendition', '32 '), ('draw', 'a'), ('screen_reset_mode', 2026, 1))
pb('\033[?2026h\033P+q544e\033\\ama\033P=2s\033\\',
('screen_set_mode', 2026, 1), ('screen_stop_pending_mode',), ('screen_request_capabilities', 43, '544e'), ('draw', 'ama'))
pb('\033P=1s\033\\\033(B\033P=2s\033\\', ('screen_start_pending_mode',), ('screen_stop_pending_mode',), ('screen_designate_charset', 0, 66))
('screen_set_mode', 2026, 1), ('screen_request_capabilities', 43, '544e'), ('draw', 'ama'), ('screen_stop_pending_mode',))
pb('\033P=1s\033\\\033(B\033P=2s\033\\', ('screen_start_pending_mode',), ('screen_designate_charset', 0, 66), ('screen_stop_pending_mode',))
s.reset()
s.set_pending_timeout(timeout)