Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Half-page scroll actions #813

Merged
merged 29 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7264d78
Half-page scroll actions #794
oromate Oct 28, 2021
42b6664
fix(performance): do not hang when resizing large line wraps (#814)
imsnif Oct 29, 2021
2ac1454
docs(changelog): scroll fix
imsnif Oct 29, 2021
6d47d36
fix(compatibility): home and end key fix (#815)
imsnif Oct 29, 2021
bbf88c6
docs(changelog): home end key fix
imsnif Oct 29, 2021
03e62eb
docs(changelog): fix link
imsnif Oct 30, 2021
f902f3e
fix(typo): Correct typo from `occured` to `occurred` (#821)
ken-matsui Oct 31, 2021
954b432
docs(changelog): fix a typo
a-kenji Oct 31, 2021
b61489c
fix(docs): fix wrong arguments for `cargo make run` given in CONTRIBU…
ken-matsui Oct 31, 2021
0cfc563
docs(changelog): update `cargo-make` for `v0.35.3`
a-kenji Oct 31, 2021
f04a7a4
fix(warning): Fix an unused import warning of std::fs on macos (#820)
ken-matsui Oct 31, 2021
13f3e74
docs(changelog): fix unused import on darwin
a-kenji Oct 31, 2021
d2b8129
add: `WriteChars` action (#825)
a-kenji Nov 1, 2021
c3e361d
docs(changelog): Add `WriteChars` action
a-kenji Nov 1, 2021
5e720b0
fix(docs): Fix a typo and some grammatical errors in bug_report.md (#…
ken-matsui Nov 1, 2021
c39c27c
docs(changelog): fix typo bug_report template
a-kenji Nov 1, 2021
35c566f
add: `rust-version` (msrv) field to `Cargo.toml` (#828)
a-kenji Nov 1, 2021
043a3cf
docs(changelog): add `rust-version` to `Cargo.toml`
a-kenji Nov 1, 2021
a14a2f6
fix(unix): forkpty => openpty (#830)
imsnif Nov 1, 2021
7e9dc40
docs(changelog): forkpty => openpty
imsnif Nov 1, 2021
070de7a
Fix: move `colors_transform` to `colorsys` (#832)
a-kenji Nov 2, 2021
2904c04
docs(changelog): `colors_transform` to `colorsys`
a-kenji Nov 2, 2021
9ea3dc0
feat(ui): add right-click support to plugins
tw4452852 Nov 2, 2021
b37b9e8
chore(docs): update changelog
TheLostLambda Nov 2, 2021
a83a8b9
chore(warnings): remove unused imports (#833)
a-kenji Nov 3, 2021
a3bf369
Merge branch 'half-page-scroll' of https://github.com/oromate/zellij …
imsnif Nov 3, 2021
3a92ae1
rename var sroll_rows and review snapshots
oromate Nov 6, 2021
5268e13
Merge branch 'half-page-scroll' of https://github.com/oromate/zellij …
imsnif Nov 8, 2021
e922f6f
style(fmt): make rustfmt happy
imsnif Nov 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions zellij-server/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,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
Expand Down
20 changes: 20 additions & 0 deletions zellij-server/src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub(crate) enum ScreenInstruction {
ScrollToBottom(ClientId),
PageScrollUp(ClientId),
PageScrollDown(ClientId),
HalfPageScrollUp(ClientId),
HalfPageScrollDown(ClientId),
ClearScroll(ClientId),
CloseFocusedPane(ClientId),
ToggleActiveTerminalFullscreen(ClientId),
Expand Down Expand Up @@ -118,6 +120,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(..) => {
Expand Down Expand Up @@ -826,6 +830,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)
Expand Down
25 changes: 25 additions & 0 deletions zellij-server/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,31 @@ impl Tab {
}
}
}
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_columns = (active_terminal.rows().max(1) - 1)/2;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be scroll_rows, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! But to be fair this is also a mistake in the other methods this was copied from. If you'd like to fix this @oromate that would be cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this. Do you think it makes sense for me to also correct the variable name in the other method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great, thanks! There are a few of those.

active_terminal.scroll_up(scroll_columns);
}
}
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_columns = (active_terminal.rows().max(1) - 1)/2;
active_terminal.scroll_down(scroll_columns);
if !active_terminal.is_scrolled() {
self.process_pending_vte_events(active_terminal_id);
}
}
}
pub fn scroll_active_terminal_to_bottom(&mut self) {
if let Some(active_terminal_id) = self.get_active_terminal_id() {
let active_terminal = self
Expand Down
4 changes: 4 additions & 0 deletions zellij-utils/assets/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,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,]
Expand Down
2 changes: 2 additions & 0 deletions zellij-utils/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ pub enum ScreenContext {
ScrollToBottom,
PageScrollUp,
PageScrollDown,
HalfPageScrollUp,
HalfPageScrollDown,
ClearScroll,
CloseFocusedPane,
ToggleActiveSyncTab,
Expand Down
4 changes: 4 additions & 0 deletions zellij-utils/src/input/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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
Expand Down
1 change: 1 addition & 0 deletions zellij-utils/src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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())],
Expand Down