1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00

wezterm: add ClearScrollback key assignment

Bound to CMD-K and CTRL+SHIFT-K by default.  This also functions
while the output is filling up (eg: `find /` and hit the key binding
to keep pruning the scrollback).

closes: https://github.com/wez/wezterm/issues/194
This commit is contained in:
Wez Furlong 2020-05-25 17:29:22 -07:00
parent 33e387be7d
commit b8acbac113
7 changed files with 34 additions and 0 deletions

View File

@ -19,6 +19,7 @@ brief notes about them may accumulate here.
followed an example from the docs; migrate instead to using eg:
`action=wezterm.action{ActivateTab=i-1}` to pass the integer argument.
* Windows: now also available with a setup.exe installer
* Added `ClearScrollback` key assignment to clear the scrollback. This is bound to CMD-K and CTRL-SHIFT-K by default.
### 20200517-122836-92c201c6

View File

@ -62,6 +62,8 @@ The default key bindings are:
| `SUPER` | `r` | `ReloadConfiguration` |
| `CTRL+SHIFT` | `R` | `ReloadConfiguration` |
| `SUPER` | `h` | `HideApplication` (macOS only) |
| `SUPER` | `k` | `ClearScrollback` |
| `CTRL+SHIFT` | `K` | `ClearScrollback` |
## Default Mouse Assignments
@ -538,6 +540,19 @@ return {
}
```
## ClearScrollback
Clears the lines that have scrolled off the top of the viewport, resetting
the scrollbar thumb to the full height of the window.
```lua
return {
keys = {
{key="K", mods="CTRL|SHIFT", action="ClearScrollback"}
}
}
```
## ReloadConfiguration
Explicitly reload the configuration.

View File

@ -1469,6 +1469,11 @@ impl TermWindow {
window.invalidate();
}
}
ClearScrollback => {
tab.erase_scrollback();
let window = self.window.as_ref().unwrap();
window.invalidate();
}
};
Ok(())
}

View File

@ -97,6 +97,7 @@ pub enum KeyAssignment {
SpawnCommandInNewTab(SpawnCommand),
SpawnCommandInNewWindow(SpawnCommand),
ShowLauncher,
ClearScrollback,
SelectTextAtMouseCursor(SelectionMode),
ExtendSelectionToMouseCursor(Option<SelectionMode>),
@ -158,6 +159,8 @@ impl InputMap {
[KeyModifiers::SUPER, KeyCode::Char('n'), SpawnWindow],
[ctrl_shift, KeyCode::Char('M'), Hide],
[ctrl_shift, KeyCode::Char('N'), SpawnWindow],
[KeyModifiers::SUPER, KeyCode::Char('k'), ClearScrollback],
[ctrl_shift, KeyCode::Char('K'), ClearScrollback],
// Font size manipulation
[KeyModifiers::CTRL, KeyCode::Char('-'), DecreaseFontSize],
[KeyModifiers::CTRL, KeyCode::Char('0'), ResetFontSize],

View File

@ -91,6 +91,10 @@ impl Tab for LocalTab {
self.domain_id
}
fn erase_scrollback(&self) {
self.terminal.borrow_mut().erase_scrollback();
}
fn is_mouse_grabbed(&self) -> bool {
self.terminal.borrow().is_mouse_grabbed()
}

View File

@ -59,6 +59,8 @@ pub trait Tab: Downcast {
fn palette(&self) -> ColorPalette;
fn domain_id(&self) -> DomainId;
fn erase_scrollback(&self) {}
/// Returns true if the terminal has grabbed the mouse and wants to
/// give the embedded application a chance to process events.
/// In practice this controls whether the gui will perform local

View File

@ -487,6 +487,10 @@ impl TerminalState {
}
}
pub fn erase_scrollback(&mut self) {
self.screen_mut().erase_scrollback();
}
pub fn is_mouse_grabbed(&self) -> bool {
self.sgr_mouse
}