uv

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package uv implements Kite's terminal backend using Ultraviolet to render frames and receive input from a terminal. New() uses the default terminal. Pass WithInput and WithOutput to New to use session streams, WithEnviron to replace the process environment, and WithSize for initial PTY dimensions. For example, after accepting an SSH session with a PTY:

b, err := uv.New(uv.WithInput(session), uv.WithOutput(session),
	uv.WithEnviron([]string{"TERM=" + pty.Term}),
	uv.WithSize(pty.Window.Width, pty.Window.Height))
if err != nil { return err }

Forward each SSH window change with b.NotifyResize(win.Width, win.Height). NotifyResize is safe on another goroutine, including during shutdown. For blocking non-file streams, provide an io.ReadCloser whose Close unblocks Read. Restore may close that input after writing terminal reset sequences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend is the ultraviolet terminal backend for kite/x. It owns a uv.Terminal for input and a uv.TerminalScreen for output. EndFrame copies the painted Buffer to the TerminalScreen and signals the render goroutine to diff and flush.

func New

func New(options ...Option) (*Backend, error)

New creates a UV backend using the default terminal unless options override it.

func (*Backend) BeginFrame

func (b *Backend) BeginFrame() backend.Surface

BeginFrame allocates a fresh Buffer for the current terminal size.

func (*Backend) Bell

func (b *Backend) Bell()

func (*Backend) Caps

func (b *Backend) Caps() backend.Caps

Caps returns the terminal capabilities detected at startup.

func (*Backend) Clear

func (b *Backend) Clear()

Clear queues a terminal reset before subsequent inserts and frames.

func (*Backend) Clipboard

func (b *Backend) Clipboard() backend.Clipboard

func (*Backend) DumpState

func (b *Backend) DumpState()

func (*Backend) EndFrame

func (b *Backend) EndFrame() error

EndFrame hands the current Buffer to the render goroutine.

func (*Backend) Events

func (b *Backend) Events() <-chan backend.RawEvent

Events returns the terminal event channel.

func (*Backend) ExecIO

func (b *Backend) ExecIO() (io.Reader, io.Writer, io.Writer)

func (*Backend) InsertAbove

func (b *Backend) InsertAbove(buf *backend.Buffer)

InsertAbove inserts a rendered cell buffer permanently into the terminal scrollback above the active inline frame.

func (*Backend) InsertAboveForFrame

func (b *Backend) InsertAboveForFrame(buf *backend.Buffer)

InsertAboveForFrame queues static output without restoring a stale live frame. The engine commits the newly reconciled live frame after these inserts.

func (*Backend) NotifyResize

func (b *Backend) NotifyResize(width, height int)

NotifyResize reports a PTY window change. Pending changes may be coalesced.

func (*Backend) Resize

func (b *Backend) Resize(size geom.Size)

Resize updates the internal dimensions after a terminal resize event.

func (*Backend) Restore

func (b *Backend) Restore()

func (*Backend) Resume

func (b *Backend) Resume() error

func (*Backend) SetCursorColor

func (b *Backend) SetCursorColor(c color.Color)

func (*Backend) SetCursorPos

func (b *Backend) SetCursorPos(x, y int)

func (*Backend) SetCursorShape

func (b *Backend) SetCursorShape(s backend.CursorShape)

func (*Backend) SetInline

func (b *Backend) SetInline(inline bool)

SetInline configures the backend to run in inline mode.

func (*Backend) SetMouseMode

func (b *Backend) SetMouseMode(mode backend.MouseSupport)

SetMouseMode selects the mouse events reported by the terminal.

func (*Backend) SetProgramResume

func (b *Backend) SetProgramResume(resume *terminal.ProgramResume)

func (*Backend) SetProgramStatus

func (b *Backend) SetProgramStatus(status *terminal.ProgramStatus)

func (*Backend) SetProgressBar

func (b *Backend) SetProgressBar(state backend.ProgressBarState, percentage int)

func (*Backend) SetResizeHandler

func (b *Backend) SetResizeHandler(fn func(geom.Size))

SetResizeHandler registers fn as the callback invoked when the terminal is resized.

func (*Backend) SetTitle

func (b *Backend) SetTitle(s string)

func (*Backend) ShowCursor

func (b *Backend) ShowCursor(v bool)

func (*Backend) Size

func (b *Backend) Size() geom.Size

Size returns the current terminal size.

func (*Backend) Start

func (b *Backend) Start() error

Start enters alt-screen, enables raw mode, and starts the render goroutine.

func (*Backend) Stop

func (b *Backend) Stop()

Stop closes the render goroutine gracefully and calls Restore.

func (*Backend) Suspend

func (b *Backend) Suspend() error

func (*Backend) Title

func (b *Backend) Title() string

func (*Backend) Write

func (b *Backend) Write(p []byte) (n int, err error)

func (*Backend) Writer

func (b *Backend) Writer() io.Writer

Writer returns the terminal output writer (the backend itself).

type Option

type Option func(*consoleOptions)

Option configures a single UV backend.

func WithEnviron

func WithEnviron(environ []string) Option

WithEnviron replaces the process environment, including when environ is empty.

func WithInput

func WithInput(r io.Reader) Option

WithInput uses r instead of standard input.

func WithOutput

func WithOutput(w io.Writer) Option

WithOutput uses w instead of standard output.

func WithSize

func WithSize(width, height int) Option

WithSize sets the initial terminal size in cells.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL