mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 15:01:34 +08:00
fix(tui): Ctrl+C on in-input selection copies to clipboard instead of clearing
Before: textInput explicitly ignored Ctrl+C so the app-level handler took over — with no knowledge of the TextInput's own selection — and fell through to clearIn() whenever input had text. Selecting part of the composer and pressing Ctrl+C silently nuked everything you typed. Now: Ctrl+C with an active in-input selection writes the selected substring to the clipboard via OSC 52 and clears the selection. The original semantics (Ctrl+C with no selection → app-level interrupt/clear/die chain) are preserved by still returning early in that case.
This commit is contained in:
@@ -2,6 +2,8 @@ import type { InputEvent, Key } from '@hermes/ink'
|
||||
import * as Ink from '@hermes/ink'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
|
||||
import { writeOsc52Clipboard } from '../lib/osc52.js'
|
||||
|
||||
type InkExt = typeof Ink & {
|
||||
stringWidth: (s: string) => number
|
||||
useDeclaredCursor: (a: { line: number; column: number; active: boolean }) => (el: any) => void
|
||||
@@ -468,10 +470,22 @@ export function TextInput({
|
||||
return void emitPaste({ cursor: curRef.current, hotkey: true, text: '', value: vRef.current })
|
||||
}
|
||||
|
||||
if (k.ctrl && inp === 'c') {
|
||||
const range = selRange()
|
||||
|
||||
if (range) {
|
||||
writeOsc52Clipboard(vRef.current.slice(range.start, range.end))
|
||||
clearSel()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (
|
||||
k.upArrow ||
|
||||
k.downArrow ||
|
||||
(k.ctrl && inp === 'c') ||
|
||||
k.tab ||
|
||||
(k.shift && k.tab) ||
|
||||
k.pageUp ||
|
||||
|
||||
Reference in New Issue
Block a user