From 82d8c4b2302d7b4a5e41c082bb9094ad7b687e32 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 27 May 2020 20:18:05 +0530 Subject: [PATCH] Fix #2699 --- kitty/config_data.py | 3 ++- kitty/window.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kitty/config_data.py b/kitty/config_data.py index eab9b5122..90bcb03ec 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -445,7 +445,8 @@ Program with which to view scrollback in a new window. The scrollback buffer is passed as STDIN to this program. If you change it, make sure the program you use can handle ANSI escape sequences for colors and text formatting. INPUT_LINE_NUMBER in the command line above will be replaced by an integer -representing which line should be at the top of the screen.''')) +representing which line should be at the top of the screen. Similarly CURSOR_LINE and CURSOR_COLUMN +will be replaced by the current cursor position.''')) o('scrollback_pager_history_size', 0, option_type=scrollback_pager_history_size, long_text=_(''' Separate scrollback history size, used only for browsing the scrollback buffer (in MB). diff --git a/kitty/window.py b/kitty/window.py index 372ae5213..d8cf10287 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -698,7 +698,14 @@ class Window: def show_scrollback(self) -> None: text = self.as_text(as_ansi=True, add_history=True, add_wrap_markers=True) data = self.pipe_data(text, has_wrap_markers=True) - cmd = [x.replace('INPUT_LINE_NUMBER', str(data['input_line_number'])) for x in self.opts.scrollback_pager] + + def prepare_arg(x: str) -> str: + x = x.replace('INPUT_LINE_NUMBER', str(data['input_line_number'])) + x = x.replace('CURSOR_LINE', str(data['cursor_y'])) + x = x.replace('CURSOR_COLUMN', str(data['cursor_x'])) + return x + + cmd = list(map(prepare_arg, self.opts.scrollback_pager)) if not os.path.isabs(cmd[0]): import shutil exe = shutil.which(cmd[0])