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
This commit is contained in:
1 parent
73c2441abc
commit
c24153db86
32 files changed
+451
-165
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
EditBufferRenderable,
|
||||
TextBufferRenderable,
|
||||
TextTableRenderable,
|
||||
type RGBA,
|
||||
type Selection,
|
||||
} from "@opentui/core"
|
||||
|
||||
export interface SelectionColors {
|
||||
background: RGBA
|
||||
foreground: RGBA
|
||||
}
|
||||
|
||||
export function applySelectionColors(selection: Selection, colors: SelectionColors): void {
|
||||
for (const renderable of selection.selectedRenderables) {
|
||||
if (renderable.isDestroyed) continue
|
||||
if (renderable instanceof TextBufferRenderable || renderable instanceof EditBufferRenderable) {
|
||||
renderable.selectionBg = colors.background
|
||||
renderable.selectionFg = colors.foreground
|
||||
} else if (renderable instanceof TextTableRenderable) {
|
||||
// OpenTUI 0.5.11 exposes table selection colors only at construction.
|
||||
// Update its retained palette without replacing streaming table cells.
|
||||
const table = renderable as unknown as { _selectionBg?: RGBA; _selectionFg?: RGBA }
|
||||
if (table._selectionBg === colors.background && table._selectionFg === colors.foreground) continue
|
||||
table._selectionBg = colors.background
|
||||
table._selectionFg = colors.foreground
|
||||
renderable.onSelectionChanged(selection)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user