diff --git a/kitty/line.c b/kitty/line.c index be87886e8..1f35936f5 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -199,8 +199,8 @@ unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc return PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buf, n); } -static PyObject * -as_unicode(Line* self) { +PyObject * +line_as_unicode(Line* self) { return unicode_in_range(self, 0, xlimit_for_line(self), true, 0); } @@ -281,7 +281,7 @@ is_continued(Line* self, PyObject *a UNUSED) { static PyObject* __repr__(Line* self) { - PyObject *s = as_unicode(self); + PyObject *s = line_as_unicode(self); if (s == NULL) return NULL; PyObject *ans = PyObject_Repr(s); Py_CLEAR(s); @@ -570,7 +570,7 @@ PyTypeObject Line_Type = { .tp_basicsize = sizeof(Line), .tp_dealloc = (destructor)dealloc, .tp_repr = (reprfunc)__repr__, - .tp_str = (reprfunc)as_unicode, + .tp_str = (reprfunc)line_as_unicode, .tp_as_sequence = &sequence_methods, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_richcompare = richcmp, diff --git a/kitty/lineops.h b/kitty/lineops.h index 4d18b7528..11ae09171 100644 --- a/kitty/lineops.h +++ b/kitty/lineops.h @@ -57,10 +57,10 @@ unsigned int line_length(Line *self); size_t cell_as_unicode(Cell *cell, bool include_cc, Py_UCS4 *buf, char_type); size_t cell_as_utf8(Cell *cell, bool include_cc, char *buf, char_type); PyObject* unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc, char leading_char); +PyObject* line_as_unicode(Line *); void linebuf_init_line(LineBuf *, index_type); void linebuf_clear(LineBuf *, char_type ch); -void linebuf_init_line(LineBuf *, index_type); void linebuf_index(LineBuf* self, index_type top, index_type bottom); void linebuf_reverse_index(LineBuf *self, index_type top, index_type bottom); void linebuf_clear_line(LineBuf *self, index_type y); @@ -105,7 +105,7 @@ void historybuf_clear(HistoryBuf *self); index_type num = line_as_ansi(line, buf, columns * 100 - 2); \ t = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buf, num); \ } else { \ - t = PyObject_Str((PyObject*)line); \ + t = line_as_unicode(line); \ } \ if (t == NULL) goto end; \ ret = PyObject_CallFunctionObjArgs(callback, t, NULL); \