Use an overlay window for browsing the scrollback buffer in less

This commit is contained in:
Kovid Goyal 2018-02-03 14:58:34 +05:30
parent 647b95631f
commit 561e63ee2d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 12 additions and 26 deletions

View File

@ -244,14 +244,13 @@ feature is best illustrated with a link:remote-control.asciidoc[tutorial].
kitty supports scrolling back to view history, just like most terminals. You kitty supports scrolling back to view history, just like most terminals. You
can use either the <<scrolling-shortcuts,keyboard shortcuts>> or the mouse can use either the <<scrolling-shortcuts,keyboard shortcuts>> or the mouse
scroll wheel to do so. However, kitty has an extra, neat feature. Sometimes you scroll wheel to do so. However, kitty has an extra, neat feature. Sometimes
need to explore the scrollback buffer in more detail, maybe search for some you need to explore the scrollback buffer in more detail, maybe search for some
text or refer to it side-by-side while typing in a follow-up command. kitty text or refer to it side-by-side while typing in a follow-up command. kitty
allows you to do this by pressing the {sc_show_scrollback} key-combination, allows you to do this by pressing the {sc_show_scrollback} key-combination,
which will open the scrollback buffer in a new window, using your favorite which will open the scrollback buffer in your favorite pager program (which is
pager program (which is `less` by default). You can then explore the scrollback `less` by default). Colors and text formatting are preserved. You can explore
buffer using whatever program you normally use. Colors and text formatting are the scrollback pager comfortably within the pager.
preserved.
== Miscellaneous features == Miscellaneous features

View File

@ -359,15 +359,12 @@ class Boss:
for window_id in tuple(w.id for w in self.window_id_map.values() if getattr(w, 'os_window_id', None) == os_window_id): for window_id in tuple(w.id for w in self.window_id_map.values() if getattr(w, 'os_window_id', None) == os_window_id):
self.window_id_map.pop(window_id, None) self.window_id_map.pop(window_id, None)
def display_scrollback(self, data): def display_scrollback(self, window, data):
if self.opts.scrollback_in_new_tab: tab = self.active_tab
self.display_scrollback_in_new_tab(data) if tab is not None:
else: tab.new_special_window(
tab = self.active_tab SpecialWindow(
if tab is not None: self.opts.scrollback_pager, data, _('History'), overlay_for=window.id))
tab.new_special_window(
SpecialWindow(
self.opts.scrollback_pager, data, _('History')))
def switch_focus_to(self, window_idx): def switch_focus_to(self, window_idx):
tab = self.active_tab tab = self.active_tab
@ -506,9 +503,3 @@ class Boss:
tm = self.active_tab_manager tm = self.active_tab_manager
if tm is not None: if tm is not None:
tm.move_tab(-1) tm.move_tab(-1)
def display_scrollback_in_new_tab(self, data):
tm = self.active_tab_manager
if tm is not None:
tm.new_tab(special_window=SpecialWindow(
self.opts.scrollback_pager, data, _('History')))

View File

@ -251,7 +251,6 @@ type_map = {
'adjust_column_width': adjust_line_height, 'adjust_column_width': adjust_line_height,
'scrollback_lines': positive_int, 'scrollback_lines': positive_int,
'scrollback_pager': shlex.split, 'scrollback_pager': shlex.split,
'scrollback_in_new_tab': to_bool,
'font_size': to_font_size, 'font_size': to_font_size,
'font_size_delta': positive_float, 'font_size_delta': positive_float,
'focus_follows_mouse': to_bool, 'focus_follows_mouse': to_bool,

View File

@ -90,9 +90,6 @@ scrollback_lines 2000
# handle ANSI escape sequences for colors and text formatting. # handle ANSI escape sequences for colors and text formatting.
scrollback_pager less +G -R scrollback_pager less +G -R
# When viewing scrollback in a new window, put it in a new tab as well
scrollback_in_new_tab no
# Wheel scroll multiplier (modify the amount scrolled by the mouse wheel). Use negative # Wheel scroll multiplier (modify the amount scrolled by the mouse wheel). Use negative
# numbers to change scroll direction. # numbers to change scroll direction.
wheel_scroll_multiplier 5.0 wheel_scroll_multiplier 5.0

View File

@ -332,7 +332,7 @@ class Window:
# actions {{{ # actions {{{
def show_scrollback(self): def show_scrollback(self):
get_boss().display_scrollback(self.buffer_as_ansi().encode('utf-8')) get_boss().display_scrollback(self, self.buffer_as_ansi().encode('utf-8'))
def paste(self, text): def paste(self, text):
if text and not self.destroyed: if text and not self.destroyed: