mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Merge 2ea7fb61a0 into 83397ebde2
This commit is contained in:
commit
7d06e6b09e
5 changed files with 45 additions and 1 deletions
|
|
@ -125,6 +125,11 @@ export function Prompt(props: PromptProps) {
|
|||
const wide = createMemo(() => dimensions().width > 120)
|
||||
const { theme, syntax } = useTheme()
|
||||
|
||||
const cursorStyle = createMemo(() => ({
|
||||
style: "block" as const,
|
||||
blinking: sync.data.config.tui?.cursor_blinking ?? true,
|
||||
}))
|
||||
|
||||
function promptModelWarning() {
|
||||
toast.show({
|
||||
variant: "warning",
|
||||
|
|
@ -323,6 +328,7 @@ export function Prompt(props: PromptProps) {
|
|||
createEffect(() => {
|
||||
if (props.disabled) input.cursorColor = theme.backgroundElement
|
||||
if (!props.disabled) input.cursorColor = theme.text
|
||||
input.cursorStyle = cursorStyle()
|
||||
})
|
||||
|
||||
const [store, setStore] = createStore<{
|
||||
|
|
@ -877,11 +883,13 @@ export function Prompt(props: PromptProps) {
|
|||
input = r
|
||||
setTimeout(() => {
|
||||
input.cursorColor = theme.text
|
||||
input.cursorStyle = cursorStyle()
|
||||
}, 0)
|
||||
}}
|
||||
onMouseDown={(r: MouseEvent) => r.target?.focus()}
|
||||
focusedBackgroundColor={theme.backgroundElement}
|
||||
cursorColor={theme.text}
|
||||
cursorStyle={cursorStyle()}
|
||||
syntaxStyle={syntax()}
|
||||
/>
|
||||
<Show when={tall()}>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { TextareaRenderable, TextAttributes } from "@opentui/core"
|
||||
import { useTheme } from "../context/theme"
|
||||
import { useDialog, type DialogContext } from "./dialog"
|
||||
import { onMount, type JSX } from "solid-js"
|
||||
import { useSync } from "../context/sync"
|
||||
import { createMemo, onMount, type JSX } from "solid-js"
|
||||
import { useKeyboard } from "@opentui/solid"
|
||||
|
||||
export type DialogPromptProps = {
|
||||
|
|
@ -16,8 +17,14 @@ export type DialogPromptProps = {
|
|||
export function DialogPrompt(props: DialogPromptProps) {
|
||||
const dialog = useDialog()
|
||||
const { theme } = useTheme()
|
||||
const sync = useSync()
|
||||
let textarea: TextareaRenderable
|
||||
|
||||
const cursorStyle = createMemo(() => ({
|
||||
style: "block" as const,
|
||||
blinking: sync.data.config.tui?.cursor_blinking ?? true,
|
||||
}))
|
||||
|
||||
useKeyboard((evt) => {
|
||||
if (evt.name === "return") {
|
||||
props.onConfirm?.(textarea.plainText)
|
||||
|
|
@ -54,6 +61,7 @@ export function DialogPrompt(props: DialogPromptProps) {
|
|||
textColor={theme.text}
|
||||
focusedTextColor={theme.text}
|
||||
cursorColor={theme.text}
|
||||
cursorStyle={cursorStyle()}
|
||||
/>
|
||||
</box>
|
||||
<box paddingBottom={1} gap={1} flexDirection="row">
|
||||
|
|
|
|||
|
|
@ -584,6 +584,7 @@ export namespace Config {
|
|||
.enum(["auto", "stacked"])
|
||||
.optional()
|
||||
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
|
||||
cursor_blinking: z.boolean().optional().describe("Enable or disable cursor blinking in the prompt input box"),
|
||||
})
|
||||
|
||||
export const Layout = z.enum(["auto", "stretch"]).meta({
|
||||
|
|
|
|||
|
|
@ -533,3 +533,26 @@ test("deduplicates duplicate plugins from global and local configs", async () =>
|
|||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("handles TUI cursor blinking configuration", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
await Bun.write(
|
||||
path.join(dir, "opencode.json"),
|
||||
JSON.stringify({
|
||||
$schema: "https://opencode.ai/config.json",
|
||||
tui: {
|
||||
cursor_blinking: false,
|
||||
},
|
||||
}),
|
||||
)
|
||||
},
|
||||
})
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const config = await Config.get()
|
||||
expect(config.tui?.cursor_blinking).toBe(false)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1394,6 +1394,10 @@ export type Config = {
|
|||
* Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column
|
||||
*/
|
||||
diff_style?: "auto" | "stacked"
|
||||
/**
|
||||
* Enable or disable cursor blinking in the prompt input box
|
||||
*/
|
||||
cursor_blinking?: boolean
|
||||
}
|
||||
/**
|
||||
* Command configuration, see https://opencode.ai/docs/commands
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue