|
@@ -10,6 +10,7 @@ import { useSDK } from "@/context/sdk"
|
|
|
import { useServer } from "@/context/server"
|
|
import { useServer } from "@/context/server"
|
|
|
import { monoFontFamily, useSettings } from "@/context/settings"
|
|
import { monoFontFamily, useSettings } from "@/context/settings"
|
|
|
import type { LocalPTY } from "@/context/terminal"
|
|
import type { LocalPTY } from "@/context/terminal"
|
|
|
|
|
+import { terminalAttr, terminalProbe } from "@/testing/terminal"
|
|
|
import { disposeIfDisposable, getHoveredLinkText, setOptionIfSupported } from "@/utils/runtime-adapters"
|
|
import { disposeIfDisposable, getHoveredLinkText, setOptionIfSupported } from "@/utils/runtime-adapters"
|
|
|
import { terminalWriter } from "@/utils/terminal-writer"
|
|
import { terminalWriter } from "@/utils/terminal-writer"
|
|
|
|
|
|
|
@@ -160,6 +161,7 @@ export const Terminal = (props: TerminalProps) => {
|
|
|
let container!: HTMLDivElement
|
|
let container!: HTMLDivElement
|
|
|
const [local, others] = splitProps(props, ["pty", "class", "classList", "autoFocus", "onConnect", "onConnectError"])
|
|
const [local, others] = splitProps(props, ["pty", "class", "classList", "autoFocus", "onConnect", "onConnectError"])
|
|
|
const id = local.pty.id
|
|
const id = local.pty.id
|
|
|
|
|
+ const probe = terminalProbe(id)
|
|
|
const restore = typeof local.pty.buffer === "string" ? local.pty.buffer : ""
|
|
const restore = typeof local.pty.buffer === "string" ? local.pty.buffer : ""
|
|
|
const restoreSize =
|
|
const restoreSize =
|
|
|
restore &&
|
|
restore &&
|
|
@@ -326,6 +328,9 @@ export const Terminal = (props: TerminalProps) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onMount(() => {
|
|
onMount(() => {
|
|
|
|
|
+ probe.init()
|
|
|
|
|
+ cleanups.push(() => probe.drop())
|
|
|
|
|
+
|
|
|
const run = async () => {
|
|
const run = async () => {
|
|
|
const loaded = await loadGhostty()
|
|
const loaded = await loadGhostty()
|
|
|
if (disposed) return
|
|
if (disposed) return
|
|
@@ -353,7 +358,13 @@ export const Terminal = (props: TerminalProps) => {
|
|
|
}
|
|
}
|
|
|
ghostty = g
|
|
ghostty = g
|
|
|
term = t
|
|
term = t
|
|
|
- output = terminalWriter((data, done) => t.write(data, done))
|
|
|
|
|
|
|
+ output = terminalWriter((data, done) =>
|
|
|
|
|
+ t.write(data, () => {
|
|
|
|
|
+ probe.render(data)
|
|
|
|
|
+ probe.settle()
|
|
|
|
|
+ done?.()
|
|
|
|
|
+ }),
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
t.attachCustomKeyEventHandler((event) => {
|
|
t.attachCustomKeyEventHandler((event) => {
|
|
|
const key = event.key.toLowerCase()
|
|
const key = event.key.toLowerCase()
|
|
@@ -441,10 +452,6 @@ export const Terminal = (props: TerminalProps) => {
|
|
|
startResize()
|
|
startResize()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // t.onScroll((ydisp) => {
|
|
|
|
|
- // console.log("Scroll position:", ydisp)
|
|
|
|
|
- // })
|
|
|
|
|
-
|
|
|
|
|
const once = { value: false }
|
|
const once = { value: false }
|
|
|
let closing = false
|
|
let closing = false
|
|
|
|
|
|
|
@@ -460,6 +467,7 @@ export const Terminal = (props: TerminalProps) => {
|
|
|
ws = socket
|
|
ws = socket
|
|
|
|
|
|
|
|
const handleOpen = () => {
|
|
const handleOpen = () => {
|
|
|
|
|
+ probe.connect()
|
|
|
local.onConnect?.()
|
|
local.onConnect?.()
|
|
|
scheduleSize(t.cols, t.rows)
|
|
scheduleSize(t.cols, t.rows)
|
|
|
}
|
|
}
|
|
@@ -560,6 +568,7 @@ export const Terminal = (props: TerminalProps) => {
|
|
|
<div
|
|
<div
|
|
|
ref={container}
|
|
ref={container}
|
|
|
data-component="terminal"
|
|
data-component="terminal"
|
|
|
|
|
+ {...{ [terminalAttr]: id }}
|
|
|
data-prevent-autofocus
|
|
data-prevent-autofocus
|
|
|
tabIndex={-1}
|
|
tabIndex={-1}
|
|
|
style={{ "background-color": terminalColors().background }}
|
|
style={{ "background-color": terminalColors().background }}
|