Files
nanobot/tui/src/composer/textarea.ts
T
chengyongru c24153db86 fix(ui): keep theme text and selections readable (#6226)
* fix(ui): keep theme text and selections readable

* fix(tui): theme the blank composer cursor cell

* refactor(webui): centralize diff theme colors

* fix(tui): keep conversation selections readable

* fix(ui): preserve nested syntax colors and selection lifetimes
2026-10-15 15:21:28 +08:00

20 lines
799 B
TypeScript

import { TextareaRenderable, type OptimizedBuffer } from "@opentui/core"
export class ComposerTextarea extends TextareaRenderable {
override renderCursor(buffer: OptimizedBuffer): void {
if (this.focused && this.showCursor) {
const { visualCol, visualRow } = this.visualCursor
const x = this.x + visualCol
const y = this.y + visualRow
if (x >= 0 && x < buffer.width && y >= 0 && y < buffer.height) {
const index = y * buffer.width + x
const { char, fg } = buffer.buffers
// OpenTUI clears unused editor cells with a white foreground. Hosts
// that draw a cursor by reversing the cell use that color as its fill.
if (char[index] === 32) fg.set(this.textColor.buffer, index * 4)
}
}
super.renderCursor(buffer)
}
}