From cdd58207a30f7edac753e3ccb3560ab7395e8e49 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 23 Nov 2016 15:47:22 +0530 Subject: [PATCH] Start migrating the tests --- kitty/parser.c | 5 ++--- kitty_tests/parser.py | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/kitty/parser.c b/kitty/parser.c index fdccf7819..74ff67016 100644 --- a/kitty/parser.c +++ b/kitty/parser.c @@ -56,7 +56,7 @@ static void _report_error(PyObject *dump_callback, const char *fmt, ...) { // Normal mode {{{ static inline void handle_normal_mode_char(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_callback) { -#define CALL_SCREEN_HANDLER(name) REPORT_COMMAND(#name, ch); name(screen); break; +#define CALL_SCREEN_HANDLER(name) REPORT_COMMAND(name, ch); name(screen); break; switch(ch) { case BEL: CALL_SCREEN_HANDLER(screen_bell); @@ -67,6 +67,7 @@ handle_normal_mode_char(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_ case LF: case VT: case FF: + case NEL: CALL_SCREEN_HANDLER(screen_linefeed); case CR: CALL_SCREEN_HANDLER(screen_carriage_return); @@ -78,8 +79,6 @@ handle_normal_mode_char(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_ CALL_SCREEN_HANDLER(screen_index); case RI: CALL_SCREEN_HANDLER(screen_reverse_index); - case NEL: - CALL_SCREEN_HANDLER(screen_linefeed); case HTS: CALL_SCREEN_HANDLER(screen_set_tab_stop); case ESC: diff --git a/kitty_tests/parser.py b/kitty_tests/parser.py index ef09d3b2d..ccf244789 100644 --- a/kitty_tests/parser.py +++ b/kitty_tests/parser.py @@ -42,11 +42,21 @@ class TestParser(BaseTest): cd = CmdDump() if isinstance(x, str): x = x.encode('utf-8') - if isinstance(s, str): - s = s.encode('utf-8') - cmds = tuple(('draw', x.encode('utf-8')) if isinstance(x, str) else x for x in cmds) + cmds = tuple(('draw', x) if isinstance(x, str) else x for x in cmds) parse_bytes_dump(cd, s, x) - self.ae(tuple(cd), cmds) + current = '' + q = [] + for args in cd: + if args[0] == 'draw': + current += args[1] + else: + if current: + q.append(('draw', current)) + current = '' + q.append(args) + if current: + q.append(('draw', current)) + self.ae(tuple(q), cmds) def test_simple_parsing(self): s = self.create_screen() @@ -72,11 +82,11 @@ class TestParser(BaseTest): def test_esc_codes(self): s = self.create_screen() pb = partial(self.parse_bytes_dump, s) - pb('12\033Da', '12', ('screen_index',), 'a') + pb('12\033Da', '12', ('screen_index', ord('D')), 'a') self.ae(str(s.line(0)), '12 ') self.ae(str(s.line(1)), ' a ') - pb('\033x', ('Unknown char in escape_dispatch: %d' % ord('x'),)) - pb('\033c123', ('screen_reset',), '123') + pb('\033x', ('Unknown char after ESC: 0x%x' % ord('x'),)) + pb('\033c123', ('screen_reset', ord('c')), '123') self.ae(str(s.line(0)), '123 ') def test_csi_codes(self):