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

Add a CloseWithoutClear copy mode key assignment #4924

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 17 additions & 4 deletions docs/examples/default-copy-mode-key-table.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ return {
mods = 'NONE',
action = act.CopyMode 'MoveToStartOfNextLine',
},
{ key = 'Escape', mods = 'NONE', action = act.CopyMode 'Close' },
{ key = 'Escape', mods = 'NONE', action = act.Multiple {
{ CopyMode = 'ScrollToBottom' },
{ CopyMode = 'Close' },
} },
{
key = 'Space',
mods = 'NONE',
Expand Down Expand Up @@ -124,7 +127,10 @@ return {
{ key = 'b', mods = 'NONE', action = act.CopyMode 'MoveBackwardWord' },
{ key = 'b', mods = 'ALT', action = act.CopyMode 'MoveBackwardWord' },
{ key = 'b', mods = 'CTRL', action = act.CopyMode 'PageUp' },
{ key = 'c', mods = 'CTRL', action = act.CopyMode 'Close' },
{ key = 'c', mods = 'CTRL', action = act.Multiple {
{ CopyMode = 'ScrollToBottom' },
{ CopyMode = 'Close' },
} },
{
key = 'd',
mods = 'CTRL',
Expand All @@ -147,7 +153,10 @@ return {
mods = 'NONE',
action = act.CopyMode 'MoveToScrollbackTop',
},
{ key = 'g', mods = 'CTRL', action = act.CopyMode 'Close' },
{ key = 'g', mods = 'CTRL', action = act.Multiple {
{ CopyMode = 'ScrollToBottom' },
{ CopyMode = 'Close' },
} },
{ key = 'h', mods = 'NONE', action = act.CopyMode 'MoveLeft' },
{ key = 'j', mods = 'NONE', action = act.CopyMode 'MoveDown' },
{ key = 'k', mods = 'NONE', action = act.CopyMode 'MoveUp' },
Expand All @@ -162,7 +171,10 @@ return {
mods = 'NONE',
action = act.CopyMode 'MoveToSelectionOtherEnd',
},
{ key = 'q', mods = 'NONE', action = act.CopyMode 'Close' },
{ key = 'q', mods = 'NONE', action = act.Multiple {
{ CopyMode = 'ScrollToBottom' },
{ CopyMode = 'Close' },
} },
{
key = 't',
mods = 'NONE',
Expand All @@ -189,6 +201,7 @@ return {
mods = 'NONE',
action = act.Multiple {
{ CopyTo = 'ClipboardAndPrimarySelection' },
{ CopyMode = 'ScrollToBottom' },
{ CopyMode = 'Close' },
},
},
Expand Down
18 changes: 12 additions & 6 deletions wezterm-gui/src/overlay/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ impl CopyRenderable {
}

fn close(&self) {
self.set_viewport(None);
TermWindow::schedule_cancel_overlay_for_pane(self.window.clone(), self.delegate.pane_id());
}

Expand Down Expand Up @@ -1574,28 +1573,35 @@ pub fn search_key_table() -> KeyTable {
table
}

fn scroll_to_bottom_and_close() -> KeyAssignment {
KeyAssignment::Multiple(vec![
KeyAssignment::ScrollToBottom,
KeyAssignment::CopyMode(CopyModeAssignment::Close),
])
}

pub fn copy_key_table() -> KeyTable {
let mut table = KeyTable::default();
for (key, mods, action) in [
(
WKeyCode::Char('c'),
Modifiers::CTRL,
KeyAssignment::CopyMode(CopyModeAssignment::Close),
scroll_to_bottom_and_close(),
),
(
WKeyCode::Char('g'),
Modifiers::CTRL,
KeyAssignment::CopyMode(CopyModeAssignment::Close),
scroll_to_bottom_and_close(),
),
(
WKeyCode::Char('q'),
Modifiers::NONE,
KeyAssignment::CopyMode(CopyModeAssignment::Close),
scroll_to_bottom_and_close(),
),
(
WKeyCode::Char('\x1b'),
Modifiers::NONE,
KeyAssignment::CopyMode(CopyModeAssignment::Close),
scroll_to_bottom_and_close(),
),
(
WKeyCode::Char('h'),
Expand Down Expand Up @@ -1847,7 +1853,7 @@ pub fn copy_key_table() -> KeyTable {
Modifiers::NONE,
KeyAssignment::Multiple(vec![
KeyAssignment::CopyTo(ClipboardCopyDestination::ClipboardAndPrimarySelection),
KeyAssignment::CopyMode(CopyModeAssignment::Close),
scroll_to_bottom_and_close(),
]),
),
(
Expand Down
Loading