From aa93c3fb66527de71d643c9ef9f808f084200ca4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 1 May 2018 07:36:40 +0530 Subject: [PATCH] Fix passing @text to other programs such as when viewing the scrollback buffer not working correctly if kitty is itself scrolled up. Fixes #509 --- CHANGELOG.rst | 2 ++ kitty/screen.c | 6 ++++++ kitty/window.py | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 54416d643..a2e2382b1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -38,6 +38,8 @@ version 0.9.1 [future] - When rendering a private use unicode codepoint and a space as a two cell ligature, set the foreground colors of the space cell to match the colors of the first cell. Works around applications like powerline that use different colors for the two cells. +- Fix passing @text to other programs such as when viewing the scrollback buffer not working correctly if kitty is itself scrolled up. + version 0.9.0 [2018-04-15] ------------------------------ diff --git a/kitty/screen.c b/kitty/screen.c index 3e8b2fce5..2cd4fc6bc 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1465,6 +1465,11 @@ as_text(Screen *self, PyObject *args) { as_text_generic(args, self, visual_line_, self->lines, self->columns, callback, as_ansi); } +static PyObject* +as_text_non_visual(Screen *self, PyObject *args) { + as_text_generic(args, self, range_line_, self->lines, self->columns, callback, as_ansi); +} + static PyObject* refresh_sprite_positions(Screen *self, PyObject *a UNUSED) { self->is_dirty = true; @@ -1968,6 +1973,7 @@ static PyMethodDef methods[] = { MND(cursor_forward, METH_VARARGS) {"index", (PyCFunction)xxx_index, METH_VARARGS, ""}, MND(as_text, METH_VARARGS) + MND(as_text_non_visual, METH_VARARGS) MND(refresh_sprite_positions, METH_NOARGS) MND(tab, METH_NOARGS) MND(backspace, METH_NOARGS) diff --git a/kitty/window.py b/kitty/window.py index 6a1934d85..55d65c307 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -322,8 +322,10 @@ class Window: def as_text(self, as_ansi=False, add_history=False): lines = [] - self.screen.as_text(lines.append, as_ansi) - if add_history and not self.screen.is_using_alternate_linebuf(): + add_history = add_history and not self.screen.is_using_alternate_linebuf() + f = self.screen.as_text_non_visual if add_history else self.screen.as_text + f(lines.append, as_ansi) + if add_history: h = [] self.screen.historybuf.as_text(h.append, as_ansi) lines = h + lines