readline

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package readline provides a minimal raw-terminal event backend for interact/ui.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// Fallback is used when input is not a real terminal stream.
	Fallback backend.Backend
	// StrictTTY disables fallback and returns a TTY-related error instead.
	StrictTTY bool
}

Backend creates raw-terminal sessions backed by golang.org/x/term.

func New

func New() *Backend

New creates a readline backend.

func NewStrict

func NewStrict() *Backend

NewStrict creates a readline backend that fails when a TTY is unavailable.

func (*Backend) NewSession

func (b *Backend) NewSession(in io.Reader, out io.Writer) (backend.Session, error)

NewSession creates a new raw-terminal session.

type Session

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

Session is a raw-terminal session.

func (*Session) Close

func (s *Session) Close() error

Close restores terminal state and ends the rendered block.

func (*Session) ReadEvent

func (s *Session) ReadEvent(ctx context.Context) (backend.Event, error)

ReadEvent reads and normalizes one terminal event.

func (*Session) Render

func (s *Session) Render(view backend.View) error

Render redraws the current interaction block.

func (*Session) Size

func (s *Session) Size() (width, height int)

Size returns the current terminal size.

Jump to

Keyboard shortcuts

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