MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / read_text

Method read_text

crates/opencode-tui/src/ui/clipboard.rs:29–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27 }
28
29 pub fn read_text() -> anyhow::Result<String> {
30 if cfg!(target_os = "macos") {
31 return read_with_command("pbpaste", &[]);
32 }
33
34 if cfg!(target_os = "windows") {
35 return read_with_command(
36 "powershell",
37 &["-NoProfile", "-Command", "Get-Clipboard -Raw"],
38 );
39 }
40
41 if std::env::var("WAYLAND_DISPLAY").is_ok() {
42 if let Ok(text) = read_with_command("wl-paste", &["-n"]) {
43 return Ok(text);
44 }
45 }
46
47 if let Ok(text) = read_with_command("xclip", &["-selection", "clipboard", "-o"]) {
48 return Ok(text);
49 }
50
51 read_with_command("xsel", &["--clipboard", "--output"])
52 }
53
54 pub fn write_text(text: &str) -> anyhow::Result<()> {
55 // Always attempt OSC 52 first — works over SSH when the terminal

Callers

nothing calls this directly

Calls 1

read_with_commandFunction · 0.85

Tested by

no test coverage detected