copy mode: ctrl-v enables rectangular selection
refs: https://github.com/wez/wezterm/issues/1656
This commit is contained in:
1 parent
ef4a95211e
commit
39f53161be
4 files changed
+36
-2
No files matched your search
@@ -385,6 +385,7 @@ pub enum CopyModeAssignment {
|
||||
MoveToScrollbackTop,
|
||||
MoveToScrollbackBottom,
|
||||
ToggleSelectionByCell,
|
||||
SetSelectionMode(Option<SelectionMode>),
|
||||
MoveToStartOfLineContent,
|
||||
MoveToEndOfLineContent,
|
||||
MoveToStartOfLine,
|
||||
|
||||
@@ -26,6 +26,7 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
* macOS: you may now drag and drop files from other programs and have their paths paste into the terminal. The new [quote_dropped_files](config/lua/config/quote_dropped_files.md) option controls how the file names are quoted. Thanks to [@junnplus](https://github.com/junnplus)! [#1868](https://github.com/wez/wezterm/pull/1868)
|
||||
* The mouse scroll wheel now cycles between tabs when hovering over the tab tab. Thanks to [@junnplus](https://github.com/junnplus)! [#1726](https://github.com/wez/wezterm/issues/1726)
|
||||
* Holding down `ALT` while dragging the left button will select a rectangular block. [ExtendSelectionToMouseCursor](config/lua/keyassignment/ExtendSelectionToMouseCursor.md) now accepts `"Block"` as a selection mode. [#1361](https://github.com/wez/wezterm/issues/1361)
|
||||
* In Copy Mode, `CTRL-v` will enable rectangular block selection mode. [#1656](https://github.com/wez/wezterm/issues/1656)
|
||||
|
||||
#### Updated
|
||||
* Bundled harfbuzz to 4.2.1
|
||||
|
||||
+1
-1
@@ -33,6 +33,7 @@ reassignable.
|
||||
| | `CTRL-g` |
|
||||
| | `q` |
|
||||
| Toggle cell selection mode | `v` |
|
||||
| Rectangular selection | `CTRL-v` (*since: nightly builds only*)|
|
||||
| Move Left | `LeftArrow`|
|
||||
| | `h` |
|
||||
| Move Down | `DownArrow`|
|
||||
@@ -64,4 +65,3 @@ reassignable.
|
||||
| Move down one screen | `PageDown` |
|
||||
| | `CTRL-f` |
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::selection::{SelectionCoordinate, SelectionRange};
|
||||
use crate::termwindow::{TermWindow, TermWindowNotif};
|
||||
use config::keyassignment::{
|
||||
CopyModeAssignment, KeyAssignment, KeyTable, KeyTableEntry, ScrollbackEraseMode,
|
||||
CopyModeAssignment, KeyAssignment, KeyTable, KeyTableEntry, ScrollbackEraseMode, SelectionMode,
|
||||
};
|
||||
use mux::domain::DomainId;
|
||||
use mux::pane::{Pane, PaneId, Pattern, SearchResult};
|
||||
@@ -37,6 +37,7 @@ struct CopyRenderable {
|
||||
cursor: StableCursorPosition,
|
||||
delegate: Rc<dyn Pane>,
|
||||
start: Option<SelectionCoordinate>,
|
||||
selection_mode: SelectionMode,
|
||||
viewport: Option<StableRowIndex>,
|
||||
/// We use this to cancel ourselves later
|
||||
window: ::window::Window,
|
||||
@@ -105,6 +106,7 @@ impl CopyOverlay {
|
||||
},
|
||||
editing_search: params.editing_search,
|
||||
result_pos: None,
|
||||
selection_mode: SelectionMode::Cell,
|
||||
};
|
||||
|
||||
let search_row = render.compute_search_row();
|
||||
@@ -324,11 +326,13 @@ impl CopyRenderable {
|
||||
fn adjust_selection(&self, start: SelectionCoordinate, range: SelectionRange) {
|
||||
let pane_id = self.delegate.pane_id();
|
||||
let window = self.window.clone();
|
||||
let mode = self.selection_mode;
|
||||
self.window
|
||||
.notify(TermWindowNotif::Apply(Box::new(move |term_window| {
|
||||
let mut selection = term_window.selection(pane_id);
|
||||
selection.origin = Some(start);
|
||||
selection.range = Some(range);
|
||||
selection.rectangular = mode == SelectionMode::Block;
|
||||
window.invalidate();
|
||||
})));
|
||||
self.adjust_viewport_for_cursor_position();
|
||||
@@ -672,6 +676,26 @@ impl CopyRenderable {
|
||||
};
|
||||
self.start.replace(coord);
|
||||
self.select_to_cursor_pos();
|
||||
self.selection_mode = SelectionMode::Cell;
|
||||
}
|
||||
}
|
||||
|
||||
fn set_selection_mode(&mut self, mode: &Option<SelectionMode>) {
|
||||
match mode {
|
||||
None => {
|
||||
self.start.take();
|
||||
}
|
||||
Some(mode) => {
|
||||
if self.start.is_none() {
|
||||
let coord = SelectionCoordinate {
|
||||
x: self.cursor.x,
|
||||
y: self.cursor.y,
|
||||
};
|
||||
self.start.replace(coord);
|
||||
self.select_to_cursor_pos();
|
||||
}
|
||||
self.selection_mode = *mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -764,6 +788,7 @@ impl Pane for CopyOverlay {
|
||||
ClearPattern => render.clear_pattern(),
|
||||
EditPattern => render.edit_pattern(),
|
||||
AcceptPattern => render.accept_pattern(),
|
||||
SetSelectionMode(mode) => render.set_selection_mode(mode),
|
||||
}
|
||||
true
|
||||
}
|
||||
@@ -1126,6 +1151,13 @@ pub fn copy_key_table() -> KeyTable {
|
||||
Modifiers::NONE,
|
||||
KeyAssignment::CopyMode(CopyModeAssignment::ToggleSelectionByCell),
|
||||
),
|
||||
(
|
||||
WKeyCode::Char('v'),
|
||||
Modifiers::CTRL,
|
||||
KeyAssignment::CopyMode(CopyModeAssignment::SetSelectionMode(Some(
|
||||
SelectionMode::Block,
|
||||
))),
|
||||
),
|
||||
(
|
||||
WKeyCode::Char('G'),
|
||||
Modifiers::SHIFT,
|
||||
|
||||
Reference in new issue
Block a user