1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-10 15:04:32 +03:00

add ScrollToTop and ScrollToBottom key assignments

refs: https://github.com/wez/wezterm/issues/1360
This commit is contained in:
Wez Furlong 2021-12-11 22:02:31 -07:00
parent 21170445b7
commit 66908eabb4
5 changed files with 23 additions and 0 deletions

View File

@ -179,6 +179,8 @@ pub enum KeyAssignment {
ScrollByPage(isize),
ScrollByLine(isize),
ScrollToPrompt(isize),
ScrollToTop,
ScrollToBottom,
ShowTabNavigator,
ShowDebugOverlay,
HideApplication,

View File

@ -14,6 +14,7 @@ As features stabilize some brief notes about them will accumulate here.
#### New
* unix domains now support an optional `proxy_command` to use in place of a direct unix socket connection. [Read more about multiplexing unix domains](multiplexing.html#unix-domains)
* [ScrollToTop](config/lua/keyassignment/ScrollToTop.md) and [ScrollToBottom](config/lua/keyassignment/ScrollToBottom.md) key assignments [#1360](https://github.com/wez/wezterm/issues/1360)
#### Changed

View File

@ -0,0 +1,7 @@
# ScrollToBottom
*Since: nightly builds only*
This action scrolls the viewport to the bottom of the scrollback.

View File

@ -0,0 +1,6 @@
# ScrollToTop
*Since: nightly builds only*
This action scrolls the viewport to the top of the scrollback.

View File

@ -1876,6 +1876,8 @@ impl TermWindow {
ScrollByPage(n) => self.scroll_by_page(*n)?,
ScrollByLine(n) => self.scroll_by_line(*n)?,
ScrollToPrompt(n) => self.scroll_to_prompt(*n)?,
ScrollToTop => self.scroll_to_top(pane),
ScrollToBottom => self.scroll_to_bottom(pane),
ShowTabNavigator => self.show_tab_navigator(),
ShowDebugOverlay => self.show_debug_overlay(),
ShowLauncher => self.show_launcher(),
@ -2162,6 +2164,11 @@ impl TermWindow {
}
}
fn scroll_to_top(&mut self, pane: &Rc<dyn Pane>) {
let dims = pane.get_dimensions();
self.set_viewport(pane.pane_id(), Some(dims.scrollback_top), dims);
}
fn scroll_to_bottom(&mut self, pane: &Rc<dyn Pane>) {
self.pane_state(pane.pane_id()).viewport = None;
}