bento

package module
v0.0.0-...-45b0304 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 27 Imported by: 0

README ΒΆ

🍱 Bento

Work in progress. Mascot is too =)

image

Bento is a Go framework for cooking up terminal user interfaces (TUIs). It provides a simple and flexible way to create text-based user interfaces in the terminal, which can be used for command-line applications, dashboards, and other interactive console programs.

It's a mix of Rust's ratatui library and Go's bubbletea

Bento provides efficient and complex layout functionality from ratatui (widgets, buffers, cassowary constraint solving algorithm) and functional design paradigms of The Elm Architecture as seen in bubbletea.

This library is mostly full Go rewrite of ratatui-core crate with some parts copied from bubbletea runtime.

Demo is WIP, but you can take a look at examples for now

It's named bento after how similar some bento boxes look like compared to the typical TUIs (multiple blocks of different sizes side by side)

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	ErrInterrupted = errors.New("interrupted")
	ErrKilled      = errors.New("killed")
)

Functions ΒΆ

This section is empty.

Types ΒΆ

type Alignment ΒΆ

type Alignment int
const (
	AlignmentNone Alignment = iota
	AlignmentLeft
	AlignmentCenter
	AlignmentRight
)

type App ΒΆ

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

func NewApp ΒΆ

func NewApp(model Model) App

func (App) Run ΒΆ

func (a App) Run() (Model, error)

func (App) WithContext ΒΆ

func (a App) WithContext(ctx context.Context) App

type BatchMsg ΒΆ

type BatchMsg []Cmd

type BlurMsg ΒΆ

type BlurMsg struct{}

BlurMsg represents a terminal blur message. This occurs when the terminal loses focus.

type Buffer ΒΆ

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

func NewBufferEmpty ΒΆ

func NewBufferEmpty(area Rect) Buffer

func NewBufferFilled ΒΆ

func NewBufferFilled(area Rect, cell Cell) Buffer

func (*Buffer) Area ΒΆ

func (b *Buffer) Area() Rect

Area of the buffer

func (*Buffer) CellAt ΒΆ

func (b *Buffer) CellAt(position Position) *Cell

func (*Buffer) Diff ΒΆ

func (b *Buffer) Diff(other *Buffer) []PositionedCell

Diff builds a minimal sequence of coordinates and Cells necessary to update the UI from self to other.

We're assuming that buffers are well-formed, that is no double-width cell is followed by a non-blank cell.

func (*Buffer) PosOf ΒΆ

func (b *Buffer) PosOf(index int) Position

func (*Buffer) Reset ΒΆ

func (b *Buffer) Reset()

func (*Buffer) Resize ΒΆ

func (b *Buffer) Resize(area Rect)

func (*Buffer) SetString ΒΆ

func (b *Buffer) SetString(x, y int, value string, style Style)

SetString prints a string, starting at the position (x, y)

func (*Buffer) SetStringN ΒΆ

func (b *Buffer) SetStringN(x, y int, value string, maxWidth int, style Style) (int, int)

SetStringN prints at most the first n characters of a string if enough space is available until the end of the line. Skips zero-width graphemes and control characters.

Use Buffer.SetString when the maximum amount of characters can be printed.

func (*Buffer) SetStyle ΒΆ

func (b *Buffer) SetStyle(area Rect, style Style)

type Cell ΒΆ

type Cell struct {
	Symbol   string
	Fg, Bg   Color
	Modifier Modifier
	Skip     bool
}

func NewCell ΒΆ

func NewCell(symbol string) Cell

func NewEmptyCell ΒΆ

func NewEmptyCell() Cell

func (*Cell) AppendSymbol ΒΆ

func (c *Cell) AppendSymbol(symbol string) *Cell

func (*Cell) Reset ΒΆ

func (c *Cell) Reset()

func (*Cell) SetBg ΒΆ

func (c *Cell) SetBg(color termenv.Color) *Cell

func (*Cell) SetFg ΒΆ

func (c *Cell) SetFg(color termenv.Color) *Cell

func (*Cell) SetStyle ΒΆ

func (c *Cell) SetStyle(style Style) *Cell

func (*Cell) SetSymbol ΒΆ

func (c *Cell) SetSymbol(symbol string) *Cell

type Cmd ΒΆ

type Cmd func() Msg

func Batch ΒΆ

func Batch(cmds ...Cmd) Cmd

Batch performs a bunch of commands concurrently with no ordering guarantees about the results. Use a Batch to return several commands.

func Sequence ΒΆ

func Sequence(cmds ...Cmd) Cmd

Sequence runs the given commands one at a time, in order. Contrast this with Batch, which runs commands concurrently.

func Tick ΒΆ

func Tick(d time.Duration, fn func(time.Time) Msg) Cmd

type Color ΒΆ

type Color = termenv.Color

type CompletedFrame ΒΆ

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

type Constraint ΒΆ

type Constraint interface {
	fmt.Stringer
	// contains filtered or unexported methods
}

type ConstraintFill ΒΆ

type ConstraintFill int

func (ConstraintFill) String ΒΆ

func (f ConstraintFill) String() string

type ConstraintLen ΒΆ

type ConstraintLen int

func (ConstraintLen) String ΒΆ

func (l ConstraintLen) String() string

type ConstraintMax ΒΆ

type ConstraintMax int

func (ConstraintMax) String ΒΆ

func (m ConstraintMax) String() string

type ConstraintMin ΒΆ

type ConstraintMin int

func (ConstraintMin) String ΒΆ

func (m ConstraintMin) String() string

type ConstraintPercentage ΒΆ

type ConstraintPercentage int

func (ConstraintPercentage) String ΒΆ

func (p ConstraintPercentage) String() string

type ConstraintRatio ΒΆ

type ConstraintRatio struct{ Num, Den int }

func (ConstraintRatio) String ΒΆ

func (r ConstraintRatio) String() string

type DefaultBackend ΒΆ

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

func NewDefaultBackend ΒΆ

func NewDefaultBackend(input io.Reader, output io.Writer) DefaultBackend

func (*DefaultBackend) ClearAfterCursor ΒΆ

func (d *DefaultBackend) ClearAfterCursor() error

ClearAfterCursor implements TerminalBackend.

func (*DefaultBackend) ClearAll ΒΆ

func (d *DefaultBackend) ClearAll() error

ClearAll implements TerminalBackend.

func (*DefaultBackend) ClearBeforeCursor ΒΆ

func (d *DefaultBackend) ClearBeforeCursor() error

ClearBeforeCursor implements TerminalBackend.

func (*DefaultBackend) ClearCurrentLine ΒΆ

func (d *DefaultBackend) ClearCurrentLine() error

ClearCurrentLine implements TerminalBackend.

func (*DefaultBackend) ClearUntilNewLine ΒΆ

func (d *DefaultBackend) ClearUntilNewLine() error

ClearUntilNewLine implements TerminalBackend.

func (*DefaultBackend) DisableBracketedPaste ΒΆ

func (d *DefaultBackend) DisableBracketedPaste() error

func (*DefaultBackend) DisableRawMode ΒΆ

func (d *DefaultBackend) DisableRawMode() error

func (*DefaultBackend) Draw ΒΆ

func (d *DefaultBackend) Draw(cells []PositionedCell) error

Draw implements TerminalBackend.

func (*DefaultBackend) EnableAlternateScreen ΒΆ

func (d *DefaultBackend) EnableAlternateScreen() error

func (*DefaultBackend) EnableBracketedPaste ΒΆ

func (d *DefaultBackend) EnableBracketedPaste() error

func (*DefaultBackend) EnableRawMode ΒΆ

func (d *DefaultBackend) EnableRawMode() error

func (*DefaultBackend) Flush ΒΆ

func (d *DefaultBackend) Flush() error

Flush implements TerminalBackend.

func (*DefaultBackend) GetCursorPosition ΒΆ

func (d *DefaultBackend) GetCursorPosition() (Position, error)

GetCursorPosition implements TerminalBackend.

func (*DefaultBackend) GetSize ΒΆ

func (d *DefaultBackend) GetSize() (Size, bool, error)

GetSize implements TerminalBackend.

func (*DefaultBackend) HideCursor ΒΆ

func (d *DefaultBackend) HideCursor() error

HideCursor implements TerminalBackend.

func (*DefaultBackend) Input ΒΆ

func (d *DefaultBackend) Input() io.Reader

func (*DefaultBackend) LeaveAlternateScreen ΒΆ

func (d *DefaultBackend) LeaveAlternateScreen() error

func (*DefaultBackend) Output ΒΆ

func (d *DefaultBackend) Output() io.Writer

func (*DefaultBackend) Read ΒΆ

func (d *DefaultBackend) Read(p []byte) (n int, err error)

Read implements TerminalBackend.

func (*DefaultBackend) SetCursorPosition ΒΆ

func (d *DefaultBackend) SetCursorPosition(position Position) error

SetCursorPosition implements TerminalBackend.

func (*DefaultBackend) ShowCursor ΒΆ

func (d *DefaultBackend) ShowCursor() error

ShowCursor implements TerminalBackend.

type Direction ΒΆ

type Direction int
const (
	DirectionVertical Direction = iota
	DirectionHorizontal
)

type Flex ΒΆ

type Flex int
const (
	FlexLegacy Flex = iota
	FlexStart
	FlexEnd
	FlexCenter
	FlexSpaceBetween
	FlexSpaceAround
)

type FocusMsg ΒΆ

type FocusMsg struct{}

FocusMsg represents a terminal focus message. This occurs when the terminal gains focus.

type Frame ΒΆ

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

func (*Frame) Area ΒΆ

func (f *Frame) Area() Rect

func (*Frame) RenderWidget ΒΆ

func (f *Frame) RenderWidget(widget Widget, area Rect)

type Key ΒΆ

type Key struct {
	Type  KeyType
	Runes []rune
	Alt   bool
	Paste bool
}

Key contains information about a keypress.

func (Key) String ΒΆ

func (k Key) String() (str string)

String returns a friendly string representation for a key. It's safe (and encouraged) for use in key comparison.

k := Key{Type: KeyEnter}
fmt.Println(k)
// Output: enter

type KeyMsg ΒΆ

type KeyMsg Key

KeyMsg contains information about a keypress. KeyMsgs are always sent to the program's update function. There are a couple general patterns you could use to check for keypresses:

// Switch on the string representation of the key (shorter)
switch msg := msg.(type) {
case KeyMsg:
    switch msg.String() {
    case "enter":
        fmt.Println("you pressed enter!")
    case "a":
        fmt.Println("you pressed a!")
    }
}

// Switch on the key type (more foolproof)
switch msg := msg.(type) {
case KeyMsg:
    switch msg.Type {
    case KeyEnter:
        fmt.Println("you pressed enter!")
    case KeyRunes:
        switch string(msg.Runes) {
        case "a":
            fmt.Println("you pressed a!")
        }
    }
}

Note that Key.Runes will always contain at least one character, so you can always safely call Key.Runes[0]. In most cases Key.Runes will only contain one character, though certain input method editors (most notably Chinese IMEs) can input multiple runes at once.

func (KeyMsg) String ΒΆ

func (k KeyMsg) String() (str string)

String returns a string representation for a key message. It's safe (and encouraged) for use in key comparison.

type KeyType ΒΆ

type KeyType int

KeyType indicates the key pressed, such as KeyEnter or KeyBreak or KeyCtrlC. All other keys will be type KeyRunes. To get the rune value, check the Rune method on a Key struct, or use the Key.String() method:

k := Key{Type: KeyRunes, Runes: []rune{'a'}, Alt: true}
if k.Type == KeyRunes {

    fmt.Println(k.Runes)
    // Output: a

    fmt.Println(k.String())
    // Output: alt+a

}
const (
	KeyNull      KeyType = keyNUL
	KeyBreak     KeyType = keyETX
	KeyEnter     KeyType = keyCR
	KeyBackspace KeyType = keyDEL
	KeyTab       KeyType = keyHT
	KeyEsc       KeyType = keyESC
	KeyEscape    KeyType = keyESC

	KeyCtrlAt           KeyType = keyNUL // ctrl+@
	KeyCtrlA            KeyType = keySOH
	KeyCtrlB            KeyType = keySTX
	KeyCtrlC            KeyType = keyETX
	KeyCtrlD            KeyType = keyEOT
	KeyCtrlE            KeyType = keyENQ
	KeyCtrlF            KeyType = keyACK
	KeyCtrlG            KeyType = keyBEL
	KeyCtrlH            KeyType = keyBS
	KeyCtrlI            KeyType = keyHT
	KeyCtrlJ            KeyType = keyLF
	KeyCtrlK            KeyType = keyVT
	KeyCtrlL            KeyType = keyFF
	KeyCtrlM            KeyType = keyCR
	KeyCtrlN            KeyType = keySO
	KeyCtrlO            KeyType = keySI
	KeyCtrlP            KeyType = keyDLE
	KeyCtrlQ            KeyType = keyDC1
	KeyCtrlR            KeyType = keyDC2
	KeyCtrlS            KeyType = keyDC3
	KeyCtrlT            KeyType = keyDC4
	KeyCtrlU            KeyType = keyNAK
	KeyCtrlV            KeyType = keySYN
	KeyCtrlW            KeyType = keyETB
	KeyCtrlX            KeyType = keyCAN
	KeyCtrlY            KeyType = keyEM
	KeyCtrlZ            KeyType = keySUB
	KeyCtrlOpenBracket  KeyType = keyESC // ctrl+[
	KeyCtrlBackslash    KeyType = keyFS  // ctrl+\
	KeyCtrlCloseBracket KeyType = keyGS  // ctrl+]
	KeyCtrlCaret        KeyType = keyRS  // ctrl+^
	KeyCtrlUnderscore   KeyType = keyUS  // ctrl+_
	KeyCtrlQuestionMark KeyType = keyDEL // ctrl+?
)

Control key aliases.

const (
	KeyRunes KeyType = -(iota + 1)
	KeyUp
	KeyDown
	KeyRight
	KeyLeft
	KeyShiftTab
	KeyHome
	KeyEnd
	KeyPgUp
	KeyPgDown
	KeyCtrlPgUp
	KeyCtrlPgDown
	KeyDelete
	KeyInsert
	KeySpace
	KeyCtrlUp
	KeyCtrlDown
	KeyCtrlRight
	KeyCtrlLeft
	KeyCtrlHome
	KeyCtrlEnd
	KeyShiftUp
	KeyShiftDown
	KeyShiftRight
	KeyShiftLeft
	KeyShiftHome
	KeyShiftEnd
	KeyCtrlShiftUp
	KeyCtrlShiftDown
	KeyCtrlShiftLeft
	KeyCtrlShiftRight
	KeyCtrlShiftHome
	KeyCtrlShiftEnd
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyF13
	KeyF14
	KeyF15
	KeyF16
	KeyF17
	KeyF18
	KeyF19
	KeyF20
)

Other keys.

func (KeyType) String ΒΆ

func (k KeyType) String() (str string)

type Layout ΒΆ

type Layout struct {
	Direction   Direction
	Constraints []Constraint
	Padding     Padding
	Flex        Flex
	Spacing     Spacing
}

func NewLayout ΒΆ

func NewLayout(constraints ...Constraint) Layout

func (Layout) Horizontal ΒΆ

func (l Layout) Horizontal() Layout

func (Layout) Split ΒΆ

func (l Layout) Split(area Rect) Splitted

func (Layout) SplitWithSpacers ΒΆ

func (l Layout) SplitWithSpacers(area Rect) (segments, spacers Splitted)

func (Layout) Vertical ΒΆ

func (l Layout) Vertical() Layout

func (Layout) WithConstraints ΒΆ

func (l Layout) WithConstraints(constraints ...Constraint) Layout

func (Layout) WithDirection ΒΆ

func (l Layout) WithDirection(direction Direction) Layout

func (Layout) WithFlex ΒΆ

func (l Layout) WithFlex(flex Flex) Layout

func (Layout) WithPadding ΒΆ

func (l Layout) WithPadding(padding Padding) Layout

func (Layout) WithSpacing ΒΆ

func (l Layout) WithSpacing(spacing Spacing) Layout

type Model ΒΆ

type Model interface {
	Widget

	Init() Cmd
	Update(msg Msg) (Model, Cmd)
}

type Modifier ΒΆ

type Modifier uint16
const (
	ModifierNone       Modifier = 0b0000_0000_0000
	ModifierBold       Modifier = 0b0000_0000_0001
	ModifierDim        Modifier = 0b0000_0000_0010
	ModifierItalic     Modifier = 0b0000_0000_0100
	ModifierUnderlined Modifier = 0b0000_0000_1000
	ModifierSlowBlink  Modifier = 0b0000_0001_0000
	ModifierRapidBlink Modifier = 0b0000_0010_0000
	ModifierReversed   Modifier = 0b0000_0100_0000
	ModifierHidden     Modifier = 0b0000_1000_0000
	ModifierCrossedOut Modifier = 0b0001_0000_0000
	ModifierAll        Modifier = ModifierBold |
		ModifierDim |
		ModifierItalic |
		ModifierUnderlined |
		ModifierSlowBlink |
		ModifierRapidBlink |
		ModifierReversed |
		ModifierHidden |
		ModifierCrossedOut
)

func (Modifier) Contains ΒΆ

func (m Modifier) Contains(other Modifier) bool

type MouseAction ΒΆ

type MouseAction int

MouseAction represents the action that occurred during a mouse event.

const (
	MouseActionPress MouseAction = iota
	MouseActionRelease
	MouseActionMotion
)

Mouse event actions.

type MouseButton ΒΆ

type MouseButton int

MouseButton represents the button that was pressed during a mouse event.

const (
	MouseButtonNone MouseButton = iota
	MouseButtonLeft
	MouseButtonMiddle
	MouseButtonRight
	MouseButtonWheelUp
	MouseButtonWheelDown
	MouseButtonWheelLeft
	MouseButtonWheelRight
	MouseButtonBackward
	MouseButtonForward
	MouseButton10
	MouseButton11
)

Mouse event buttons

This is based on X11 mouse button codes.

1 = left button
2 = middle button (pressing the scroll wheel)
3 = right button
4 = turn scroll wheel up
5 = turn scroll wheel down
6 = push scroll wheel left
7 = push scroll wheel right
8 = 4th button (aka browser backward button)
9 = 5th button (aka browser forward button)
10
11

Other buttons are not supported.

type MouseEvent ΒΆ

type MouseEvent struct {
	X      int
	Y      int
	Shift  bool
	Alt    bool
	Ctrl   bool
	Action MouseAction
	Button MouseButton
}

MouseEvent represents a mouse event, which could be a click, a scroll wheel movement, a cursor movement, or a combination.

func (MouseEvent) IsWheel ΒΆ

func (m MouseEvent) IsWheel() bool

IsWheel returns true if the mouse event is a wheel event.

func (MouseEvent) String ΒΆ

func (m MouseEvent) String() (s string)

String returns a string representation of a mouse event.

type MouseMsg ΒΆ

type MouseMsg MouseEvent

MouseMsg contains information about a mouse event and are sent to a programs update function when mouse activity occurs. Note that the mouse must first be enabled in order for the mouse events to be received.

func (MouseMsg) String ΒΆ

func (m MouseMsg) String() string

String returns a string representation of a mouse event.

type Msg ΒΆ

type Msg any

func Quit ΒΆ

func Quit() Msg

Quit is a special command that tells the Bento app to exit.

type Padding ΒΆ

type Padding struct {
	Top, Right, Bottom, Left int
}

func NewPadding ΒΆ

func NewPadding(sides ...int) Padding

func (Padding) WithBottom ΒΆ

func (p Padding) WithBottom(s int) Padding

func (Padding) WithLeft ΒΆ

func (p Padding) WithLeft(s int) Padding

func (Padding) WithRight ΒΆ

func (p Padding) WithRight(s int) Padding

func (Padding) WithTop ΒΆ

func (p Padding) WithTop(s int) Padding

type Position ΒΆ

type Position struct {
	X, Y int
}

func NewPosition ΒΆ

func NewPosition(x, y int) Position

type PositionedCell ΒΆ

type PositionedCell struct {
	Cell

	Position Position
}

type QuitMsg ΒΆ

type QuitMsg struct{}

type Rect ΒΆ

type Rect struct {
	X, Y int

	Width, Height int
}

func NewRect ΒΆ

func NewRect(width, height int) Rect

func (Rect) Area ΒΆ

func (r Rect) Area() int

func (Rect) Bottom ΒΆ

func (r Rect) Bottom() int

func (Rect) Columns ΒΆ

func (r Rect) Columns() []Rect

func (Rect) Contains ΒΆ

func (r Rect) Contains(position Position) bool

func (Rect) IndentX ΒΆ

func (r Rect) IndentX(offset int) Rect

func (Rect) Inner ΒΆ

func (r Rect) Inner(padding Padding) Rect

func (Rect) Intersection ΒΆ

func (r Rect) Intersection(other Rect) Rect

func (Rect) IsEmpty ΒΆ

func (r Rect) IsEmpty() bool

func (Rect) Left ΒΆ

func (r Rect) Left() int

func (Rect) Position ΒΆ

func (r Rect) Position() Position

func (Rect) Positioned ΒΆ

func (r Rect) Positioned(x, y int) Rect

func (Rect) Right ΒΆ

func (r Rect) Right() int

func (Rect) Rows ΒΆ

func (r Rect) Rows() []Rect

func (Rect) Top ΒΆ

func (r Rect) Top() int

type ResetColor ΒΆ

type ResetColor struct{}

func (ResetColor) Sequence ΒΆ

func (ResetColor) Sequence(bg bool) string

Sequence implements termenv.Color.

type Size ΒΆ

type Size struct {
	Width, Height int
}

type Spacing ΒΆ

type Spacing interface{}

type SpacingOverlap ΒΆ

type SpacingOverlap int

type SpacingSpace ΒΆ

type SpacingSpace int

type Splitted ΒΆ

type Splitted []Rect

func (Splitted) Assign ΒΆ

func (s Splitted) Assign(areas ...*Rect)

func (Splitted) Unwrap ΒΆ

func (s Splitted) Unwrap() Rect

func (Splitted) Unwrap2 ΒΆ

func (s Splitted) Unwrap2() (a, b Rect)

func (Splitted) Unwrap3 ΒΆ

func (s Splitted) Unwrap3() (a, b, c Rect)

func (Splitted) Unwrap4 ΒΆ

func (s Splitted) Unwrap4() (a, b, c, d Rect)

type StatefulWidget ΒΆ

type StatefulWidget[S any] interface {
	RenderStateful(area Rect, buffer *Buffer, state S)
}

type Style ΒΆ

type Style struct {
	Foreground, Background StyleColor
	// contains filtered or unexported fields
}

func NewStyle ΒΆ

func NewStyle() Style

func (Style) Black ΒΆ

func (s Style) Black() Style

func (Style) Blue ΒΆ

func (s Style) Blue() Style

func (Style) Bold ΒΆ

func (s Style) Bold() Style

func (Style) BrightBlack ΒΆ

func (s Style) BrightBlack() Style

func (Style) BrightBlue ΒΆ

func (s Style) BrightBlue() Style

func (Style) BrightCyan ΒΆ

func (s Style) BrightCyan() Style

func (Style) BrightGreen ΒΆ

func (s Style) BrightGreen() Style

func (Style) BrightMagenta ΒΆ

func (s Style) BrightMagenta() Style

func (Style) BrightRed ΒΆ

func (s Style) BrightRed() Style

func (Style) BrightWhite ΒΆ

func (s Style) BrightWhite() Style

func (Style) BrightYellow ΒΆ

func (s Style) BrightYellow() Style

func (Style) CrossedOut ΒΆ

func (s Style) CrossedOut() Style

func (Style) Cyan ΒΆ

func (s Style) Cyan() Style

func (Style) Dim ΒΆ

func (s Style) Dim() Style

func (Style) Green ΒΆ

func (s Style) Green() Style

func (Style) Italic ΒΆ

func (s Style) Italic() Style

func (Style) Magenta ΒΆ

func (s Style) Magenta() Style

func (Style) OnBlack ΒΆ

func (s Style) OnBlack() Style

func (Style) OnBlue ΒΆ

func (s Style) OnBlue() Style

func (Style) OnBrightBlack ΒΆ

func (s Style) OnBrightBlack() Style

func (Style) OnBrightBlue ΒΆ

func (s Style) OnBrightBlue() Style

func (Style) OnBrightCyan ΒΆ

func (s Style) OnBrightCyan() Style

func (Style) OnBrightGreen ΒΆ

func (s Style) OnBrightGreen() Style

func (Style) OnBrightMagenta ΒΆ

func (s Style) OnBrightMagenta() Style

func (Style) OnBrightRed ΒΆ

func (s Style) OnBrightRed() Style

func (Style) OnBrightWhite ΒΆ

func (s Style) OnBrightWhite() Style

func (Style) OnBrightYellow ΒΆ

func (s Style) OnBrightYellow() Style

func (Style) OnCyan ΒΆ

func (s Style) OnCyan() Style

func (Style) OnGreen ΒΆ

func (s Style) OnGreen() Style

func (Style) OnMagenta ΒΆ

func (s Style) OnMagenta() Style

func (Style) OnRGB ΒΆ

func (s Style) OnRGB(r, g, b uint8) Style

func (Style) OnRed ΒΆ

func (s Style) OnRed() Style

func (Style) OnWhite ΒΆ

func (s Style) OnWhite() Style

func (Style) OnYellow ΒΆ

func (s Style) OnYellow() Style

func (Style) Patched ΒΆ

func (s Style) Patched(patch Style) Style

func (Style) RGB ΒΆ

func (s Style) RGB(r, g, b uint8) Style

func (Style) Red ΒΆ

func (s Style) Red() Style

func (Style) Reversed ΒΆ

func (s Style) Reversed() Style

func (Style) Underlined ΒΆ

func (s Style) Underlined() Style

func (Style) White ΒΆ

func (s Style) White() Style

func (Style) WithBackground ΒΆ

func (s Style) WithBackground(color Color) Style

func (Style) WithForeground ΒΆ

func (s Style) WithForeground(color Color) Style

func (Style) WithModifier ΒΆ

func (s Style) WithModifier(modifier Modifier) Style

func (Style) WithoutModifier ΒΆ

func (s Style) WithoutModifier(modifier Modifier) Style

func (Style) Yellow ΒΆ

func (s Style) Yellow() Style

type StyleColor ΒΆ

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

func (*StyleColor) Color ΒΆ

func (s *StyleColor) Color() Color

func (*StyleColor) IsSet ΒΆ

func (s *StyleColor) IsSet() bool

func (*StyleColor) Reset ΒΆ

func (s *StyleColor) Reset()

func (*StyleColor) Set ΒΆ

func (s *StyleColor) Set(color Color)

type Terminal ΒΆ

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

func NewTerminal ΒΆ

func NewTerminal(backend TerminalBackend, viewport Viewport) (*Terminal, error)

func (*Terminal) Clear ΒΆ

func (t *Terminal) Clear() error

func (*Terminal) CurrentBuffer ΒΆ

func (t *Terminal) CurrentBuffer() *Buffer

func (*Terminal) DisableBracketedPaste ΒΆ

func (t *Terminal) DisableBracketedPaste() error

func (*Terminal) DisableRawMode ΒΆ

func (t *Terminal) DisableRawMode() error

func (*Terminal) Draw ΒΆ

func (t *Terminal) Draw(widget Widget) (CompletedFrame, error)

func (*Terminal) EnableAlternateScreen ΒΆ

func (t *Terminal) EnableAlternateScreen() error

func (*Terminal) EnableBracketedPaste ΒΆ

func (t *Terminal) EnableBracketedPaste() error

func (*Terminal) EnableRawMode ΒΆ

func (t *Terminal) EnableRawMode() error

func (*Terminal) Flush ΒΆ

func (t *Terminal) Flush() error

Flush obtains a difference between the previous and the current buffer and passes it to the current backend for drawing.

func (*Terminal) GetFrame ΒΆ

func (t *Terminal) GetFrame() Frame

func (*Terminal) HideCursor ΒΆ

func (t *Terminal) HideCursor() error

func (*Terminal) Input ΒΆ

func (t *Terminal) Input() io.Reader

func (*Terminal) LeaveAlternateScreen ΒΆ

func (t *Terminal) LeaveAlternateScreen() error

func (*Terminal) Output ΒΆ

func (t *Terminal) Output() io.Writer

func (*Terminal) PreviousBuffer ΒΆ

func (t *Terminal) PreviousBuffer() *Buffer

func (*Terminal) Read ΒΆ

func (t *Terminal) Read(p []byte) (n int, err error)

Read implements io.Reader.

func (*Terminal) Resize ΒΆ

func (t *Terminal) Resize(area Rect) error

func (*Terminal) SetCursorPosition ΒΆ

func (t *Terminal) SetCursorPosition(position Position) error

func (*Terminal) ShowCursor ΒΆ

func (t *Terminal) ShowCursor() error

func (*Terminal) Size ΒΆ

func (t *Terminal) Size() (Size, bool, error)

func (*Terminal) SwapBuffers ΒΆ

func (t *Terminal) SwapBuffers()

func (*Terminal) Viewport ΒΆ

func (t *Terminal) Viewport() Viewport

type TerminalBackend ΒΆ

type TerminalBackend interface {
	io.Reader

	Draw(cells []PositionedCell) error
	HideCursor() error
	ShowCursor() error
	GetCursorPosition() (Position, error)
	SetCursorPosition(position Position) error
	GetSize() (Size, bool, error)
	Flush() error

	ClearAll() error
	ClearAfterCursor() error
	ClearBeforeCursor() error
	ClearCurrentLine() error
	ClearUntilNewLine() error

	EnableRawMode() error
	DisableRawMode() error

	EnableAlternateScreen() error
	LeaveAlternateScreen() error

	EnableBracketedPaste() error
	DisableBracketedPaste() error

	Input() io.Reader
	Output() io.Writer
}

type TryUpdater ΒΆ

type TryUpdater interface {
	// TryUpdate passes message to update the receiver.
	// It returns a boolean that states whether the message was consumed
	// and should not be handled further.
	// If consumed is true the caller should return resulted cmd.
	//
	// It is adviced to call this method before any further message handling.
	TryUpdate(msg Msg) (consumed bool, cmd Cmd)
}

type Viewport ΒΆ

type Viewport interface {
	// contains filtered or unexported methods
}

type ViewportFixed ΒΆ

type ViewportFixed Rect

type ViewportFullscreen ΒΆ

type ViewportFullscreen struct{}

type ViewportInline ΒΆ

type ViewportInline int

type Widget ΒΆ

type Widget interface {
	Render(area Rect, buffer *Buffer)
}

type WindowSizeMsg ΒΆ

type WindowSizeMsg Size

Jump to

Keyboard shortcuts

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