mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-14 12:34:44 +02:00
More command replaying
This commit is contained in:
@@ -12,6 +12,7 @@ import sys
|
||||
|
||||
|
||||
CSI = '\033['
|
||||
OSC = '\033]'
|
||||
|
||||
|
||||
def write(x):
|
||||
@@ -73,6 +74,10 @@ def screen_set_margins(t, b):
|
||||
write(CSI + '%d;%dr' % (t, b))
|
||||
|
||||
|
||||
def screen_indexn(n):
|
||||
write(CSI + '%dS')
|
||||
|
||||
|
||||
def screen_erase_in_display(how, private):
|
||||
write(CSI + ('?' if private else '') + str(how) + 'J')
|
||||
|
||||
@@ -85,6 +90,10 @@ def screen_cursor_up2(count):
|
||||
write(CSI + '%dA' % count)
|
||||
|
||||
|
||||
def screen_cursor_down(count):
|
||||
write(CSI + '%dDB')
|
||||
|
||||
|
||||
def screen_carriage_return():
|
||||
write('\r')
|
||||
|
||||
@@ -101,6 +110,24 @@ def draw(*a):
|
||||
write(' '.join(a))
|
||||
|
||||
|
||||
def report_device_attributes(mode, char):
|
||||
x = CSI
|
||||
if char:
|
||||
x += ord(char)
|
||||
if mode:
|
||||
x += str(mode)
|
||||
write(CSI + x + 'c')
|
||||
|
||||
|
||||
def write_osc(code, string=''):
|
||||
if string:
|
||||
string = ';' + string
|
||||
write(OSC + str(code) + string + '\x07')
|
||||
|
||||
|
||||
set_dynamic_color = write_osc
|
||||
|
||||
|
||||
def replay(raw):
|
||||
for line in raw.splitlines():
|
||||
if line.strip():
|
||||
|
||||
@@ -96,6 +96,9 @@ _report_params(PyObject *dump_callback, const char *name, unsigned int *params,
|
||||
#define REPORT_OSC(name, string) \
|
||||
Py_XDECREF(PyObject_CallFunction(dump_callback, "sO", #name, string)); PyErr_Clear();
|
||||
|
||||
#define REPORT_OSC2(name, code, string) \
|
||||
Py_XDECREF(PyObject_CallFunction(dump_callback, "sIO", #name, code, string)); PyErr_Clear();
|
||||
|
||||
#else
|
||||
|
||||
#define DUMP_UNUSED UNUSED
|
||||
@@ -107,6 +110,7 @@ _report_params(PyObject *dump_callback, const char *name, unsigned int *params,
|
||||
#define REPORT_PARAMS(...)
|
||||
#define FLUSH_DRAW
|
||||
#define REPORT_OSC(name, string)
|
||||
#define REPORT_OSC2(name, code, string)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -266,7 +270,7 @@ handle_esc_mode_char(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_cal
|
||||
static inline void
|
||||
dispatch_osc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) {
|
||||
#define DISPATCH_OSC(name) REPORT_OSC(name, string); name(screen, string);
|
||||
#define SET_COLOR(name) REPORT_OSC(name, string); name(screen, code, string);
|
||||
#define SET_COLOR(name) REPORT_OSC2(name, code, string); name(screen, code, string);
|
||||
const unsigned int limit = screen->parser_buf_pos;
|
||||
unsigned int code=0, i;
|
||||
for (i = 0; i < MIN(limit, 5); i++) {
|
||||
|
||||
Reference in New Issue
Block a user