diff options
| author | apexo <mail@apexo.de> | 2022-08-12 17:21:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-12 17:21:58 +0200 |
| commit | 2cb6e20d626848e30fd4dc4296e625bfe73e5212 (patch) | |
| tree | 1b99ec403a7a0c45207fb1716d54fc5e04046d0f | |
| parent | style(comment): update flake-lock frequency comment (diff) | |
| download | sl0ppij-2cb6e20d626848e30fd4dc4296e625bfe73e5212.tar.gz sl0ppij-2cb6e20d626848e30fd4dc4296e625bfe73e5212.tar.xz sl0ppij-2cb6e20d626848e30fd4dc4296e625bfe73e5212.zip | |
Terminal compatibility: forward OSC52 events (#1644)
Fixes #1199
Co-authored-by: Christian Schubert <christian.schubert01@sap.com>
| -rw-r--r-- | zellij-server/src/panes/grid.rs | 10 | ||||
| -rw-r--r-- | zellij-server/src/panes/terminal_pane.rs | 4 | ||||
| -rw-r--r-- | zellij-server/src/tab/mod.rs | 7 |
3 files changed, 19 insertions, 2 deletions
diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs index a238f087..fc815afd 100644 --- a/zellij-server/src/panes/grid.rs +++ b/zellij-server/src/panes/grid.rs @@ -342,6 +342,7 @@ pub struct Grid { scrollback_buffer_lines: usize, pub mouse_mode: bool, pub search_results: SearchResult, + pub pending_clipboard_update: Option<String>, } impl Debug for Grid { @@ -447,6 +448,7 @@ impl Grid { character_cell_size, search_results: Default::default(), sixel_grid, + pending_clipboard_update: None, } } pub fn render_full_viewport(&mut self) { @@ -1890,8 +1892,12 @@ impl Perform for Grid { b"?" => { // TBD: paste from own clipboard - currently unsupported }, - _base64 => { - // TBD: copy to own clipboard - currently unsupported + base64 => { + if let Ok(bytes) = base64::decode(base64) { + if let Ok(string) = String::from_utf8(bytes) { + self.pending_clipboard_update = Some(string); + } + }; }, } }, diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index 666260e6..6f34a864 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -484,6 +484,10 @@ impl Pane for TerminalPane { self.grid.pending_messages_to_pty.drain(..).collect() } + fn drain_clipboard_update(&mut self) -> Option<String> { + self.grid.pending_clipboard_update.take() + } + fn start_selection(&mut self, start: &Position, _client_id: ClientId) { self.grid.start_selection(start); self.set_should_render(true); diff --git a/zellij-server/src/tab/mod.rs b/zellij-server/src/tab/mod.rs index eb611a1e..44c2a480 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -258,6 +258,9 @@ pub trait Pane { // we should probably refactor away from this trait at some point vec![] } + fn drain_clipboard_update(&mut self) -> Option<String> { + None + } fn render_full_viewport(&mut self) {} fn relative_position(&self, position_on_screen: &Position) -> Position { position_on_screen.relative_to(self.get_content_y(), self.get_content_x()) @@ -955,9 +958,13 @@ impl Tab { { terminal_output.handle_pty_bytes(bytes); let messages_to_pty = terminal_output.drain_messages_to_pty(); + let clipboard_update = terminal_output.drain_clipboard_update(); for message in messages_to_pty { self.write_to_pane_id(message, PaneId::Terminal(pid)); } + if let Some(string) = clipboard_update { + self.write_selection_to_clipboard(&string); + } } } pub fn write_to_terminals_on_current_tab(&mut self, input_bytes: Vec<u8>) { |
