mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
Fix dumping of bytes/commands
This commit is contained in:
@@ -247,6 +247,7 @@ class DumpCommands: # {{{
|
||||
if self.draw_dump_buf:
|
||||
safe_print('draw', ''.join(self.draw_dump_buf))
|
||||
self.draw_dump_buf = []
|
||||
a = tuple(str(x, 'utf-8', 'replace') if isinstance(x, memoryview) else x for x in a)
|
||||
safe_print(*a)
|
||||
# }}}
|
||||
|
||||
|
||||
@@ -158,6 +158,22 @@ def screen_cursor_down(count: int) -> None:
|
||||
write(f'{CSI}{count}B')
|
||||
|
||||
|
||||
def screen_report_key_encoding_flags() -> None:
|
||||
write(f'{CSI}?u')
|
||||
|
||||
|
||||
def screen_set_key_encoding_flags(flags: int, how: int) -> None:
|
||||
write(f'{CSI}={flags};{how}u')
|
||||
|
||||
|
||||
def screen_push_key_encoding_flags(flags: int) -> None:
|
||||
write(f'{CSI}>{flags}u')
|
||||
|
||||
|
||||
def screen_pop_key_encoding_flags(flags: int) -> None:
|
||||
write(f'{CSI}<{flags}u')
|
||||
|
||||
|
||||
def screen_carriage_return() -> None:
|
||||
write('\r')
|
||||
|
||||
@@ -214,10 +230,15 @@ def write_osc(code: int, string: str = '') -> None:
|
||||
write(f'{OSC}{code}\x07')
|
||||
|
||||
|
||||
set_dynamic_color = set_color_table_color = process_cwd_notification = write_osc
|
||||
set_color_table_color = process_cwd_notification = write_osc
|
||||
clipboard_control_pending: str = ''
|
||||
|
||||
|
||||
def set_dynamic_color(payload: str) -> None:
|
||||
code, data = payload.partition(' ')[::2]
|
||||
write_osc(int(code), data)
|
||||
|
||||
|
||||
def shell_prompt_marking(payload: str) -> None:
|
||||
write_osc(133, payload)
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/*
|
||||
* bytes-parser.c
|
||||
* vt-parser.c
|
||||
* Copyright (C) 2023 Kovid Goyal <kovid at kovidgoyal.net>
|
||||
*
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
// TODO: Fix dump_commands for OSC and DCS commands that used to take strings but now take memoryview
|
||||
// TODO: Test clipboard kitten with 52 and 5522
|
||||
// TODO: Test shell integration with secondary prompts
|
||||
// TODO: Test screen_request_capabilities
|
||||
@@ -1593,6 +1592,13 @@ do_parse_vt(PS *self) {
|
||||
static void
|
||||
run_worker(Screen *screen, PyObject *dump_callback, monotonic_t now) {
|
||||
PS *self = (PS*)screen->vt_parser->state;
|
||||
#ifdef DUMP_COMMANDS
|
||||
if (screen->read_buf_sz && dump_callback) {
|
||||
RAII_PyObject(mv, PyMemoryView_FromMemory((char*)screen->read_buf, screen->read_buf_sz, PyBUF_READ));
|
||||
PyObject *ret = PyObject_CallFunction(dump_callback, "sO", "bytes", mv);
|
||||
if (ret) { Py_DECREF(ret); } else { PyErr_Clear(); }
|
||||
}
|
||||
#endif
|
||||
self->input_data = screen->read_buf; self->input_sz = screen->read_buf_sz; self->input_pos = 0;
|
||||
self->dump_callback = dump_callback; self->now = now; self->screen = screen;
|
||||
do_parse_vt(self);
|
||||
|
||||
Reference in New Issue
Block a user