From ac2a33d09fd3fa594dee3c3d7bb48dc93e66664c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Jan 2021 12:43:41 +0530 Subject: [PATCH] Silence the errors about OSC 7 Up to now this poorly designed and completely unnecessary escape code was relegated to only GNOME, however, off late Apple has started using it as well, so silently ignore it, instead of spamming error messages for it. --- kitty/client.py | 5 +++-- kitty/parser.c | 4 ++++ kitty/screen.c | 7 +++++++ kitty/screen.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kitty/client.py b/kitty/client.py index ccd86b3c1..ad48661b2 100644 --- a/kitty/client.py +++ b/kitty/client.py @@ -207,14 +207,15 @@ def write_osc(code: int, string: str = '') -> None: write(OSC + str(code) + string + '\x07') -set_dynamic_color = set_color_table_color = write_osc +set_dynamic_color = set_color_table_color = process_cwd_notification = write_osc def replay(raw: str) -> None: + specials = {'draw', 'set_title', 'set_icon', 'set_dynamic_color', 'set_color_table_color', 'process_cwd_notification'} for line in raw.splitlines(): if line.strip() and not line.startswith('#'): cmd, rest = line.partition(' ')[::2] - if cmd in {'draw', 'set_title', 'set_icon', 'set_dynamic_color', 'set_color_table_color'}: + if cmd in specials: globals()[cmd](rest) else: r = map(int, rest.split()) if rest else () diff --git a/kitty/parser.c b/kitty/parser.c index c0597aecf..3edd534f0 100644 --- a/kitty/parser.c +++ b/kitty/parser.c @@ -392,6 +392,10 @@ dispatch_osc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { START_DISPATCH DISPATCH_OSC_WITH_CODE(set_color_table_color); END_DISPATCH + case 7: + START_DISPATCH + DISPATCH_OSC_WITH_CODE(process_cwd_notification); + END_DISPATCH case 8: dispatch_hyperlink(screen, i, limit-i, dump_callback); break; diff --git a/kitty/screen.c b/kitty/screen.c index c58dec8d5..96d7dc903 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1630,6 +1630,13 @@ set_color_table_color(Screen *self, unsigned int code, PyObject *color) { else { CALLBACK("set_color_table_color", "IO", code, color); } } +void +process_cwd_notification(Screen *self, unsigned int code, PyObject *cwd) { + (void)self; (void)code; (void)cwd; + // we ignore this as we dont need the stupid OSC 7 cwd reporting protocol, + // since, being moderately intelligent, we can get CWD directly. +} + void screen_handle_cmd(Screen *self, PyObject *cmd) { CALLBACK("handle_remote_cmd", "O", cmd); diff --git a/kitty/screen.h b/kitty/screen.h index 36d1f3687..aeb26888b 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -193,6 +193,7 @@ void set_icon(Screen *self, PyObject*); void set_dynamic_color(Screen *self, unsigned int code, PyObject*); void clipboard_control(Screen *self, PyObject*); void set_color_table_color(Screen *self, unsigned int code, PyObject*); +void process_cwd_notification(Screen *self, unsigned int code, PyObject*); uint32_t* translation_table(uint32_t which); void screen_request_capabilities(Screen *, char, PyObject *); void screen_set_8bit_controls(Screen *, bool);