Add a new standalone action scroll_prompt_to_top
Refactor clear_terminal to move the functions to Window. Fix the action not scrolling to the bottom when the screen is scrolled.
This commit is contained in:
parent
73cdd87d91
commit
4ed2854791
@ -815,19 +815,21 @@ class Boss:
|
||||
windows.append(w)
|
||||
else:
|
||||
windows = list(self.all_windows)
|
||||
reset = action == 'reset'
|
||||
how = 3 if action == 'scrollback' else 2
|
||||
for w in windows:
|
||||
if action in ('to_cursor', 'scroll'):
|
||||
w.screen.scroll_until_cursor_prompt()
|
||||
if action == 'to_cursor':
|
||||
w.screen.clear_scrollback()
|
||||
continue
|
||||
w.screen.cursor.x = w.screen.cursor.y = 0
|
||||
if reset:
|
||||
w.screen.reset()
|
||||
else:
|
||||
w.screen.erase_in_display(how, False)
|
||||
if action == 'reset':
|
||||
for w in windows:
|
||||
w.clear_screen(reset=True, scrollback=True)
|
||||
elif action == 'scrollback':
|
||||
for w in windows:
|
||||
w.clear_screen(scrollback=True)
|
||||
elif action == 'clear':
|
||||
for w in windows:
|
||||
w.clear_screen()
|
||||
elif action == 'scroll':
|
||||
for w in windows:
|
||||
w.scroll_prompt_to_top()
|
||||
elif action == 'to_cursor':
|
||||
for w in windows:
|
||||
w.scroll_prompt_to_top(clear_scrollback=True)
|
||||
|
||||
def increase_font_size(self) -> None: # legacy
|
||||
cfs = global_font_size()
|
||||
|
||||
@ -1308,6 +1308,13 @@ class Window:
|
||||
text = text.replace(b'\r\n', b'\n').replace(b'\n', b'\r')
|
||||
self.screen.paste(text)
|
||||
|
||||
def clear_screen(self, reset: bool = False, scrollback: bool = False) -> None:
|
||||
self.screen.cursor.x = self.screen.cursor.y = 0
|
||||
if reset:
|
||||
self.screen.reset()
|
||||
else:
|
||||
self.screen.erase_in_display(3 if scrollback else 2, False)
|
||||
|
||||
# actions {{{
|
||||
|
||||
@ac('cp', 'Show scrollback in a pager like less')
|
||||
@ -1445,7 +1452,16 @@ class Window:
|
||||
if self.screen.is_main_linebuf():
|
||||
self.screen.scroll_to_prompt(num_of_prompts)
|
||||
|
||||
@ac('sc', 'Scroll prompt to the bottom of the screen, filling in extra lines form the scrollback buffer')
|
||||
@ac('sc', 'Scroll prompt to the top of the screen, filling screen with empty lines')
|
||||
def scroll_prompt_to_top(self, clear_scrollback: bool = False) -> None:
|
||||
if self.screen.is_main_linebuf():
|
||||
self.screen.scroll_until_cursor_prompt()
|
||||
if clear_scrollback:
|
||||
self.screen.clear_scrollback()
|
||||
elif self.screen.scrolled_by > 0:
|
||||
self.screen.scroll(SCROLL_FULL, False)
|
||||
|
||||
@ac('sc', 'Scroll prompt to the bottom of the screen, filling in extra lines from the scrollback buffer')
|
||||
def scroll_prompt_to_bottom(self) -> None:
|
||||
self.screen.scroll_prompt_to_bottom()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user