mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Fix continuation char marking when rewrapping historybuf
This commit is contained in:
parent
eb1adf4764
commit
cf2fffaf95
3 changed files with 27 additions and 8 deletions
|
|
@ -305,13 +305,6 @@ historybuf_pop_line(HistoryBuf *self, Line *line) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
history_buf_set_last_char_as_continuation(HistoryBuf *self, index_type y, bool wrapped) {
|
||||
if (self->count > 0) {
|
||||
cpu_lineptr(self, index_of(self, y))[self->xnum-1].next_char_was_wrapped = wrapped;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
line(HistoryBuf *self, PyObject *val) {
|
||||
#define line_doc "Return the line with line number val. This buffer grows upwards, i.e. 0 is the most recently added line"
|
||||
|
|
@ -608,9 +601,16 @@ HistoryBuf *alloc_historybuf(unsigned int lines, unsigned int columns, unsigned
|
|||
}
|
||||
// }}}
|
||||
|
||||
static void
|
||||
history_buf_set_last_char_as_continuation(HistoryBuf *self, index_type y, bool wrapped) {
|
||||
if (self->count > 0) {
|
||||
cpu_lineptr(self, index_of(self, y))[self->xnum-1].next_char_was_wrapped = wrapped;
|
||||
}
|
||||
}
|
||||
|
||||
index_type
|
||||
historybuf_next_dest_line(HistoryBuf *self, ANSIBuf *as_ansi_buf, Line *src_line, index_type dest_y, Line *dest_line, bool continued) {
|
||||
history_buf_set_last_char_as_continuation(self, dest_y, continued);
|
||||
history_buf_set_last_char_as_continuation(self, 0, continued);
|
||||
index_type idx = historybuf_push(self, as_ansi_buf);
|
||||
*attrptr(self, idx) = src_line->attrs;
|
||||
init_line(self, idx, dest_line);
|
||||
|
|
|
|||
|
|
@ -546,6 +546,12 @@ last_char_has_wrapped_flag(Line* self, PyObject *a UNUSED) {
|
|||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
set_wrapped_flag(Line* self, PyObject *is_wrapped) {
|
||||
self->cpu_cells[self->xnum-1].next_char_was_wrapped = PyObject_IsTrue(is_wrapped);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
__repr__(Line* self) {
|
||||
PyObject *s = line_as_unicode(self, false);
|
||||
|
|
@ -1028,6 +1034,7 @@ static PyMethodDef methods[] = {
|
|||
METHOD(set_attribute, METH_VARARGS)
|
||||
METHOD(as_ansi, METH_NOARGS)
|
||||
METHOD(last_char_has_wrapped_flag, METH_NOARGS)
|
||||
METHODB(set_wrapped_flag, METH_O),
|
||||
METHOD(hyperlink_ids, METH_NOARGS)
|
||||
METHOD(width, METH_O)
|
||||
METHOD(url_start_at, METH_O)
|
||||
|
|
|
|||
|
|
@ -486,6 +486,18 @@ class TestDataTypes(BaseTest):
|
|||
self.ae(str(hb.line(i)).rstrip(), str(3000 - 1 - i))
|
||||
|
||||
# rewrap
|
||||
def as_ansi(hb):
|
||||
lines = []
|
||||
hb.as_ansi(lines.append)
|
||||
return ''.join(lines)
|
||||
hb = filled_history_buf(5, 5)
|
||||
for i in range(hb.ynum):
|
||||
hb.line(i).set_wrapped_flag(True)
|
||||
hb2 = HistoryBuf(3, 10)
|
||||
before = as_ansi(hb)
|
||||
hb.rewrap(hb2)
|
||||
self.ae(before, as_ansi(hb2).rstrip())
|
||||
|
||||
hb = filled_history_buf(5, 5)
|
||||
hb2 = HistoryBuf(hb.ynum, hb.xnum)
|
||||
hb.rewrap(hb2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue