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.
This commit is contained in:
Kovid Goyal 2021-01-29 12:43:41 +05:30
parent 68423b3603
commit ac2a33d09f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 15 additions and 2 deletions

View File

@ -207,14 +207,15 @@ def write_osc(code: int, string: str = '') -> None:
write(OSC + str(code) + string + '\x07') 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: 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(): for line in raw.splitlines():
if line.strip() and not line.startswith('#'): if line.strip() and not line.startswith('#'):
cmd, rest = line.partition(' ')[::2] 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) globals()[cmd](rest)
else: else:
r = map(int, rest.split()) if rest else () r = map(int, rest.split()) if rest else ()

View File

@ -392,6 +392,10 @@ dispatch_osc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) {
START_DISPATCH START_DISPATCH
DISPATCH_OSC_WITH_CODE(set_color_table_color); DISPATCH_OSC_WITH_CODE(set_color_table_color);
END_DISPATCH END_DISPATCH
case 7:
START_DISPATCH
DISPATCH_OSC_WITH_CODE(process_cwd_notification);
END_DISPATCH
case 8: case 8:
dispatch_hyperlink(screen, i, limit-i, dump_callback); dispatch_hyperlink(screen, i, limit-i, dump_callback);
break; break;

View File

@ -1630,6 +1630,13 @@ set_color_table_color(Screen *self, unsigned int code, PyObject *color) {
else { CALLBACK("set_color_table_color", "IO", code, 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 void
screen_handle_cmd(Screen *self, PyObject *cmd) { screen_handle_cmd(Screen *self, PyObject *cmd) {
CALLBACK("handle_remote_cmd", "O", cmd); CALLBACK("handle_remote_cmd", "O", cmd);

View File

@ -193,6 +193,7 @@ void set_icon(Screen *self, PyObject*);
void set_dynamic_color(Screen *self, unsigned int code, PyObject*); void set_dynamic_color(Screen *self, unsigned int code, PyObject*);
void clipboard_control(Screen *self, PyObject*); void clipboard_control(Screen *self, PyObject*);
void set_color_table_color(Screen *self, unsigned int code, 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); uint32_t* translation_table(uint32_t which);
void screen_request_capabilities(Screen *, char, PyObject *); void screen_request_capabilities(Screen *, char, PyObject *);
void screen_set_8bit_controls(Screen *, bool); void screen_set_8bit_controls(Screen *, bool);