Documentation
¶
Overview ¶
Package widget provides base user interfaces.
Index ¶
- func DeleteBytes(s []byte, offset, length int) []byte
- func EventToString(ev *tcell.EventKey) string
- func Fini()
- func HideCursor()
- func Init()
- func InsertBytes(s, data []byte, offset int) []byte
- func IsNil(w Widget) bool
- func PollEvent() tcell.Event
- func SetBorder(v, h, ul, ur, ll, lr rune)
- func SetCells(x, y int, s string, style tcell.Style) (pos int)
- func Show()
- func ShowCursor(x, y int)
- func Size() (width, height int)
- func TruncLeft(s string, w int, head string) string
- type BorderStyle
- type Drawer
- type Extmap
- type Keymap
- type ListBox
- func (b *ListBox) AdjustCursor()
- func (b *ListBox) AdjustOffset()
- func (b *ListBox) AppendHighlightString(s, highlight string)
- func (b *ListBox) AppendList(e ...Drawer)
- func (b *ListBox) AppendString(s ...string)
- func (b *ListBox) ClearList()
- func (b *ListBox) Column() int
- func (b *ListBox) ColumnAdjustContentsWidth()
- func (b *ListBox) CurrentContent() Drawer
- func (b *ListBox) Cursor() int
- func (b *ListBox) CursorDown()
- func (b *ListBox) CursorToLeft()
- func (b *ListBox) CursorToRight()
- func (b *ListBox) CursorUp()
- func (b *ListBox) Draw()
- func (b *ListBox) IndexByName(name string) int
- func (b *ListBox) IsEmpty() bool
- func (b *ListBox) Len() int
- func (b *ListBox) Less(i, j int) bool
- func (b *ListBox) List() []Drawer
- func (b *ListBox) Lower() int
- func (b *ListBox) MoveBottom()
- func (b *ListBox) MoveCursor(amount int)
- func (b *ListBox) MoveTop()
- func (b *ListBox) Offset() int
- func (b *ListBox) PageDown()
- func (b *ListBox) PageUp()
- func (b *ListBox) Scroll(amount int)
- func (b *ListBox) ScrollRate() string
- func (b *ListBox) SetColumn(n int)
- func (b *ListBox) SetCursor(x int)
- func (b *ListBox) SetCursorByName(name string)
- func (b *ListBox) SetList(l []Drawer)
- func (b *ListBox) SetLower(lb int)
- func (b *ListBox) SetOffsetCenteredCursor()
- func (b *ListBox) SetTitle(s string)
- func (b *ListBox) Swap(i, j int)
- func (b *ListBox) Title() string
- func (b *ListBox) Upper() int
- type ProgressGauge
- type TextBox
- func (b *TextBox) BackwardChar()
- func (b *TextBox) BackwardWord()
- func (b *TextBox) Cursor() int
- func (b *TextBox) DeleteBackwardChar()
- func (b *TextBox) DeleteBackwardWord()
- func (b *TextBox) DeleteChar()
- func (b *TextBox) DeleteForwardWord()
- func (b *TextBox) ForwardChar()
- func (b *TextBox) ForwardWord()
- func (b *TextBox) InsertChar(r rune)
- func (b *TextBox) InsertString(str string)
- func (b *TextBox) KillLine()
- func (b *TextBox) KillLineAll()
- func (b *TextBox) MoveBottom()
- func (b *TextBox) MoveCursor(offset int)
- func (b *TextBox) MoveTop()
- func (b *TextBox) SetText(text string)
- func (b *TextBox) String() string
- func (b *TextBox) TextAfterCursor() string
- func (b *TextBox) TextBeforeCursor() string
- func (b *TextBox) WidthTextAfterCursor() int
- func (b *TextBox) WidthTextBeforeCursor() int
- type Widget
- type Window
- func (w *Window) Border()
- func (w *Window) BorderLR()
- func (w *Window) BorderStyle() BorderStyle
- func (w *Window) BorderUL()
- func (w *Window) Clear()
- func (w *Window) Draw()
- func (w *Window) Height() int
- func (w *Window) LeftBottom() (x, y int)
- func (w *Window) LeftTop() (x, y int)
- func (w *Window) Resize(x, y, width, height int)
- func (w *Window) ResizeRelative(x, y, width, height int)
- func (w *Window) RightBottom() (x, y int)
- func (w *Window) RightTop() (x, y int)
- func (w *Window) SetBorderStyle(style BorderStyle)
- func (w *Window) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteBytes ¶
DeleteBytes deletes bytes in offset position by length.
func EventToString ¶
func EventToString(ev *tcell.EventKey) string
EventToString converts the keyboard intput event to string. A meta key input event returns prefixed `M-'.
func InsertBytes ¶
InsertBytes inserts data to offset position.
Types ¶
type BorderStyle ¶
type BorderStyle int
BorderStyle is a window border style.
const ( // AllBorder is a style draws all lines and corners. AllBorder BorderStyle = iota // ULBorder is a style draws upper and lower lines. ULBorder // NoBorder dose not draw borders. NoBorder )
type Extmap ¶
Extmap represents callback functions for the widget input event on specified conditions.
type Keymap ¶
type Keymap map[string]func()
Keymap represents callback functions for the widget input event.
type ListBox ¶
type ListBox struct { *Window // contains filtered or unexported fields }
ListBox is a scrollable window listing contents.
func NewListBox ¶
NewListBox creates a new list box specified coordinates and sizes.
func (*ListBox) AdjustCursor ¶
func (b *ListBox) AdjustCursor()
AdjustCursor adjusts the cursor within range of upper and lower.
func (*ListBox) AdjustOffset ¶
func (b *ListBox) AdjustOffset()
AdjustOffset adjusts the offset within range of upper and lower.
func (*ListBox) AppendHighlightString ¶
AppendHighlightString appends a new highlighted content by the string to the end.
func (*ListBox) AppendList ¶
AppendList appends new contents to the end.
func (*ListBox) AppendString ¶
AppendString appends new contents by strings to the end.
func (*ListBox) ColumnAdjustContentsWidth ¶
func (b *ListBox) ColumnAdjustContentsWidth()
ColumnAdjustContentsWidth adjusts the column by list box constent widths. Fit to the widest content.
func (*ListBox) CurrentContent ¶
CurrentContent gets the content on the cursor.
func (*ListBox) CursorDown ¶
func (b *ListBox) CursorDown()
CursorDown moves the cursor to the down.
func (*ListBox) CursorToLeft ¶
func (b *ListBox) CursorToLeft()
CursorToLeft moves the cursor to the left.
func (*ListBox) CursorToRight ¶
func (b *ListBox) CursorToRight()
CursorToRight moves the cursor to the right.
func (*ListBox) IndexByName ¶
IndexByName returns the index to match content name.
func (*ListBox) MoveBottom ¶
func (b *ListBox) MoveBottom()
MoveBottom moves cursor to index of upper list.
func (*ListBox) ScrollRate ¶
ScrollRate returns rate of offset.
func (*ListBox) SetCursorByName ¶
SetCursorByName sets the cursor by the content name.
func (*ListBox) SetOffsetCenteredCursor ¶
func (b *ListBox) SetOffsetCenteredCursor()
SetOffsetCenteredCursor sets the offset so that centred cursor.
type ProgressGauge ¶
type ProgressGauge struct { *Window // contains filtered or unexported fields }
ProgressGauge is a progress bar changing with time.
func NewProgressGauge ¶
func NewProgressGauge(x, y, width, height int) *ProgressGauge
NewProgressGauge returns a new progress gauge specified coordinates and sizes.
func (*ProgressGauge) Draw ¶
func (b *ProgressGauge) Draw()
Draw the progress gauge from start time to now and estimated time of arrival.
func (*ProgressGauge) IsFinished ¶
func (b *ProgressGauge) IsFinished() bool
IsFinished reports whether finished.
func (*ProgressGauge) Start ¶
func (b *ProgressGauge) Start(maxval float64)
Start the timer from now.
func (*ProgressGauge) Update ¶
func (b *ProgressGauge) Update(value float64)
Update the current value.
type TextBox ¶
type TextBox struct { *Window Edithook func() // contains filtered or unexported fields }
TextBox is editable text box.
func NewTextBox ¶
NewTextBox returns the text box of specified size and coordinates.
func (*TextBox) BackwardChar ¶
func (b *TextBox) BackwardChar()
BackwardChar move backwards the editing cursor only a character.
func (*TextBox) BackwardWord ¶
func (b *TextBox) BackwardWord()
BackwardWord move backwards the editing cursor only a word.
func (*TextBox) DeleteBackwardChar ¶
func (b *TextBox) DeleteBackwardChar()
DeleteBackwardChar deletes a character on backward of editing cursor.
func (*TextBox) DeleteBackwardWord ¶
func (b *TextBox) DeleteBackwardWord()
DeleteBackwardWord deletes a word on backward of editing cursor.
func (*TextBox) DeleteChar ¶
func (b *TextBox) DeleteChar()
DeleteChar deletes a character on editing cursor.
func (*TextBox) DeleteForwardWord ¶
func (b *TextBox) DeleteForwardWord()
DeleteForwardWord deletes a word on forward of editing cursor.
func (*TextBox) ForwardChar ¶
func (b *TextBox) ForwardChar()
ForwardChar move forwards the editing cursor only a character.
func (*TextBox) ForwardWord ¶
func (b *TextBox) ForwardWord()
ForwardWord move forwards the editing cursor only a word.
func (*TextBox) InsertChar ¶
InsertChar inserts a character to position on editing cursor.
func (*TextBox) InsertString ¶
InsertString inserts string to position on editing cursor.
func (*TextBox) KillLine ¶
func (b *TextBox) KillLine()
KillLine deletes text on backward of editing cursor in line.
func (*TextBox) MoveBottom ¶
func (b *TextBox) MoveBottom()
MoveBottom sets cursor position to the bottom.
func (*TextBox) MoveCursor ¶
MoveCursor moves editing cursor.
func (*TextBox) TextAfterCursor ¶
TextAfterCursor returns the text after the cursor.
func (*TextBox) TextBeforeCursor ¶
TextBeforeCursor returns the text before the cursor.
func (*TextBox) WidthTextAfterCursor ¶
WidthTextAfterCursor returns width of text after the cursor.
func (*TextBox) WidthTextBeforeCursor ¶
WidthTextBeforeCursor returns width of text before the cursor.
type Widget ¶
type Widget interface { // Viewer and controller Draw() // sets cells to the terminal Input(key string) // the key event control // Connector Next() Widget // retruns a next widget for drawing and input Disconnect() // disconnect reference to the next widget for exiting // Window Width() int Height() int LeftTop() (x, y int) RightBottom() (x, y int) LeftBottom() (x, y int) RightTop() (x, y int) Resize(x, y, width, height int) ResizeRelative(x, y, width, height int) }
Widget describes a window manager in CUI.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window represents a quadrangular on coordinates of x and y.
func (*Window) BorderStyle ¶
func (w *Window) BorderStyle() BorderStyle
BorderStyle returns the border style.
func (*Window) LeftBottom ¶
LeftBottom returns left bottom coordinates of the window.
func (*Window) ResizeRelative ¶
ResizeRelative resizes relative to current sizes.
func (*Window) RightBottom ¶
RightBottom returns right bottom coordinates of the window.
func (*Window) SetBorderStyle ¶
func (w *Window) SetBorderStyle(style BorderStyle)
SetBorderStyle sets the border style.