Add keyboard shortcuts for scrolling in terminal (#13508)
Fixes #4917, #12231 Release Notes: - Added keyboard shortcuts for scrolling in terminal ([4917](https://github.com/zed-industries/zed/issues/4917), [12231](https://github.com/zed-industries/zed/issues/12231))
This commit is contained in:
parent
61bbb3539a
commit
d5fbf75ccf
4 changed files with 95 additions and 4 deletions
|
@ -21,7 +21,8 @@ use terminal::{
|
|||
term::{search::RegexSearch, TermMode},
|
||||
},
|
||||
terminal_settings::{TerminalBlink, TerminalSettings, WorkingDirectory},
|
||||
Clear, Copy, Event, MaybeNavigationTarget, Paste, ShowCharacterPalette, TaskStatus, Terminal,
|
||||
Clear, Copy, Event, MaybeNavigationTarget, Paste, ScrollLineDown, ScrollLineUp, ScrollPageDown,
|
||||
ScrollPageUp, ScrollToBottom, ScrollToTop, ShowCharacterPalette, TaskStatus, Terminal,
|
||||
};
|
||||
use terminal_element::TerminalElement;
|
||||
use ui::{h_flex, prelude::*, ContextMenu, Icon, IconName, Label, Tooltip};
|
||||
|
@ -251,6 +252,36 @@ impl TerminalView {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn scroll_line_up(&mut self, _: &ScrollLineUp, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |term, _| term.scroll_line_up());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn scroll_line_down(&mut self, _: &ScrollLineDown, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |term, _| term.scroll_line_down());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn scroll_page_up(&mut self, _: &ScrollPageUp, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |term, _| term.scroll_page_up());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn scroll_page_down(&mut self, _: &ScrollPageDown, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |term, _| term.scroll_page_down());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn scroll_to_top(&mut self, _: &ScrollToTop, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |term, _| term.scroll_to_top());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn scroll_to_bottom(&mut self, _: &ScrollToBottom, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |term, _| term.scroll_to_bottom());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn should_show_cursor(&self, focused: bool, cx: &mut gpui::ViewContext<Self>) -> bool {
|
||||
//Don't blink the cursor when not focused, blinking is disabled, or paused
|
||||
if !focused
|
||||
|
@ -743,6 +774,12 @@ impl Render for TerminalView {
|
|||
.on_action(cx.listener(TerminalView::copy))
|
||||
.on_action(cx.listener(TerminalView::paste))
|
||||
.on_action(cx.listener(TerminalView::clear))
|
||||
.on_action(cx.listener(TerminalView::scroll_line_up))
|
||||
.on_action(cx.listener(TerminalView::scroll_line_down))
|
||||
.on_action(cx.listener(TerminalView::scroll_page_up))
|
||||
.on_action(cx.listener(TerminalView::scroll_page_down))
|
||||
.on_action(cx.listener(TerminalView::scroll_to_top))
|
||||
.on_action(cx.listener(TerminalView::scroll_to_bottom))
|
||||
.on_action(cx.listener(TerminalView::show_character_palette))
|
||||
.on_action(cx.listener(TerminalView::select_all))
|
||||
.on_key_down(cx.listener(Self::key_down))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue