Copy the current screen selection to clipboard and show a toast.
(&mut self)
| 1816 | |
| 1817 | /// Copy the current screen selection to clipboard and show a toast. |
| 1818 | fn copy_selection(&mut self) { |
| 1819 | if !self.selection.is_active() { |
| 1820 | return; |
| 1821 | } |
| 1822 | let lines = self.screen_lines.clone(); |
| 1823 | let text = self |
| 1824 | .selection |
| 1825 | .get_selected_text(|row| lines.get(row as usize).cloned()); |
| 1826 | if !text.is_empty() { |
| 1827 | match Clipboard::write_text(&text) { |
| 1828 | Ok(()) => { |
| 1829 | self.toast |
| 1830 | .show(ToastVariant::Info, "Copied to clipboard", 2000); |
| 1831 | } |
| 1832 | Err(err) => { |
| 1833 | self.toast |
| 1834 | .show(ToastVariant::Error, &format!("Copy failed: {}", err), 3000); |
| 1835 | } |
| 1836 | } |
| 1837 | } |
| 1838 | self.selection.clear(); |
| 1839 | } |
| 1840 | |
| 1841 | fn current_session_id(&self) -> Option<String> { |
| 1842 | match self.context.current_route() { |
no test coverage detected