term

package
v0.0.94 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default terminal dimensions
	DefaultColumns = 80
	DefaultRows    = 24

	// Minimum terminal width for proper operation
	MinTerminalWidth = 6
)

Constants for key codes and terminal behavior

View Source
const HistoryLimit = 1000

HistoryLimit is the maximum number of entries saved in the scrollback history.

Variables

This section is empty.

Functions

func Bold added in v0.0.31

func Bold()

Font style

func ClearLine

func ClearLine()

func CloseProps

func CloseProps()

func ColorBgBlack added in v0.0.31

func ColorBgBlack()

Background

func ColorBgBlue added in v0.0.31

func ColorBgBlue()

func ColorBgCyan added in v0.0.31

func ColorBgCyan()

func ColorBgGreen added in v0.0.31

func ColorBgGreen()

func ColorBgMagenta added in v0.0.31

func ColorBgMagenta()

func ColorBgRed added in v0.0.31

func ColorBgRed()

func ColorBgWhite added in v0.0.31

func ColorBgWhite()

func ColorBgYellow added in v0.0.31

func ColorBgYellow()

func ColorBlack added in v0.0.31

func ColorBlack()

Standard colors

func ColorBlue

func ColorBlue()

func ColorBrBlack added in v0.0.31

func ColorBrBlack()

Bright colors

func ColorBrBlue added in v0.0.31

func ColorBrBlue()

func ColorBrCyan added in v0.0.31

func ColorBrCyan()

func ColorBrGreen

func ColorBrGreen()

func ColorBrMagenta added in v0.0.31

func ColorBrMagenta()

func ColorBrRed added in v0.0.31

func ColorBrRed()

func ColorBrWhite added in v0.0.31

func ColorBrWhite()

func ColorBrYellow added in v0.0.31

func ColorBrYellow()

func ColorCyan

func ColorCyan()

func ColorGreen

func ColorGreen()

func ColorMagenta

func ColorMagenta()

func ColorRed

func ColorRed()

func ColorWhite

func ColorWhite()

func ColorYellow added in v0.0.31

func ColorYellow()

func CurDown

func CurDown(n int)

func CurLeft

func CurLeft(n int)

func CurRight

func CurRight(n int)

func CurUp

func CurUp(n int)

func DisplayBlock

func DisplayBlock(bloc env.Block, idx *env.Idxs) (env.Object, bool)

func DisplayDateInput added in v0.0.92

func DisplayDateInput(initialDate string, right int) (env.Object, bool)

DisplayDateInput displays an interactive date input in format YYYY-MM-DD Allows arrow keys to navigate between fields and increment/decrement values Returns a string in format "YYYY-MM-DD"

func DisplayDict

func DisplayDict(bloc env.Dict, idx *env.Idxs) (env.Object, bool)

func DisplayInputField

func DisplayInputField(right int, mlen int) (env.Object, bool)

func DisplaySelection

func DisplaySelection(bloc env.Block, idx *env.Idxs, right int) (env.Object, bool)

func DisplayTable

func DisplayTable(bloc env.Table, idx *env.Idxs) (env.Object, bool)

func DisplayTableCustom added in v0.0.31

func DisplayTableCustom(bloc env.Table, myfn func(row env.Object, iscurr env.Integer), idx *env.Idxs) (env.Object, bool)

ideation: .display\custom fn { x } { -> 'subject .elipsis 20 .red .prn , spacer 2 , -> 'score .align-right 10 .print }

func DisplayTableRow added in v0.0.33

func DisplayTableRow(bloc env.TableRow, idx *env.Idxs) (env.Object, bool)

func GetChar

func GetChar() (ascii int, keyCode int, err error)

GetChar reads a character from the Unix terminal and returns ASCII code, key code, and error

func GetChar2

func GetChar2() (letter string, ascii int, keyCode int, err error)

GetChar2 is similar to GetChar but returns the character as a string

func GetTerminalColumns added in v0.0.26

func GetTerminalColumns() int

func HideCur

func HideCur()

func Italic added in v0.0.31

func Italic()

func ResetBold

func ResetBold()

func RestoreCurPos

func RestoreCurPos()

func RyeHighlight added in v0.0.26

func RyeHighlight(s string, inStrX bool, inStrX2 bool, columns int) (string, bool, bool)

func SaveCurPos

func SaveCurPos()

func SetTerminalRestoreFunc added in v0.0.82

func SetTerminalRestoreFunc(restoreFunc func() error)

SetTerminalRestoreFunc allows external packages to register a function that will be called to restore terminal state after suspension

func ShowCur

func ShowCur()

func StrBold added in v0.0.90

func StrBold() string

Font style string functions

func StrCloseProps added in v0.0.31

func StrCloseProps() string

func StrColorBgBlack added in v0.0.90

func StrColorBgBlack() string

Background string functions

func StrColorBgBlue added in v0.0.90

func StrColorBgBlue() string

func StrColorBgCyan added in v0.0.90

func StrColorBgCyan() string

func StrColorBgGreen added in v0.0.90

func StrColorBgGreen() string

func StrColorBgMagenta added in v0.0.90

func StrColorBgMagenta() string

func StrColorBgRed added in v0.0.90

func StrColorBgRed() string

func StrColorBgWhite added in v0.0.90

func StrColorBgWhite() string

func StrColorBgYellow added in v0.0.90

func StrColorBgYellow() string

func StrColorBlack added in v0.0.31

func StrColorBlack() string

Standard colors returned

func StrColorBlue added in v0.0.31

func StrColorBlue() string

func StrColorBrBlack added in v0.0.31

func StrColorBrBlack() string

func StrColorBrBlue added in v0.0.90

func StrColorBrBlue() string

func StrColorBrCyan added in v0.0.90

func StrColorBrCyan() string

func StrColorBrGreen added in v0.0.90

func StrColorBrGreen() string

func StrColorBrMagenta added in v0.0.90

func StrColorBrMagenta() string

func StrColorBrRed added in v0.0.90

func StrColorBrRed() string

func StrColorBrWhite added in v0.0.90

func StrColorBrWhite() string

func StrColorBrYellow added in v0.0.90

func StrColorBrYellow() string

func StrColorCyan added in v0.0.31

func StrColorCyan() string

func StrColorGreen added in v0.0.31

func StrColorGreen() string

func StrColorMagenta added in v0.0.31

func StrColorMagenta() string

func StrColorRed added in v0.0.31

func StrColorRed() string

func StrColorWhite added in v0.0.31

func StrColorWhite() string

func StrColorYellow added in v0.0.31

func StrColorYellow() string

func StrResetBold added in v0.0.90

func StrResetBold() string

func StrUnderline added in v0.0.90

func StrUnderline() string

func SuspendProcess added in v0.0.82

func SuspendProcess() error

SuspendProcess implements Unix-style process suspension using SIGTSTP signal It properly handles terminal state restoration after resume to fix input issues

func Underline added in v0.0.31

func Underline()

Types

type Completer added in v0.0.26

type Completer func(line string, mode int) []string

Completer takes the currently edited line content at the left of the cursor to the completer which may return {"Hello, world", "Hello, Word"} to have "Hello, world!!!".

type HighlightedStringBuilder added in v0.0.26

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

func (*HighlightedStringBuilder) ColoredString added in v0.0.26

func (h *HighlightedStringBuilder) ColoredString(inStr bool) string

func (*HighlightedStringBuilder) Reset added in v0.0.26

func (h *HighlightedStringBuilder) Reset()

func (*HighlightedStringBuilder) String added in v0.0.26

func (h *HighlightedStringBuilder) String() string

func (*HighlightedStringBuilder) WriteRune added in v0.0.26

func (h *HighlightedStringBuilder) WriteRune(c rune)

type KeyEvent added in v0.0.26

type KeyEvent struct {
	Key   string
	Code  int
	Ctrl  bool
	Alt   bool
	Shift bool
}

func NewKeyEvent added in v0.0.26

func NewKeyEvent(key string, code int, ctrl bool, alt bool, shift bool) KeyEvent

type MLState added in v0.0.26

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

MLState represents the state of a microliner terminal session

func NewMicroLiner added in v0.0.26

func NewMicroLiner(ch chan KeyEvent, sb func(msg string), el func(line string) string) *MLState

NewMicroLiner initializes a new *MLState with the provided event channel, output function, and line handler function.

func (*MLState) AppendHistory added in v0.0.26

func (s *MLState) AppendHistory(item string)

AppendHistory appends an entry to the scrollback history. AppendHistory should be called iff Prompt returns a valid command.

func (*MLState) ClearHistory added in v0.0.26

func (s *MLState) ClearHistory()

ClearHistory clears the scrollback history.

func (*MLState) GetKeyChan added in v0.0.40

func (s *MLState) GetKeyChan() <-chan KeyEvent

func (*MLState) MicroPrompt added in v0.0.26

func (s *MLState) MicroPrompt(prompt string, text string, pos int, ctx1 context.Context) (string, error)

MicroPrompt displays a prompt and handles user input with editing capabilities. It returns the final input string or an error if the operation was canceled or failed. The prompt is displayed with the given text and cursor position. The context can be used to cancel the operation.

func (*MLState) ReadHistory added in v0.0.31

func (s *MLState) ReadHistory(r io.Reader) (num int, err error)

ReadHistory reads history entries from an io.Reader and adds them to the history buffer. It returns the number of entries successfully read and any error encountered. If an error occurs, some entries may have been added to the history buffer.

func (*MLState) SetColumns added in v0.0.27

func (s *MLState) SetColumns(cols int) bool

func (*MLState) SetCompleter added in v0.0.26

func (s *MLState) SetCompleter(f Completer)

SetCompleter sets the completion function that Liner will call to fetch completion candidates when the user presses tab.

func (*MLState) SetDisplayValueFunc added in v0.0.82

func (s *MLState) SetDisplayValueFunc(fn func(*env.ProgramState, env.Object, bool) (env.Object, string))

SetDisplayValueFunc sets the callback function used to display values

func (*MLState) SetOnValueSelectedFunc added in v0.0.93

func (s *MLState) SetOnValueSelectedFunc(fn func(env.Object))

SetOnValueSelectedFunc sets the callback function called when user selects a value via Ctrl+x

func (*MLState) SetProgramState added in v0.0.82

func (s *MLState) SetProgramState(ps *env.ProgramState)

SetProgramState sets the program state for environment access during tab completion

func (*MLState) WriteHistory added in v0.0.31

func (s *MLState) WriteHistory(w io.Writer) (num int, err error)

WriteHistory writes scrollback history to w. Returns the number of lines successfully written, and any write error.

Unlike the rest of liner's API, WriteHistory is safe to call from another goroutine while Prompt is in progress. This exception is to facilitate the saving of the history buffer during an unexpected exit (for example, due to Ctrl-C being invoked)

type WordCompleter added in v0.0.26

type WordCompleter func(line string, pos int, mode int) (head string, completions []string, tail string)

WordCompleter takes the currently edited line with the cursor position and to the completer which may returns ("Hello, ", {"world", "Word"}, "!!!") to have "Hello, world!!!".

Jump to

Keyboard shortcuts

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