More work on tui.loop
This commit is contained in:
parent
0c7d51dd9d
commit
22cf67b407
@ -12,6 +12,8 @@ import termios
|
||||
import tty
|
||||
from contextlib import closing, contextmanager
|
||||
|
||||
from kitty.fast_data_types import parse_input_from_terminal
|
||||
|
||||
from .operations import init_state, reset_state
|
||||
|
||||
|
||||
@ -80,6 +82,22 @@ class Loop:
|
||||
if self.read_buf:
|
||||
data = self.read_buf + data
|
||||
self.read_buf = data
|
||||
self.handler = handler
|
||||
self.read_buf = parse_input_from_terminal(
|
||||
handler.on_text, self.on_dcs, self.on_csi, self.on_osc, self.on_pm, self.on_apc, self.read_buf)
|
||||
del self.handler
|
||||
|
||||
def on_dcs(self, dcs):
|
||||
pass
|
||||
|
||||
def on_csi(self, csi):
|
||||
pass
|
||||
|
||||
def on_pm(self, pm):
|
||||
pass
|
||||
|
||||
def on_apc(self, apc):
|
||||
pass
|
||||
|
||||
def _write_ready(self, handler):
|
||||
if len(handler.write_buf) > self.iov_limit:
|
||||
|
||||
@ -12,7 +12,7 @@ parse_input_from_terminal(PyObject *self UNUSED, PyObject *args) {
|
||||
enum State { NORMAL, ESC, CSI, ST, ESC_ST };
|
||||
enum State state = NORMAL;
|
||||
PyObject *uo, *text_callback, *dcs_callback, *csi_callback, *osc_callback, *pm_callback, *apc_callback, *callback;
|
||||
if (!PyArg_ParseTuple(args, "UOOOOOO", &uo, &text_callback, &dcs_callback, &csi_callback, &osc_callback, &pm_callback, &apc_callback)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "OOOOOOU", &text_callback, &dcs_callback, &csi_callback, &osc_callback, &pm_callback, &apc_callback, &uo)) return NULL;
|
||||
Py_ssize_t sz = PyUnicode_GET_LENGTH(uo), pos = 0, start = 0, count = 0, consumed = 0;
|
||||
callback = text_callback;
|
||||
int kind = PyUnicode_KIND(uo);
|
||||
|
||||
@ -343,7 +343,7 @@ class TestDataTypes(BaseTest):
|
||||
text_r, csi_r, apc_r, rest = [], [], [], []
|
||||
left = ''
|
||||
for d in data:
|
||||
left = parse_input_from_terminal(left + d, text_r.append, rest.append, csi_r.append, rest.append, rest.append, apc_r.append)
|
||||
left = parse_input_from_terminal(text_r.append, rest.append, csi_r.append, rest.append, rest.append, apc_r.append, left + d)
|
||||
self.ae(left, leftover)
|
||||
self.ae(text, ' '.join(text_r))
|
||||
self.ae(csi, ' '.join(csi_r))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user