diff --git a/kitty/line-buf.c b/kitty/line-buf.c index c7c64dd9b..2f0ae76a7 100644 --- a/kitty/line-buf.c +++ b/kitty/line-buf.c @@ -114,6 +114,26 @@ set_attribute(LineBuf *self, PyObject *args) { Py_RETURN_NONE; } +static PyObject* +set_continued(LineBuf *self, PyObject *args) { +#define set_continued_doc "set_continued(y, val) -> Set the continued values for the specified line." + unsigned int y; + int val; + if (!PyArg_ParseTuple(args, "Ip", &y, &val)) return NULL; + if (y >= self->ynum) { PyErr_SetString(PyExc_ValueError, "Out of bounds."); return NULL; } + self->continued_map[y] = val & 1; + Py_RETURN_NONE; +} + +static PyObject* +is_continued(LineBuf *self, PyObject *val) { +#define is_continued_doc "is_continued(y) -> Whether the line y is continued or not" + unsigned long y = PyLong_AsUnsignedLong(val); + if (y >= self->ynum) { PyErr_SetString(PyExc_ValueError, "Out of bounds."); return NULL; } + if (self->continued_map[y]) { Py_RETURN_TRUE; } + Py_RETURN_FALSE; +} + // Boilerplate {{{ static PyObject* @@ -125,6 +145,8 @@ static PyMethodDef methods[] = { METHOD(copy_old, METH_O) METHOD(clear, METH_NOARGS) METHOD(set_attribute, METH_VARARGS) + METHOD(set_continued, METH_VARARGS) + METHOD(is_continued, METH_O) {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/kitty/screen.py b/kitty/screen.py index 14c533992..f23b9ac56 100644 --- a/kitty/screen.py +++ b/kitty/screen.py @@ -357,7 +357,7 @@ class Screen: if mo.DECAWM in self.mode: self.carriage_return() self.linefeed() - self.linebuf[self.cursor.y].continued = True + self.linebuf.set_continued(self.cursor.y, True) space_left_in_line = self.columns else: space_left_in_line = 1 @@ -365,7 +365,7 @@ class Screen: pos = len(data) - 1 self.cursor.x = self.columns - 1 write_sz = min(len_left, space_left_in_line) - line = self.linebuf[self.cursor.y] + line = self.linebuf.line(self.cursor.y) if do_insert: line.right_shift(self.cursor.x, write_sz) line.set_text(data, pos, write_sz, self.cursor) diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index e03002623..1b852887e 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -25,6 +25,10 @@ class TestDataTypes(BaseTest): c = old.line(y).cursor_from(x) self.assertFalse(c.reverse) self.assertTrue(c.bold) + self.assertFalse(old.is_continued(0)) + old.set_continued(0, True) + self.assertTrue(old.is_continued(0)) + self.assertFalse(old.is_continued(1)) def test_line(self): lb = LineBuf(2, 3)