mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
wezterm: add PastePrimarySelection key assignment
refs: https://github.com/wez/wezterm/issues/183
This commit is contained in:
parent
f6743086ac
commit
57d270cae0
@ -11,6 +11,8 @@ the feature set may change. As features stabilize some
|
|||||||
brief notes about them may accumulate here.
|
brief notes about them may accumulate here.
|
||||||
|
|
||||||
* Windows: Fixed AltGr handling for European layouts
|
* 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 TOML config file parsing code
|
||||||
* Removed old `arg="something"` key binding parameter. This was a remnant from
|
* Removed old `arg="something"` key binding parameter. This was a remnant from
|
||||||
the TOML based configuration. You're unlikely to notice this unless you
|
the TOML based configuration. You're unlikely to notice this unless you
|
||||||
|
@ -107,6 +107,7 @@ specified via the `arg` key; see examples below.
|
|||||||
| `SpawnWindow` | Create a new window |
|
| `SpawnWindow` | Create a new window |
|
||||||
| `ToggleFullScreen` | Toggles full screen mode for current window |
|
| `ToggleFullScreen` | Toggles full screen mode for current window |
|
||||||
| `Paste` | Paste the clipboard to the current tab |
|
| `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. |
|
| `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. |
|
| `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% |
|
| `IncreaseFontSize` | Increases the font size of the current window by 10% |
|
||||||
@ -139,6 +140,10 @@ return {
|
|||||||
{key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={
|
{key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={
|
||||||
args={"top"}
|
args={"top"}
|
||||||
}}},
|
}}},
|
||||||
|
|
||||||
|
-- If you prefer to paste the primary selection rather than the clipboard
|
||||||
|
-- when running on X11
|
||||||
|
{key="Insert", mods="SHIFT", action="PastePrimarySelection"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -1344,6 +1344,19 @@ impl TermWindow {
|
|||||||
s
|
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(
|
fn perform_key_assignment(
|
||||||
&mut self,
|
&mut self,
|
||||||
tab: &Rc<dyn Tab>,
|
tab: &Rc<dyn Tab>,
|
||||||
@ -1373,20 +1386,10 @@ impl TermWindow {
|
|||||||
.set_clipboard(self.selection_text(tab));
|
.set_clipboard(self.selection_text(tab));
|
||||||
}
|
}
|
||||||
Paste => {
|
Paste => {
|
||||||
let tab_id = tab.tab_id();
|
self.paste_from_clipboard(tab, Clipboard::default());
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
PastePrimarySelection => {
|
||||||
});
|
self.paste_from_clipboard(tab, Clipboard::PrimarySelection);
|
||||||
}
|
}
|
||||||
ActivateTabRelative(n) => {
|
ActivateTabRelative(n) => {
|
||||||
self.activate_tab_relative(*n)?;
|
self.activate_tab_relative(*n)?;
|
||||||
|
@ -60,6 +60,7 @@ pub enum KeyAssignment {
|
|||||||
ToggleFullScreen,
|
ToggleFullScreen,
|
||||||
Copy,
|
Copy,
|
||||||
Paste,
|
Paste,
|
||||||
|
PastePrimarySelection,
|
||||||
ActivateTabRelative(isize),
|
ActivateTabRelative(isize),
|
||||||
IncreaseFontSize,
|
IncreaseFontSize,
|
||||||
DecreaseFontSize,
|
DecreaseFontSize,
|
||||||
|
Loading…
Reference in New Issue
Block a user