termui

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultColumnSpacing = 1

DefaultColumnSpacing default the spacing (in chars) between columns of a table

Variables

This section is empty.

Functions

func String

func String(b bufferer) (string, error)

String returns this Buffer content as a string

Types

type GaugeColumn

type GaugeColumn struct {
	termui.Gauge
}

GaugeColumn is a termui.Gauge to be used as a Grid column. It is borderless, has a height of 1 and its label is left-aligned.

func NewGaugeColumn

func NewGaugeColumn() *GaugeColumn

NewGaugeColumn creates a new GaugeColumn

func NewThemedGaugeColumn

func NewThemedGaugeColumn(theme *ui.ColorTheme) *GaugeColumn

NewThemedGaugeColumn creates a new GaugeColumn using the given theme

func (*GaugeColumn) Reset

func (w *GaugeColumn) Reset()

Reset resets this GaugeColumn

type KeyValuePar

type KeyValuePar struct {
	X, Y   int
	Width  int
	Height int
	// contains filtered or unexported fields
}

KeyValuePar is a widget for key value pairs

func NewKeyValuePar

func NewKeyValuePar(key, value string, theme *ui.ColorTheme) *KeyValuePar

NewKeyValuePar creates a KeyValuePar widget with the given values

func (*KeyValuePar) Buffer

func (kv *KeyValuePar) Buffer() gtermui.Buffer

Buffer returns this kv data as a gtermui.Buffer

func (*KeyValuePar) GetHeight

func (kv *KeyValuePar) GetHeight() int

GetHeight returns this kv heigth

func (*KeyValuePar) SetWidth

func (kv *KeyValuePar) SetWidth(width int)

SetWidth sets the width of this kv

func (*KeyValuePar) SetX

func (kv *KeyValuePar) SetX(x int)

SetX sets the x position of this kv

func (*KeyValuePar) SetY

func (kv *KeyValuePar) SetY(y int)

SetY sets the y position of this kv

type MarkupPar

type MarkupPar struct {
	gizaktermui.Paragraph
	// contains filtered or unexported fields
}

MarkupPar is a paragraph with marked-up text

func NewParFromMarkupText

func NewParFromMarkupText(theme *ui.ColorTheme, str string) *MarkupPar

NewParFromMarkupText creates a new termui paragraph from marked-up text.

func (*MarkupPar) Buffer

func (p *MarkupPar) Buffer() gizaktermui.Buffer

Buffer return this paragraph content as a termui.Buffer

func (*MarkupPar) Content

func (p *MarkupPar) Content(str string)

Content sets the paragraph content to the given text.

type ParColumn

type ParColumn struct {
	termui.Paragraph
}

ParColumn is a termui.Par that can be used in a grid to show text

func NewParColumn

func NewParColumn(s string) *ParColumn

NewParColumn creates a new paragraph column with the given text

func NewThemedParColumn

func NewThemedParColumn(theme *ui.ColorTheme, s string) *ParColumn

NewThemedParColumn creates a new paragraph column with the given text using the given color theme

func (*ParColumn) Content

func (w *ParColumn) Content(s string)

Content sets the text of this Par to the given content

func (*ParColumn) Reset

func (w *ParColumn) Reset()

Reset resets the text on this Par

func (*ParColumn) SetWidth

func (w *ParColumn) SetWidth(width int)

SetWidth sets par width.

type Row

type Row struct {
	X, Y    int
	Width   int
	Height  int
	Columns []gtermui.GridBufferer
	Table   Table
}

Row is a widget for table rows

func (*Row) AddColumn

func (row *Row) AddColumn(c gtermui.GridBufferer)

AddColumn adds the given column to this row

func (*Row) Buffer

func (row *Row) Buffer() gtermui.Buffer

Buffer returns this Row data as a gtermui.Buffer

func (*Row) GetHeight

func (row *Row) GetHeight() int

GetHeight returns this Row heigth

func (*Row) SetWidth

func (row *Row) SetWidth(width int)

SetWidth sets the width of this Row

func (*Row) SetX

func (row *Row) SetX(x int)

SetX sets the x position of this Row

func (*Row) SetY

func (row *Row) SetY(y int)

SetY sets the y position of this Row

type SizableBufferer

type SizableBufferer interface {
	gizak.Bufferer
	GetHeight() int
	SetWidth(int)
	SetX(int)
	SetY(int)
}

SizableBufferer is a termui.Bufferer with dimensions and position

type Table

type Table interface {
	ColumnWidths() []int
}

Table defines common behaviour for table widgets

type TableHeader

type TableHeader struct {
	X, Y          int
	Height, Width int
	Columns       []*termui.Paragraph
	ColumnSpacing int

	Theme *ui.ColorTheme
	// contains filtered or unexported fields
}

TableHeader is a table header widget

func NewHeader

func NewHeader(Theme *ui.ColorTheme) *TableHeader

NewHeader creates a header of height 1 that uses the given Theme

func (*TableHeader) AddColumn

func (th *TableHeader) AddColumn(s string)

AddColumn adds a column to this header

func (*TableHeader) AddFixedWidthColumn

func (th *TableHeader) AddFixedWidthColumn(s string, width int)

AddFixedWidthColumn adds a column to this header with a fixed width

func (*TableHeader) Buffer

func (th *TableHeader) Buffer() termui.Buffer

Buffer returns the content of this header as a buffer

func (*TableHeader) ColumnCount

func (th *TableHeader) ColumnCount() int

ColumnCount returns the number of columns on this header

func (*TableHeader) ColumnWidths

func (th *TableHeader) ColumnWidths() []int

ColumnWidths returns the width of each column of the table

func (*TableHeader) GetHeight

func (th *TableHeader) GetHeight() int

GetHeight return this header's height

func (*TableHeader) SetWidth

func (th *TableHeader) SetWidth(w int)

SetWidth sets the width of this header

func (*TableHeader) SetX

func (th *TableHeader) SetX(x int)

SetX sets the X position of this header

func (*TableHeader) SetY

func (th *TableHeader) SetY(y int)

SetY sets the Y position of this header

type TextInput

type TextInput struct {
	termui.Block

	TextFgColor termui.Attribute
	TextBgColor termui.Attribute
	TextBuilder termui.TextBuilder

	sync.RWMutex
	// contains filtered or unexported fields
}

TextInput is a widget to capture user input

func NewTextInput

func NewTextInput(c cursor, s string) *TextInput

NewTextInput creates a new TextInput showing the text provided

func (*TextInput) Buffer

func (i *TextInput) Buffer() termui.Buffer

Buffer returns the content of this widget as a termui.Buffer

func (*TextInput) OnFocus

func (i *TextInput) OnFocus(event ui.EventSource) error

OnFocus starts handling events sent to the given channel. It is a blocking call, to return from it, either close the channel or send a closing event (i.e. KeyEnter on single line mode, KeyEsc on any mode).

func (*TextInput) Text

func (i *TextInput) Text() (string, bool)

Text returns the text of the input field as a string

type Widget

type Widget interface {
	Buffer() gizaktermui.Buffer
	Mount() error
	Name() string
	Unmount() error
}

Widget defines how a UI widget responds to its lifecycle events:

  • Buffer returns the content of the widget as termui.Buffer, it will be invoked every time the widget is render.
  • Mount will be invoked before the Buffer method, it can be used to prepare the widget for rendering.
  • Unmount will be invoked to signal that the widget is not going to be used anymore, it can be used for cleaning up.

Widget are identified by its name.

Jump to

Keyboard shortcuts

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