MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / copy_selection

Method copy_selection

crates/opencode-tui/src/app/app.rs:1818–1839  ·  view source on GitHub ↗

Copy the current screen selection to clipboard and show a toast.

(&mut self)

Source from the content-addressed store, hash-verified

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() {

Callers 1

handle_eventMethod · 0.80

Calls 7

get_selected_textMethod · 0.80
is_emptyMethod · 0.80
showMethod · 0.80
is_activeMethod · 0.45
cloneMethod · 0.45
getMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected