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

wezterm: add PastePrimarySelection key assignment

refs: https://github.com/wez/wezterm/issues/183
This commit is contained in:
Wez Furlong 2020-05-19 21:19:06 -07:00
parent f6743086ac
commit 57d270cae0
4 changed files with 25 additions and 14 deletions

View File

@ -11,6 +11,8 @@ the feature set may change. As features stabilize some
brief notes about them may accumulate here.
* Windows: Fixed AltGr handling for European layouts
* X11: Added `PastePrimarySelection` key assignment that pastes the contents
of the primary selection rather than the clipboard.
* Removed old TOML config file parsing code
* Removed old `arg="something"` key binding parameter. This was a remnant from
the TOML based configuration. You're unlikely to notice this unless you

View File

@ -107,6 +107,7 @@ specified via the `arg` key; see examples below.
| `SpawnWindow` | Create a new window |
| `ToggleFullScreen` | Toggles full screen mode for current window |
| `Paste` | Paste the clipboard to the current tab |
| `PastePrimarySelection` | X11: Paste the primary selection to the current tab (behaves like `Paste` on other systems).|
| `ActivateTabRelative` | Activate a tab relative to the current tab. The `arg` value specifies an offset. eg: `-1` activates the tab to the left of the current tab, while `1` activates the tab to the right. |
| `ActivateTab` | Activate the tab specified by the `arg` value. eg: `0` activates the leftmost tab, while `1` activates the second tab from the left, and so on. |
| `IncreaseFontSize` | Increases the font size of the current window by 10% |
@ -139,6 +140,10 @@ return {
{key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={
args={"top"}
}}},
-- If you prefer to paste the primary selection rather than the clipboard
-- when running on X11
{key="Insert", mods="SHIFT", action="PastePrimarySelection"},
}
}
```

View File

@ -1344,6 +1344,19 @@ impl TermWindow {
s
}
fn paste_from_clipboard(&mut self, tab: &Rc<dyn Tab>, clipboard: Clipboard) {
let tab_id = tab.tab_id();
let future = self.window.as_ref().unwrap().get_clipboard(clipboard);
promise::spawn::spawn(async move {
if let Ok(clip) = future.await {
let mux = Mux::get().unwrap();
if let Some(tab) = mux.get_tab(tab_id) {
tab.trickle_paste(clip).ok();
}
}
});
}
fn perform_key_assignment(
&mut self,
tab: &Rc<dyn Tab>,
@ -1373,20 +1386,10 @@ impl TermWindow {
.set_clipboard(self.selection_text(tab));
}
Paste => {
let tab_id = tab.tab_id();
let future = self
.window
.as_ref()
.unwrap()
.get_clipboard(Clipboard::default());
promise::spawn::spawn(async move {
if let Ok(clip) = future.await {
let mux = Mux::get().unwrap();
if let Some(tab) = mux.get_tab(tab_id) {
tab.trickle_paste(clip).ok();
}
}
});
self.paste_from_clipboard(tab, Clipboard::default());
}
PastePrimarySelection => {
self.paste_from_clipboard(tab, Clipboard::PrimarySelection);
}
ActivateTabRelative(n) => {
self.activate_tab_relative(*n)?;

View File

@ -60,6 +60,7 @@ pub enum KeyAssignment {
ToggleFullScreen,
Copy,
Paste,
PastePrimarySelection,
ActivateTabRelative(isize),
IncreaseFontSize,
DecreaseFontSize,