Documentation
¶
Overview ¶
Package term owns the terminal mode and the cell grid around the browser image. The image starts after two chrome rows and ends before the footer.
Index ¶
- Constants
- func ParseKittyGraphicsReply(s string) bool
- func QueryKittyGraphics(in *os.File, out interface{ ... }) bool
- type CellPixels
- type Event
- type EventKind
- type Geometry
- type MouseEvent
- type Screen
- func (s *Screen) BodyRows() int
- func (s *Screen) Chrome(lines []string)
- func (s *Screen) ClearBody()
- func (s *Screen) Close()
- func (s *Screen) Footer(text string)
- func (s *Screen) Header(text string)
- func (s *Screen) QueryPixels()
- func (s *Screen) Refresh() (rows, cols int)
- func (s *Screen) Size() (rows, cols int)
- func (s *Screen) Text(lines []string)
- func (s *Screen) WriteBody(draw func(io.Writer) error) error
Constants ¶
const ChromeRows = 2
ChromeRows is the fixed tab/navigation chrome above the page image.
Variables ¶
This section is empty.
Functions ¶
func ParseKittyGraphicsReply ¶ added in v0.2.3
ParseKittyGraphicsReply reports whether s contains an OK for the probe. Errors, including a file-medium refusal, are not support.
func QueryKittyGraphics ¶ added in v0.2.3
QueryKittyGraphics asks the terminal that draws this pane whether it accepts kitty graphics. It is a query, not an environment guess: a multiplexer can answer for the terminal actually attached to it, even when TERM names a plain xterm. Silence is a no; a late answer is ignored by ReadEvent as an APC.
Types ¶
type CellPixels ¶
CellPixels is the result of the CSI 14t/16t query.
func FallbackCellPixels ¶
func FallbackCellPixels(rows, cols int) CellPixels
FallbackCellPixels is the 8x16 estimate used when the terminal is not queried or does not answer.
func ParseCellPixels ¶
func ParseCellPixels(s string) (CellPixels, bool)
ParseCellPixels parses one or both of CSI 4;height;width t (text area) and CSI 6;height;width t (cell size).
func QueryCellPixels ¶
func QueryCellPixels(in *os.File, out interface{ Write([]byte) (int, error) }, rows, cols int) CellPixels
QueryCellPixels asks the terminal for its text-area and cell size. It is best-effort: a terminal that does not answer gets the 8x16 fallback.
func TerminalCellPixels ¶ added in v0.2.0
func TerminalCellPixels(in *os.File, rows, cols int) CellPixels
TerminalCellPixels obtains the kernel-reported terminal pixel extent when it is available. Pseudo terminals commonly leave it zero, in which case the conservative fallback is returned without reading stdin.
type Event ¶
type Event struct {
Kind EventKind
Rune rune
Mouse MouseEvent
Pixels CellPixels
}
Event is a key or terminal event.
type EventKind ¶
type EventKind int
EventKind is one parsed terminal input event.
const ( KeyText EventKind = iota KeyEnter KeyBackspace KeyEscape KeyUp KeyDown KeyLeft KeyRight KeyAltLeft KeyAltRight KeyAltF KeyCtrlL KeyCtrlR KeyCtrlC KeyCtrlQ KeyCtrlG KeyCtrlO KeyResize KeyMouse KeyCellPixels // KeyIgnored is terminal metadata that is not a key, such as an APC reply. KeyIgnored KeyTab )
type Geometry ¶
type Geometry struct {
Cols, Rows int
CellWidth int
CellHeight int
ContentTopRow int // 1-based terminal row where the page starts
ContentRows int // number of terminal rows occupied by the page image
ContentWidthPx int
ContentHeightPx int
}
Geometry maps terminal cells to browser CSS pixels.
func GeometryFor ¶
func GeometryFor(rows, cols int, p CellPixels) Geometry
GeometryFor builds the mapping for a terminal grid and optional pixel measurements.
func (Geometry) CellToPixel ¶
CellToPixel maps a 1-based terminal cell to the page viewport. Returns false when the point is outside the content area.
func (Geometry) CellToPixelClamped ¶ added in v0.2.0
CellToPixelClamped maps a 1-based terminal cell to the page viewport, clamping cells outside the content area to its nearest edge. A drag keeps producing motion after the pointer leaves the page area, and the page expects the pointer to keep tracking along the edge instead of freezing.
type MouseEvent ¶
type MouseEvent struct {
Button int
Col int
Row int
Press bool
Motion bool
Wheel int // -1 up, 1 down, 0 not a wheel
WheelX int // -1 left, 1 right; never reinterpret sideways touchpad drift as vertical
}
MouseEvent is one SGR mouse report.
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Screen switches the terminal into raw mode and an alternate screen.
func (*Screen) Chrome ¶ added in v0.2.0
Chrome draws exactly the two styled chrome lines. ANSI escapes are preserved verbatim; callers are responsible for keeping their visible width in bounds.
func (*Screen) Close ¶
func (s *Screen) Close()
Close restores the cursor, the main screen and the terminal mode.
func (*Screen) QueryPixels ¶ added in v0.2.0
func (s *Screen) QueryPixels()
QueryPixels asynchronously requests pane and cell pixel dimensions. Replies are consumed by ReadEvent, so this method never competes for stdin.