mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-22 03:57:30 +03:00
An echo escape code to echo data via the TTY
This commit is contained in:
parent
d8ed42ae8e
commit
cf01480ec8
@ -1080,11 +1080,22 @@ dispatch_dcs(Screen *screen, PyObject DUMP_UNUSED *dump_callback) {
|
||||
screen_handle_print(screen, msg);
|
||||
Py_DECREF(msg);
|
||||
} else PyErr_Clear();
|
||||
#undef PRINT_PREFIX
|
||||
#define ECHO_PREFIX "kitty-echo|"
|
||||
} else if (startswith(screen->parser_buf + 1, screen->parser_buf_pos - 1, ECHO_PREFIX)) {
|
||||
const size_t pp_size = sizeof(ECHO_PREFIX);
|
||||
PyObject *msg = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, screen->parser_buf + pp_size, screen->parser_buf_pos - pp_size);
|
||||
if (msg != NULL) {
|
||||
REPORT_OSC2(screen_handle_echo, (char)screen->parser_buf[0], msg);
|
||||
screen_handle_echo(screen, msg);
|
||||
Py_DECREF(msg);
|
||||
} else PyErr_Clear();
|
||||
#undef ECHO_PREFIX
|
||||
|
||||
} else {
|
||||
REPORT_ERROR("Unrecognized DCS @ code: 0x%x", screen->parser_buf[1]);
|
||||
}
|
||||
break;
|
||||
#undef PRINT_PREFIX
|
||||
default:
|
||||
REPORT_ERROR("Unrecognized DCS code: 0x%x", screen->parser_buf[0]);
|
||||
break;
|
||||
|
@ -2104,6 +2104,13 @@ screen_handle_print(Screen *self, PyObject *msg) {
|
||||
CALLBACK("handle_remote_print", "O", msg);
|
||||
}
|
||||
|
||||
void
|
||||
screen_handle_echo(Screen *self, PyObject *msg) {
|
||||
Py_ssize_t sz;
|
||||
const char *bytes = PyUnicode_AsUTF8AndSize(msg, &sz);
|
||||
write_to_child(self, bytes, sz);
|
||||
}
|
||||
|
||||
void
|
||||
screen_request_capabilities(Screen *self, char c, PyObject *q) {
|
||||
static char buf[128];
|
||||
|
@ -208,6 +208,7 @@ void screen_push_colors(Screen *, unsigned int);
|
||||
void screen_pop_colors(Screen *, unsigned int);
|
||||
void screen_report_color_stack(Screen *);
|
||||
void screen_handle_print(Screen *, PyObject *cmd);
|
||||
void screen_handle_echo(Screen *, PyObject *cmd);
|
||||
void screen_designate_charset(Screen *, uint32_t which, uint32_t as);
|
||||
void screen_use_latin1(Screen *, bool);
|
||||
void set_title(Screen *self, PyObject*);
|
||||
|
Loading…
Reference in New Issue
Block a user