feat(scrolling): half-page scroll actions (#813)

* Half-page scroll actions #794

* fix(performance): do not hang when resizing large line wraps (#814)

* fix(performance): do not hang when resizing large line wraps

* style(fmt): make rustfmt happy

* style(clippy): make clippy happy

* docs(changelog): scroll fix

* fix(compatibility): home and end key fix (#815)

* fix(compatibility): handle home/end keys properly from terminfo

* style(fmt): make rustfmt happy

* style(fmt): remove unused import

* docs(changelog): home end key fix

* docs(changelog): fix link

* fix(typo): Correct typo from `occured` to `occurred` (#821)

* docs(changelog): fix a typo

* fix(docs): fix wrong arguments for `cargo make run` given in CONTRIBUTING.md (#819)

* docs(changelog): update `cargo-make` for `v0.35.3`

* fix(warning): Fix an unused import warning of std::fs on macos (#820)

* docs(changelog): fix unused import on darwin

* add: `WriteChars` action (#825)

* Behaves like the `Write` action, but one can specify
  strings themselves instead of their bytecodes.

  Usage:

  WriteChars: "cargo make test",

* docs(changelog): Add `WriteChars` action

* fix(docs): Fix a typo and some grammatical errors in bug_report.md (#826)

* docs(changelog): fix typo bug_report template

* add: `rust-version` (msrv) field to `Cargo.toml` (#828)

* specifies the minimum version the package can be compiled with,
  may be ignored with `--ignore-rust-version` option

  ref: https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field

* docs(changelog): add `rust-version` to `Cargo.toml`

* fix(unix): forkpty => openpty (#830)

* fix(unix): forkpty => openpty

* style(fmt): make rustfmt happy

* docs(changelog): forkpty => openpty

* Fix: move `colors_transform` to `colorsys` (#832)

* `colors_transform` is deprecated and superceded by `colorsys`

  ref: https://crates.io/crates/colors-transform

* docs(changelog): `colors_transform` to `colorsys`

* feat(ui): add right-click support to plugins

* chore(docs): update changelog

* chore(warnings): remove unused imports (#833)

* rename var sroll_rows and review snapshots

* style(fmt): make rustfmt happy

Co-authored-by: Aram Drevekenin <aram@poor.dev>
Co-authored-by: Ken Matsui <26405363+ken-matsui@users.noreply.github.com>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
Co-authored-by: Tw <tw19881113@gmail.com>
Co-authored-by: Brooks Rady <b.j.rady@gmail.com>
This commit is contained in:
oromate 2021-11-08 11:05:47 -03:00 committed by GitHub
parent c9f9240969
commit 8f06f119fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 5 deletions

View File

@ -26,4 +26,4 @@ expression: last_snapshot
│ ││line19 00000000000000000000000000000000000000000000000000█│
└──────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
Ctrl + <g> LOCK  <p> PANE  <t> TAB  <n> RESIZE  <h> MOVE  <s> SCROLL  <o> SESSION  <q> QUIT 
<↓↑> Scroll / <PgUp/PgDn> Scroll Page / <ENTER> Select pane
<↓↑> Scroll / <PgUp/PgDn> Scroll Page / <u/d> Scroll Half Page / <ENTER> Select pane

View File

@ -183,6 +183,18 @@ fn route_action(
.send_to_screen(ScreenInstruction::PageScrollDown(client_id))
.unwrap();
}
Action::HalfPageScrollUp => {
session
.senders
.send_to_screen(ScreenInstruction::HalfPageScrollUp(client_id))
.unwrap();
}
Action::HalfPageScrollDown => {
session
.senders
.send_to_screen(ScreenInstruction::HalfPageScrollDown(client_id))
.unwrap();
}
Action::ToggleFocusFullscreen => {
session
.senders

View File

@ -59,6 +59,8 @@ pub(crate) enum ScreenInstruction {
ScrollToBottom(ClientId),
PageScrollUp(ClientId),
PageScrollDown(ClientId),
HalfPageScrollUp(ClientId),
HalfPageScrollDown(ClientId),
ClearScroll(ClientId),
CloseFocusedPane(ClientId),
ToggleActiveTerminalFullscreen(ClientId),
@ -123,6 +125,8 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::ScrollToBottom(..) => ScreenContext::ScrollToBottom,
ScreenInstruction::PageScrollUp(..) => ScreenContext::PageScrollUp,
ScreenInstruction::PageScrollDown(..) => ScreenContext::PageScrollDown,
ScreenInstruction::HalfPageScrollUp(..) => ScreenContext::HalfPageScrollUp,
ScreenInstruction::HalfPageScrollDown(..) => ScreenContext::HalfPageScrollDown,
ScreenInstruction::ClearScroll(..) => ScreenContext::ClearScroll,
ScreenInstruction::CloseFocusedPane(..) => ScreenContext::CloseFocusedPane,
ScreenInstruction::ToggleActiveTerminalFullscreen(..) => {
@ -848,6 +852,22 @@ pub(crate) fn screen_thread_main(
screen.render();
}
ScreenInstruction::HalfPageScrollUp(client_id) => {
screen
.get_active_tab_mut(client_id)
.unwrap()
.scroll_active_terminal_up_half_page();
screen.render();
}
ScreenInstruction::HalfPageScrollDown(client_id) => {
screen
.get_active_tab_mut(client_id)
.unwrap()
.scroll_active_terminal_down_half_page();
screen.render();
}
ScreenInstruction::ClearScroll(client_id) => {
screen
.get_active_tab_mut(client_id)

View File

@ -2899,8 +2899,8 @@ impl Tab {
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
// prevent overflow when row == 0
let scroll_columns = active_terminal.rows().max(1) - 1;
active_terminal.scroll_up(scroll_columns);
let scroll_rows = active_terminal.rows().max(1) - 1;
active_terminal.scroll_up(scroll_rows);
}
}
pub fn scroll_active_terminal_down_page(&mut self) {
@ -2910,8 +2910,33 @@ impl Tab {
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
// prevent overflow when row == 0
let scroll_columns = active_terminal.rows().max(1) - 1;
active_terminal.scroll_down(scroll_columns);
let scroll_rows = active_terminal.rows().max(1) - 1;
active_terminal.scroll_down(scroll_rows);
if !active_terminal.is_scrolled() {
self.process_pending_vte_events(active_terminal_id);
}
}
}
pub fn scroll_active_terminal_up_half_page(&mut self) {
if let Some(active_terminal_id) = self.get_active_terminal_id() {
let active_terminal = self
.panes
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
// prevent overflow when row == 0
let scroll_rows = (active_terminal.rows().max(1) - 1) / 2;
active_terminal.scroll_up(scroll_rows);
}
}
pub fn scroll_active_terminal_down_half_page(&mut self) {
if let Some(active_terminal_id) = self.get_active_terminal_id() {
let active_terminal = self
.panes
.get_mut(&PaneId::Terminal(active_terminal_id))
.unwrap();
// prevent overflow when row == 0
let scroll_rows = (active_terminal.rows().max(1) - 1) / 2;
active_terminal.scroll_down(scroll_rows);
if !active_terminal.is_scrolled() {
self.process_pending_vte_events(active_terminal_id);
}

View File

@ -265,6 +265,10 @@ keybinds:
key: [Ctrl: 'f', PageDown, Right, Char: 'l',]
- action: [PageScrollUp,]
key: [Ctrl: 'b', PageUp, Left, Char: 'h',]
- action: [HalfPageScrollDown,]
key: [Char: 'd',]
- action: [HalfPageScrollUp,]
key: [Char: 'u',]
- action: [NewPane: ,]
key: [ Alt: 'n',]
- action: [MoveFocus: Left,]

View File

@ -239,6 +239,8 @@ pub enum ScreenContext {
ScrollToBottom,
PageScrollUp,
PageScrollDown,
HalfPageScrollUp,
HalfPageScrollDown,
ClearScroll,
CloseFocusedPane,
ToggleActiveSyncTab,

View File

@ -68,6 +68,10 @@ pub enum Action {
PageScrollUp,
/// Scroll down one page in focus pane.
PageScrollDown,
/// Scroll up half page in focus pane.
HalfPageScrollUp,
/// Scroll down half page in focus pane.
HalfPageScrollDown,
/// Toggle between fullscreen focus pane and normal layout.
ToggleFocusFullscreen,
/// Toggle frames around panes in the UI

View File

@ -51,6 +51,7 @@ pub fn get_mode_info(
InputMode::Scroll => vec![
("↓↑".to_string(), "Scroll".to_string()),
("PgUp/PgDn".to_string(), "Scroll Page".to_string()),
("u/d".to_string(), "Scroll Half Page".to_string()),
],
InputMode::RenameTab => vec![("Enter".to_string(), "when done".to_string())],
InputMode::Session => vec![("d".to_string(), "Detach".to_string())],