Merge aed42472ac into ae614d919f
commit
6fc11c1555
|
|
@ -1,4 +1,14 @@
|
|||
import { BoxRenderable, TextareaRenderable, MouseEvent, PasteEvent, decodePasteBytes, t, dim, fg } from "@opentui/core"
|
||||
import {
|
||||
BoxRenderable,
|
||||
TextareaRenderable,
|
||||
MouseEvent,
|
||||
MouseButton,
|
||||
PasteEvent,
|
||||
decodePasteBytes,
|
||||
t,
|
||||
dim,
|
||||
fg,
|
||||
} from "@opentui/core"
|
||||
import { createEffect, createMemo, onMount, createSignal, onCleanup, on, Show, Switch, Match } from "solid-js"
|
||||
import "opentui-spinner/solid"
|
||||
import path from "path"
|
||||
|
|
@ -1084,7 +1094,15 @@ export function Prompt(props: PromptProps) {
|
|||
input.cursorColor = theme.text
|
||||
}, 0)
|
||||
}}
|
||||
onMouseDown={(r: MouseEvent) => r.target?.focus()}
|
||||
onMouseDown={async (r: MouseEvent) => {
|
||||
r.target?.focus()
|
||||
if (r.button !== MouseButton.MIDDLE) return
|
||||
if (props.disabled) return
|
||||
r.preventDefault()
|
||||
const text = await Clipboard.readPrimary()
|
||||
if (!text || !input || input.isDestroyed) return
|
||||
input.insertText(text)
|
||||
}}
|
||||
focusedBackgroundColor={theme.backgroundElement}
|
||||
cursorColor={theme.text}
|
||||
syntaxStyle={syntax()}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,22 @@ export namespace Clipboard {
|
|||
}
|
||||
}
|
||||
|
||||
export async function readPrimary(): Promise<string | undefined> {
|
||||
if (platform() !== "linux") return
|
||||
if (process.env["WAYLAND_DISPLAY"] && which("wl-paste")) {
|
||||
const result = await Process.text(["wl-paste", "--primary", "--no-newline"], { nothrow: true })
|
||||
if (result.text) return result.text
|
||||
}
|
||||
if (which("xclip")) {
|
||||
const result = await Process.text(["xclip", "-selection", "primary", "-o"], { nothrow: true })
|
||||
if (result.text) return result.text
|
||||
}
|
||||
if (which("xsel")) {
|
||||
const result = await Process.text(["xsel", "--primary", "--output"], { nothrow: true })
|
||||
if (result.text) return result.text
|
||||
}
|
||||
}
|
||||
|
||||
const getCopyMethod = lazy(() => {
|
||||
const os = platform()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue