readline

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 9 Imported by: 2 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 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