Files
opentui/packages/core
Simon Klee acf13584be native: check highlight counts after shrinking setText (#1601)
native: drop highlights on removed lines when replacing text
setText kept user highlights on every stored line, also on lines past
the
new line count. getHighlightCount and getLineHighlights reported them,
and
text that grew back into such a line (append) was colored by them.

setPlainText now builds the kept highlight lists during preparation, for
lines below the new line count only, and swaps them in when it publishes
the text, like the styled-text path. The lists past the new end are
freed
with the old storage. This replaces the in-place internal-highlight
filter.
The fix covers setText, setTextFromMemId*, setTextFromMemRangeWithUndo
(EditBuffer.replaceText), and replaceText (EditBuffer.setText).

Source additions (net -5 lines): the staged highlight lists and their
cleanup hold the kept highlights until publication, and one comment
states
the line-count bound.

Fixes https://github.com/anomalyco/opentui/issues/1588
2026-10-09 21:33:25 +02:00
..

OpenTUI logo

npm version Core build status

OpenTUI is a library to build terminal user interfaces.

  • It is written in Zig.
  • You write TypeScript directly or through React and Solid.
  • You arrange boxes and text with flexbox.
  • You add selects, inputs, and scroll boxes with keyboard and mouse controls.
  • You can play sounds, show images, and render 3D graphics.

OpenCode uses OpenTUI in production for millions of users.

Website | Documentation | Packages

OpenTUI Core

@opentui/core supplies the renderer and TypeScript API. You use imperative renderables and events directly. The TypeScript packages call native Zig through an internal foreign function interface (FFI) boundary.

import { TextRenderable, createCliRenderer } from "@opentui/core"

const renderer = await createCliRenderer({ exitOnCtrlC: true })

renderer.root.add(new TextRenderable(renderer, { content: "Hello, OpenTUI!" }))

exitOnCtrlC: true calls renderer.destroy() when the user presses Ctrl+C. The code that creates the renderer must call renderer.destroy() on every other shutdown path.

Install the package:

bun add @opentui/core

Then build your first app with the quickstart.

Runtime and platform support

@opentui/core runs on Bun 1.3.14 or later, or on Node.js 26.4.0 or later with ECMAScript modules (ESM) and --experimental-ffi.

Use Bun 1.4.0 or later on native Windows arm64.

The native ABI and the generated platform packages, such as @opentui/core-linux-x64, are internal distribution surfaces, not application APIs.

AI agent skill

Install the OpenTUI documentation as a skill for your AI coding assistant with npx skills:

npx skills add anomalyco/opentui --skill opentui

Add -g to install the skill globally.

License

OpenTUI is licensed under the MIT License.