mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
tui: fix clipboard copy functionality in tmux sessions
- Add proper tmux DCS passthrough wrapper for OSC52 sequences - Users can now copy text to clipboard when running TUI inside tmux - Previously clipboard copy would fail in SSH/tmux environments
This commit is contained in:
parent
f27cec5461
commit
8f3c87ffdb
2 changed files with 5 additions and 4 deletions
|
|
@ -186,7 +186,11 @@ function App(props: { onExit: () => void }) {
|
|||
onMouseUp={async () => {
|
||||
const text = renderer.getSelection()?.getSelectedText()
|
||||
if (text && text.length > 0) {
|
||||
console.log("copying", text)
|
||||
const base64 = Buffer.from(text).toString("base64")
|
||||
const osc52 = `\x1b]52;c;${base64}\x07`
|
||||
const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
|
||||
/* @ts-expect-error */
|
||||
renderer.writeOut(finalOsc52)
|
||||
await Clipboard.copy(text)
|
||||
renderer.clearSelection()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,9 +112,6 @@ export namespace Clipboard {
|
|||
})
|
||||
|
||||
export async function copy(text: string): Promise<void> {
|
||||
const base64 = Buffer.from(text).toString("base64")
|
||||
const osc52 = `\x1b]52;c;${base64}\x07`
|
||||
process.stdout.write(osc52)
|
||||
await getCopyMethod()(text)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue