Documentation
¶
Overview ¶
Package kite builds terminal user interfaces around a logical DOM. Input events travel through that tree in capture, target, and bubble phases. Each frame, the engine resolves styles, lays out elements in terminal cells, and paints the result to the application's chosen backend.
For example, to run a mounted element with the backend/uv terminal backend:
func run(ctx context.Context, root dom.Element) error {
b, err := uv.New()
if err != nil {
return err
}
app := kite.New(b, kite.WithMouseMode(kite.MouseModeTrack))
app.Mount(root)
return app.Run(ctx)
}
Applications choose their own exit keys or cancel the context to stop Run. Use element and style to build the interface, event to handle input, and dom to navigate the document. The engine, backend, and terminal packages expose the runtime and its host interfaces; testenv runs it without a physical TTY.
Optional packages include extras/kitex for reactive components, extras/trail for inline CLIs, extras/kites for shared state, extras/wind for async data, extras/flight for navigation, extras/form for forms, extras/stage for component previews, extras/clipboard for native clipboard access, and devtools for inspection.
Example ¶
package main
import (
"fmt"
"github.com/masterkeysrd/kite"
"github.com/masterkeysrd/kite/backend/mock"
"github.com/masterkeysrd/kite/element"
)
func main() {
b := mock.New(5, 1)
app := kite.New(b, kite.WithMouseMode(kite.MouseModeClick))
defer app.Stop()
app.Mount(element.Box("Ready"))
app.Frame()
screen := b.LastFrame().Surface
for x := range screen.Bounds().Size.Width {
fmt.Print(screen.CellAt(x, 0).Content)
}
fmt.Println()
}
Output: Ready
Index ¶
- Constants
- type Backend
- type Clipboard
- type Clock
- type Document
- type Engine
- type MouseMode
- type Option
- func WithClipboard(cb Clipboard) Option
- func WithClock(clk Clock) Option
- func WithInline(enabled bool) Option
- func WithMouseMode(mode MouseMode) Option
- func WithOptions(opts Options) Option
- func WithProfiler(enabled bool) Option
- func WithShutdownTimeout(d time.Duration) Option
- func WithWorkers(n int) Option
- type Options
- type Terminal
- type Timer
Examples ¶
Constants ¶
const ( // MouseModeOff disables mouse reporting. MouseModeOff = engine.MouseModeOff // MouseModeClick reports clicks only. MouseModeClick = engine.MouseModeClick // MouseModeDrag reports clicks and motion while a button is held (default). MouseModeDrag = engine.MouseModeDrag // MouseModeTrack reports all mouse motion, including hover. MouseModeTrack = engine.MouseModeTrack )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*config)
Option configures an engine before it starts.
func WithClipboard ¶
WithClipboard selects the clipboard provider used by the document.
func WithInline ¶
WithInline selects inline rendering instead of the alternate screen.
func WithMouseMode ¶
WithMouseMode selects which mouse events the terminal reports.
func WithOptions ¶
WithOptions replaces the engine options without changing the mouse mode. Pass it first to use opts as a base for subsequent options.
func WithProfiler ¶
WithProfiler enables or disables frame profiling at startup.
func WithShutdownTimeout ¶
WithShutdownTimeout sets the shutdown timeout for pending work.
func WithWorkers ¶
WithWorkers sets the size of the background worker pool.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package animation interpolates styles and custom values on the host frame clock.
|
Package animation interpolates styles and custom values on the host frame clock. |
|
Package backend defines Kite's interface to a terminal or other output device.
|
Package backend defines Kite's interface to a terminal or other output device. |
|
mock
Package mock provides a headless Kite backend that records frames and accepts synthetic input so tests can exercise a UI without a terminal.
|
Package mock provides a headless Kite backend that records frames and accepts synthetic input so tests can exercise a UI without a terminal. |
|
uv
Package uv implements Kite's terminal backend using Ultraviolet to render frames and receive input from a terminal.
|
Package uv implements Kite's terminal backend using Ultraviolet to render frames and receive input from a terminal. |
|
wasm
Package wasm embeds Kite and Kitex applications in an HTML canvas.
|
Package wasm embeds Kite and Kitex applications in an HTML canvas. |
|
Package cursor translates between text offsets and terminal cells.
|
Package cursor translates between text offsets and terminal cells. |
|
Package devtools provides standard developer tools for Kite applications, including an X-Ray mode for visual debugging and a web-based DOM inspector.
|
Package devtools provides standard developer tools for Kite applications, including an X-Ray mode for visual debugging and a web-based DOM inspector. |
|
inspector
Package inspector captures snapshots of a running Kite application's DOM, layout fragments, and element styles for the DevTools inspector.
|
Package inspector captures snapshots of a running Kite application's DOM, layout fragments, and element styles for the DevTools inspector. |
|
Package dom defines the interfaces for Kite's logical document tree.
|
Package dom defines the interfaces for Kite's logical document tree. |
|
Package element provides containers, text, form controls, and overlays for building a Kite document.
|
Package element provides containers, text, form controls, and overlays for building a Kite document. |
|
Package engine runs Kite applications.
|
Package engine runs Kite applications. |
|
Package event defines Kite's UI events and listener interfaces.
|
Package event defines Kite's UI events and listener interfaces. |
|
examples
|
|
|
animation
command
|
|
|
app1
command
|
|
|
button
command
|
|
|
checkbox_radio
command
|
|
|
clipboard
command
|
|
|
demoutil
Package demoutil provides logging setup, exit-key bindings and shortcut bars for Kite examples.
|
Package demoutil provides logging setup, exit-key bindings and shortcut bars for Kite examples. |
|
dialog
command
|
|
|
flex
command
|
|
|
flight_demo
command
|
|
|
form_demo
command
|
|
|
grid
command
|
|
|
grid_animation
command
|
|
|
input
command
|
|
|
kites_demo
command
|
|
|
kitex_autocomplete_demo
command
|
|
|
kitex_context_demo
command
|
|
|
kitex_demo
command
|
|
|
kitex_effects_demo
command
|
|
|
kitex_hooks
command
|
|
|
kitex_ref_demo
command
|
|
|
list
command
|
|
|
opacity
command
|
|
|
overlay
command
|
|
|
overlay_tweaks
command
|
|
|
reducer
command
|
|
|
responsive
command
|
|
|
select
command
|
|
|
spatial_navigation
command
|
|
|
stage
command
|
|
|
table
command
|
|
|
textarea
command
|
|
|
trail_demo
command
|
|
|
wind_demo
command
|
|
|
extras
|
|
|
clipboard
Package clipboard provides a native clipboard for local Kite applications that need MIME formats beyond plain text.
|
Package clipboard provides a native clipboard for local Kite applications that need MIME formats beyond plain text. |
|
flight
Package flight implements a stack-based navigation system for Kitex applications.
|
Package flight implements a stack-based navigation system for Kitex applications. |
|
form
Package form provides a high-level form state and validation engine for Kite applications.
|
Package form provides a high-level form state and validation engine for Kite applications. |
|
kites
Package kites implements a lightweight, thread-safe external state store (similar to Zustand or Redux) for global state management outside of the VDOM tree.
|
Package kites implements a lightweight, thread-safe external state store (similar to Zustand or Redux) for global state management outside of the VDOM tree. |
|
kites/kitesdt
Package kitesdt provides the DevTools integration bridge and time-travel debugger mini-plugin for kites global state stores.
|
Package kitesdt provides the DevTools integration bridge and time-travel debugger mini-plugin for kites global state stores. |
|
kitex
Package kitex builds declarative Kite UIs from typed components and element constructors.
|
Package kitex builds declarative Kite UIs from typed components and element constructors. |
|
kitex/internal/genprops
command
|
|
|
kitex/kitexdt
Package kitexdt provides the DevTools integration bridge for kitex Virtual DOM.
|
Package kitexdt provides the DevTools integration bridge for kitex Virtual DOM. |
|
kitex/kitextest
Package kitextest provides a lightweight, React-Testing-Library-inspired test harness for rendering, querying, interacting with, and asserting on kitex VDOM components in a headless testenv environment.
|
Package kitextest provides a lightweight, React-Testing-Library-inspired test harness for rendering, querying, interacting with, and asserting on kitex VDOM components in a headless testenv environment. |
|
stage
Package stage provides an interactive, isolated component development stage and playground for kitex applications.
|
Package stage provides an interactive, isolated component development stage and playground for kitex applications. |
|
trail
Package trail runs Kitex components inline in the terminal without switching to an alternate screen.
|
Package trail runs Kitex components inline in the terminal without switching to an alternate screen. |
|
wind
Package wind implements an asynchronous data fetching and caching library for Kitex applications, inspired by React Query.
|
Package wind implements an asynchronous data fetching and caching library for Kitex applications, inspired by React Query. |
|
wind/winddt
Package winddt provides the DevTools integration bridge for wind async queries and streams.
|
Package winddt provides the DevTools integration bridge for wind async queries and streams. |
|
Package geom defines the geometric value types used throughout the Kite layout engine.
|
Package geom defines the geometric value types used throughout the Kite layout engine. |
|
internal
|
|
|
collections
Package collections provides order-preserving slice deletion for Kite internals.
|
Package collections provides order-preserving slice deletion for Kite internals. |
|
dom
Package dom implements Kite's public DOM interfaces.
|
Package dom implements Kite's public DOM interfaces. |
|
event
Package event dispatches events through the capture, target, and bubble phases and synthesizes UI events from raw backend input.
|
Package event dispatches events through the capture, target, and bubble phases and synthesizes UI events from raw backend input. |
|
focus
Package focus implements focus management for Kite.
|
Package focus implements focus management for Kite. |
|
focus/spatial
Package spatial ranks focusable elements by their position within the active focus scope.
|
Package spatial ranks focusable elements by their position within the active focus scope. |
|
layout
Package layout computes a fragment tree from render nodes, computed styles, and available space.
|
Package layout computes a fragment tree from render nodes, computed styles, and available space. |
|
layout/text
Package text shapes strings into grapheme clusters with terminal-cell widths and line-break opportunities for inline layout.
|
Package text shapes strings into grapheme clusters with terminal-cell widths and line-break opportunities for inline layout. |
|
paint
Package paint implements the paint phase of the Kite rendering pipeline.
|
Package paint implements the paint phase of the Kite rendering pipeline. |
|
render
Package render provides the core engine for maintaining the render tree.
|
Package render provides the core engine for maintaining the render tree. |
|
styler
Package styler implements the Kite style resolution engine.
|
Package styler implements the Kite style resolution engine. |
|
text
Package text provides the Unicode-aware gap buffer used by Kite's text controls for editing and caret movement.
|
Package text provides the Unicode-aware gap buffer used by Kite's text controls for editing and caret movement. |
|
Package key defines the key event types and modifier constants used by the Kite terminal UI engine.
|
Package key defines the key event types and modifier constants used by the Kite terminal UI engine. |
|
Package log provides structured logging for Kite without writing over the terminal UI.
|
Package log provides structured logging for Kite without writing over the terminal UI. |
|
Package promise provides a lightweight, generic Promise<T> implementation for asynchronous operations in the Kite terminal UI engine.
|
Package promise provides a lightweight, generic Promise<T> implementation for asynchronous operations in the Kite terminal UI engine. |
|
Package style defines layout and appearance properties for Kite elements.
|
Package style defines layout and appearance properties for Kite elements. |
|
Package terminal defines the host environment context exposed by a Kite document.
|
Package terminal defines the host environment context exposed by a Kite document. |
|
Package testenv provides an ergonomic testing environment for Kite components.
|
Package testenv provides an ergonomic testing environment for Kite components. |
|
Package trace provides Chrome Trace Event format instrumentation for the Kite engine.
|
Package trace provides Chrome Trace Event format instrumentation for the Kite engine. |