Documentation
¶
Overview ¶
Package screen draws the terminal UI's area below the conversation, and writes the conversation above it, as Codex's TUI does (ADR 0033).
The conversation is the terminal's own scrollback: lines written once, above the area, never drawn again. The area (what is being written, the calls under way, the input, the status line) is drawn again at each frame. The area's place on the terminal is kept here:
- The conversation's lines are written in a scroll region from the top of the terminal to just above the area: only that region scrolls, and the area stays where it is.
- Where the area is not at the bottom of the terminal (a terminal just started, the area got shorter), it is first pushed down by reverse scrolls, by the lines to write (to the bottom at most).
- The area getting taller than the room below it scrolls the terminal up, its bottom at the terminal's bottom. Getting shorter at the bottom, it stays there: what is above it moves down as much, blank rows left at the terminal's top (Codex leaves its bottom up until lines written push it down; ADR 0033, 追記). Getting shorter not at the bottom, its top stays: the next lines written push it down.
So, once the terminal is full, the area's bottom (the input, the status line) stays at the terminal's bottom.
Index ¶
- func Size(out *os.File) (w, h int, err error)
- type Cursor
- type Screen
- func (s *Screen) Clear()
- func (s *Screen) Draw(lines []string, cur *Cursor)
- func (s *Screen) DrawAlt(lines []string, cur *Cursor)
- func (s *Screen) Insert(lines []string)
- func (s *Screen) Place(row int)
- func (s *Screen) Placed() bool
- func (s *Screen) Plain()
- func (s *Screen) Resize(w, h int)
- func (s *Screen) Retake()
- func (s *Screen) Size() (w, h int)
- func (s *Screen) Stop()
- type Terminal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cursor ¶
Cursor is where the cursor is shown, in the area (nil: hidden), its colour ("#rrggbb", "" the terminal's) and its style (DECSCUSR: 1 a blinking block, 2 a steady one, ..., 0 the terminal's).
type Screen ¶
type Screen struct {
// Term is the terminal taken (raw mode, modes), given back to a command
// the UI runs in it and taken again (Retake).
Term *Terminal
// NoRegions: the terminal's scroll regions are not to be relied on
// (Zellij): lines are written where the area is, and it is drawn again
// under them, as Codex writes there.
NoRegions bool
// Trace, if set, is given each write and the area's place after it
// (KAIROCODE_TUI_TRACE: what the terminal was sent, to find out what it
// did otherwise than the tests' terminal).
Trace io.Writer
// contains filtered or unexported fields
}
Screen draws on a terminal of Width × Height cells.
func (*Screen) Clear ¶
func (s *Screen) Clear()
Clear takes the area away (the UI leaving): the cursor is left where it began.
func (*Screen) Draw ¶
Draw draws the area: lines (each at most as wide as the terminal), the cursor at cur.
func (*Screen) DrawAlt ¶
DrawAlt draws a screen of its own (the terminal's alternate screen), lines from its top; Draw goes back to the area.
func (*Screen) Place ¶
Place says where the cursor is (its row, 0-based), as the terminal told it: where the area begins when the UI starts. After a resize, it is where the cell the cursor was left on went: the area's old self begins as many rows above as its lines before that cell now take, and is cleared from there (a terminal that wrapped them again has them take more rows).
func (*Screen) Plain ¶
func (s *Screen) Plain()
Plain has the screen write as it is, its colours not made to fit the terminal (tests).
func (*Screen) Resize ¶
Resize says the terminal's new size. The terminal may have moved what it shows (most wrap its lines again): the area's place is not known until the terminal tells where the cursor went (Place), and it is drawn again whole there.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal is the terminal the UI takes: its input in raw mode.