Skip to content

Commit bded900

Browse files
authored
feat(desktop): Change Terminal's Cursor to Bar and Stop Blinking when not focused (#7402)
1 parent 9fd87e8 commit bded900

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/app/src/components/terminal.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const Terminal = (props: TerminalProps) => {
4545
let serializeAddon: SerializeAddon
4646
let fitAddon: FitAddon
4747
let handleResize: () => void
48+
let handleTextareaFocus: () => void
49+
let handleTextareaBlur: () => void
4850
let reconnect: number | undefined
4951
let disposed = false
5052

@@ -105,6 +107,7 @@ export const Terminal = (props: TerminalProps) => {
105107

106108
const t = new mod.Terminal({
107109
cursorBlink: true,
110+
cursorStyle: "bar",
108111
fontSize: 14,
109112
fontFamily: "IBM Plex Mono, monospace",
110113
allowTransparency: true,
@@ -170,6 +173,17 @@ export const Terminal = (props: TerminalProps) => {
170173

171174
t.open(container)
172175
container.addEventListener("pointerdown", handlePointerDown)
176+
177+
handleTextareaFocus = () => {
178+
t.options.cursorBlink = true
179+
}
180+
handleTextareaBlur = () => {
181+
t.options.cursorBlink = false
182+
}
183+
184+
t.textarea?.addEventListener("focus", handleTextareaFocus)
185+
t.textarea?.addEventListener("blur", handleTextareaBlur)
186+
173187
focusTerminal()
174188

175189
if (local.pty.buffer) {
@@ -242,6 +256,8 @@ export const Terminal = (props: TerminalProps) => {
242256
window.removeEventListener("resize", handleResize)
243257
}
244258
container.removeEventListener("pointerdown", handlePointerDown)
259+
term?.textarea?.removeEventListener("focus", handleTextareaFocus)
260+
term?.textarea?.removeEventListener("blur", handleTextareaBlur)
245261

246262
const t = term
247263
if (serializeAddon && props.onCleanup && t) {

0 commit comments

Comments
 (0)