diff --git a/docs/changelog.rst b/docs/changelog.rst index 9f537ebdb..44e0c95f2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -108,6 +108,9 @@ Detailed list of changes - Allow ignoring failure to close windows/tabs via rc commands (:disc:`5406`) +- Fix hyperlinks not present when fetching text from the history buffer + (:iss:`5427`) + 0.25.2 [2022-06-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 35e4fb932..23169de1c 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -990,9 +990,6 @@ def create_test_font_group(sz: float, dpix: float, class HistoryBuf: - def as_text(self, callback: Callable[[str], None], as_ansi: bool, insert_wrap_markers: bool) -> None: - pass - def pagerhist_as_text(self, upto_output_start: bool = False) -> str: pass @@ -1143,6 +1140,7 @@ class Screen: pass as_text_non_visual = as_text as_text_alternate = as_text + as_text_for_history_buf = as_text def cmd_output(self, which: int, callback: Callable[[str], None], as_ansi: bool, insert_wrap_markers: bool) -> bool: pass diff --git a/kitty/history.c b/kitty/history.c index 472c1180e..bc06d525c 100644 --- a/kitty/history.c +++ b/kitty/history.c @@ -480,13 +480,11 @@ get_line_wrapper(void *x, int y) { return &glw->line; } -static PyObject* -as_text(HistoryBuf *self, PyObject *args) { +PyObject* +as_text_history_buf(HistoryBuf *self, PyObject *args, ANSIBuf *output) { GetLineWrapper glw = {.self=self}; glw.line.xnum = self->xnum; - ANSIBuf output = {0}; - PyObject *ans = as_text_generic(args, &glw, get_line_wrapper, self->count, &output); - free(output.buf); + PyObject *ans = as_text_generic(args, &glw, get_line_wrapper, self->count, output); return ans; } @@ -523,7 +521,6 @@ static PyMethodDef methods[] = { METHODB(pagerhist_rewrap, METH_O), METHODB(pagerhist_as_text, METH_VARARGS), METHODB(pagerhist_as_bytes, METH_VARARGS), - METHODB(as_text, METH_VARARGS), METHOD(dirty_lines, METH_NOARGS) METHOD(push, METH_VARARGS) METHOD(rewrap, METH_VARARGS) diff --git a/kitty/screen.c b/kitty/screen.c index 41f4e2d52..e52dd98ff 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2744,6 +2744,11 @@ as_text_non_visual(Screen *self, PyObject *args) { return as_text_generic(args, self, get_range_line, self->lines, &self->as_ansi_buf); } +static PyObject* +as_text_for_history_buf(Screen *self, PyObject *args) { + return as_text_history_buf(self->historybuf, args, &self->as_ansi_buf); +} + static PyObject* as_text_generic_wrapper(Screen *self, PyObject *args, get_line_func get_line) { return as_text_generic(args, self, get_line, self->lines, &self->as_ansi_buf); @@ -3975,6 +3980,7 @@ static PyMethodDef methods[] = { MND(set_pending_timeout, METH_O) MND(as_text, METH_VARARGS) MND(as_text_non_visual, METH_VARARGS) + MND(as_text_for_history_buf, METH_VARARGS) MND(as_text_alternate, METH_VARARGS) MND(cmd_output, METH_VARARGS) MND(tab, METH_NOARGS) diff --git a/kitty/screen.h b/kitty/screen.h index cc6c9d27e..a100b7acd 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -241,6 +241,7 @@ typedef struct SelectionUpdate { } SelectionUpdate; void screen_update_selection(Screen *self, index_type x, index_type y, bool in_left_half, SelectionUpdate upd); bool screen_history_scroll(Screen *self, int amt, bool upwards); +PyObject* as_text_history_buf(HistoryBuf *self, PyObject *args, ANSIBuf *output); Line* screen_visual_line(Screen *self, index_type y); unsigned long screen_current_char_width(Screen *self); void screen_mark_url(Screen *self, index_type start_x, index_type start_y, index_type end_x, index_type end_y); diff --git a/kitty/window.py b/kitty/window.py index cf72414f0..551c30f92 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -270,7 +270,7 @@ def as_text( if add_history: pht = pagerhist(screen, as_ansi, add_wrap_markers) h: List[str] = [pht] if pht else [] - screen.historybuf.as_text(h.append, as_ansi, add_wrap_markers) + screen.as_text_for_history_buf(h.append, as_ansi, add_wrap_markers) if h: if not screen.linebuf.is_continued(0): h[-1] += '\n'