okami.mom/ultraviolet

git clone https://git.nkp.pet/okami.mom/ultraviolet

Ayman Bagabasdocs: update README and tutorial5027f0c

main
1.4 KiB46 linesraw
1// Package uv (Ultraviolet) provides primitives for building terminal user
2// interfaces in Go.
3//
4// It offers cell-based screen buffers, a diffing terminal renderer, cross-platform
5// input decoding (keyboard, mouse, paste, focus, resize), and a windowing model
6// with off-screen buffers. Ultraviolet powers Bubble Tea v2 and Lip Gloss v2.
7//
8// # Getting Started
9//
10// Create a terminal, get its screen, and run an event loop:
11//
12//	t := uv.DefaultTerminal()
13//	scr := t.Screen()
14//	scr.EnterAltScreen()
15//
16//	if err := t.Start(); err != nil {
17//	    log.Fatal(err)
18//	}
19//	defer t.Stop()
20//
21//	for ev := range t.Events() {
22//	    switch ev := ev.(type) {
23//	    case uv.WindowSizeEvent:
24//	        scr.Resize(ev.Width, ev.Height)
25//	    case uv.KeyPressEvent:
26//	        if ev.MatchString("q") { return }
27//	    }
28//	}
29//
30// # Rendering
31//
32// Drawing is a two-step process. [TerminalScreen.Render] diffs the screen and
33// writes escape sequences to an internal buffer. [TerminalScreen.Flush] sends
34// the buffer to the terminal—this is the only method that performs real I/O.
35//
36//	scr.Render()
37//	scr.Flush()
38//
39// Use the screen package for high-level drawing helpers like
40// [screen.Context.DrawString] and [screen.Clear].
41//
42// # Packages
43//
44//   - screen — drawing context and screen manipulation helpers
45//   - layout — constraint-based layout solver (Cassowary algorithm)
46package uv