Documentation
¶
Index ¶
- Constants
- func SetLogger(l Logger)
- type Alignment
- type App
- type BorderBse
- func (x *BorderBse) ApplyStyle(isFocused ...bool)
- func (x *BorderBse) DrawBorder(p *Painter, fn func(*Painter, image.Point))
- func (x *BorderBse) Focus(prev ...bool) bool
- func (x *BorderBse) MeasureBorder() (borderSize, minSize image.Point)
- func (x *BorderBse) SetBorder(has bool)
- func (x *BorderBse) SetTitle(text string)
- func (x *BorderBse) Unfocus()
- type Box
- func (x *Box) Add(vs ...Ctrl)
- func (x *Box) Draw(p *Painter)
- func (x *Box) Focus(prev ...bool) bool
- func (x *Box) FocusNext() bool
- func (x *Box) FocusPrev() bool
- func (x *Box) FocusedIdx() int
- func (x *Box) Insert(i int, c Ctrl)
- func (x *Box) IsChildFocused(child Ctrl) bool
- func (x *Box) MinSizeHint() image.Point
- func (x *Box) OnKeyEvent(e KeyEvent)
- func (x *Box) Remove(i int)
- func (x *Box) Resize(size image.Point)
- func (x *Box) SizeHint() image.Point
- func (x *Box) String() string
- func (x *Box) Unfocus()
- type Color
- type Ctrl
- type CtrlBse
- func (x *CtrlBse) Bse() *CtrlBse
- func (x *CtrlBse) Draw(p *Painter)
- func (x *CtrlBse) Focus(prev ...bool) bool
- func (x *CtrlBse) FocusNext() bool
- func (x *CtrlBse) FocusPrev() bool
- func (x *CtrlBse) IsChildFocused(child Ctrl) bool
- func (x *CtrlBse) MinSizeHint() image.Point
- func (x *CtrlBse) OnKeyEvent(ev KeyEvent)
- func (x *CtrlBse) Resize(size image.Point)
- func (x *CtrlBse) SetSizePolicy(h, v SizePolicy)
- func (x *CtrlBse) SetSizePolicyX(h SizePolicy)
- func (x *CtrlBse) SetSizePolicyY(v SizePolicy)
- func (x *CtrlBse) Size() image.Point
- func (x *CtrlBse) SizeHint() image.Point
- func (x *CtrlBse) SizePolicy() (SizePolicy, SizePolicy)
- func (x *CtrlBse) Unfocus()
- type Decoration
- type Fle
- type HList
- type Itm
- type Key
- type KeyEvent
- type Label
- func (l *Label) Draw(p *Painter)
- func (l *Label) MinSizeHint() image.Point
- func (l *Label) Resize(size image.Point)
- func (l *Label) SetStyleName(style string)
- func (l *Label) SetText(text string)
- func (l *Label) SetWordWrap(enabled bool)
- func (l *Label) SizeHint() image.Point
- func (l *Label) Text() string
- type Length
- type LengthX
- type LengthY
- type List
- func (x *List) Add(vs ...Itm)
- func (x *List) ApplyStyle(isFocused bool)
- func (x *List) ClearItems()
- func (x *List) ClearSizeHints()
- func (x *List) Focus(prev ...bool) bool
- func (x *List) MinSizeHint() image.Point
- func (x *List) Navigate(i int, isFst ...bool)
- func (x *List) Next()
- func (x *List) OnItemActivated(fn func(*List))
- func (x *List) OnSelectionChanged(fn func(*List))
- func (x *List) Prev()
- func (x *List) RaiseActivate()
- func (x *List) RaiseSelectionChanged()
- func (x *List) RemoveAt(i int)
- func (x *List) Selected() int
- func (x *List) SelectedItem() Itm
- func (x *List) SetBorder(has bool)
- func (x *List) SetTitle(text string)
- func (x *List) SizeHint() image.Point
- func (x *List) Unfocus()
- type ListItem
- type Ln
- type Logger
- type ModMask
- type MouseEvent
- type Painter
- func (p *Painter) Begin()
- func (p *Painter) DrawCursor(x, y int)
- func (p *Painter) DrawHorizontalLine(x1, x2, y int)
- func (p *Painter) DrawRect(x, y, w, h int)
- func (p *Painter) DrawRune(x, y int, r rune)
- func (p *Painter) DrawText(x, y int, text string)
- func (p *Painter) DrawVerticalLine(x, y1, y2 int)
- func (p *Painter) End()
- func (p *Painter) FillRect(x, y, w, h int)
- func (p *Painter) Repaint(w Ctrl)
- func (p *Painter) Restore()
- func (p *Painter) SetStyle(s Style)
- func (p *Painter) Translate(x, y int)
- func (p *Painter) WithMask(r image.Rectangle, fn func(*Painter))
- func (p *Painter) WithStyle(s Style, fn func(*Painter))
- func (p *Painter) WithStyleKey(key string, fn func(*Painter))
- type ProBox
- func (x *ProBox) OnKeyEvent(e KeyEvent)
- func (x *ProBox) ParseCompleted(start time.Time, er error, reloaded bool)
- func (x *ProBox) ParseFle(reloaded ...bool)
- func (x *ProBox) ReloadFle()
- func (x *ProBox) RunCompleted(start time.Time, er error)
- func (x *ProBox) RunFle()
- func (x *ProBox) SetEllapsedTxt(ellapsed time.Duration)
- func (x *ProBox) SetFle(fle *Fle)
- func (x *ProBox) SetSizePolicy(h, v SizePolicy)
- func (x *ProBox) String() string
- func (x *ProBox) UpdateEllapsed(ellapsed time.Duration)
- type PrtBorder
- type PrtTitle
- type ReadBox
- func (x *ReadBox) ApplyStyle(isFocused ...bool)
- func (x *ReadBox) BufEnd()
- func (x *ReadBox) BufStart()
- func (x *ReadBox) CalcLines()
- func (x *ReadBox) Clear()
- func (x *ReadBox) ClearSizeHints()
- func (x *ReadBox) Draw(p *Painter)
- func (x *ReadBox) Focus(prev ...bool) bool
- func (x *ReadBox) LnNext()
- func (x *ReadBox) LnPrev()
- func (x *ReadBox) Measure()
- func (x *ReadBox) MinSizeHint() image.Point
- func (x *ReadBox) OnKeyEvent(e KeyEvent)
- func (x *ReadBox) PgNext()
- func (x *ReadBox) PgPrev()
- func (x *ReadBox) SetBorder(has bool)
- func (x *ReadBox) SetText(text string)
- func (x *ReadBox) SetTextf(format string, args ...interface{})
- func (x *ReadBox) SetTitle(text string)
- func (x *ReadBox) SizeHint() image.Point
- func (x *ReadBox) String() string
- func (x *ReadBox) Text() string
- func (x *ReadBox) Unfocus()
- type SizePolicy
- type Spacer
- type Style
- type Surface
- type Tab
- type Taber
- type Text
- type Theme
- type UI
- type UIBse
- type VList
Constants ¶
const ( KeyBackspace = KeyBS KeyTab = KeyTAB KeyEsc = KeyESC KeyEscape = KeyESC KeyEnter = KeyCR KeyBackspace2 = KeyDEL )
These are aliases for other keys.
const ( PrtBorderKey = "prt.border" PrtBorderFocusedKey = "prt.border.focused" PrtTitleKey = "prt.title" PrtTitleFocusedKey = "prt.title.focused" TextKey = "text" TextFocusedKey = "text.focused" ListItemKey = "list.item" ListItemSelectedKey = "list.item.selected" ListItemSelectedFocusedKey = "list.item.selected.focused" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alignment ¶
type Alignment int
Alignment is used to set the direction in which widgets are laid out.
type App ¶
type BorderBse ¶
type BorderBse struct {
CtrlBse
// contains filtered or unexported fields
}
func (*BorderBse) ApplyStyle ¶
func (*BorderBse) DrawBorder ¶
func (*BorderBse) MeasureBorder ¶
type Box ¶
type Box struct {
BorderBse
// Border bool
Title string
Alignment Alignment
// contains filtered or unexported fields
}
Box is a layout for placing widgets either horizontally or vertically. If horizontally, all widgets will have the same height. If vertically, they will all have the same width.
func (*Box) FocusedIdx ¶
func (*Box) IsChildFocused ¶
func (*Box) MinSizeHint ¶
MinSizeHint returns the minimum size hint for the layout.
func (*Box) OnKeyEvent ¶
func (*Box) Resize ¶
Resize recursively updates the size of the Box and all the widgets it contains. This is a potentially expensive operation and should be invoked with restraint.
Resize is called by the layout engine and is not intended to be used by end users.
type Ctrl ¶
type Ctrl interface {
Bse() *CtrlBse
Draw(p *Painter)
MinSizeHint() image.Point
Size() image.Point
SizeHint() image.Point
SizePolicy() (SizePolicy, SizePolicy)
Resize(size image.Point)
OnKeyEvent(ev KeyEvent)
Focus(prev ...bool) bool
Unfocus()
FocusPrev() bool
FocusNext() bool
IsChildFocused(child Ctrl) bool
}
Ctrl defines common operations on widgets.
type CtrlBse ¶
type CtrlBse struct {
Prnt Ctrl
// contains filtered or unexported fields
}
func (*CtrlBse) IsChildFocused ¶
func (*CtrlBse) MinSizeHint ¶
MinSizeHint returns the size below which the widget cannot shrink.
func (*CtrlBse) OnKeyEvent ¶
OnKeyEvent is an empty operation to fulfill the Ctrl interface.
func (*CtrlBse) SetSizePolicy ¶
func (x *CtrlBse) SetSizePolicy(h, v SizePolicy)
SetSizePolicy sets the size policy for horizontal and vertical directions.
func (*CtrlBse) SetSizePolicyX ¶
func (x *CtrlBse) SetSizePolicyX(h SizePolicy)
func (*CtrlBse) SetSizePolicyY ¶
func (x *CtrlBse) SetSizePolicyY(v SizePolicy)
func (*CtrlBse) SizePolicy ¶
func (x *CtrlBse) SizePolicy() (SizePolicy, SizePolicy)
SizePolicy returns the current size policy.
type Decoration ¶
type Decoration int
Decoration represents a bold/underline/etc. state
const ( DecorationInherit Decoration = iota DecorationOn DecorationOff )
Decoration modes: Inherit from parent widget, explicitly on, or explicitly off.
type Key ¶
type Key int16
Key represents both normal and special keys. For normal letters, KeyRune is used together with the Rune field in the KeyEvent.
const ( KeyRune Key = iota + 256 KeyUp KeyDown KeyRight KeyLeft KeyUpLeft KeyUpRight KeyDownLeft KeyDownRight KeyCenter KeyPgUp KeyPgDn KeyHome KeyEnd KeyInsert KeyDelete KeyHelp KeyExit KeyClear KeyCancel KeyPrint KeyPause KeyBacktab KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 KeyF21 KeyF22 KeyF23 KeyF24 KeyF25 KeyF26 KeyF27 KeyF28 KeyF29 KeyF30 KeyF31 KeyF32 KeyF33 KeyF34 KeyF35 KeyF36 KeyF37 KeyF38 KeyF39 KeyF40 KeyF41 KeyF42 KeyF43 KeyF44 KeyF45 KeyF46 KeyF47 KeyF48 KeyF49 KeyF50 KeyF51 KeyF52 KeyF53 KeyF54 KeyF55 KeyF56 KeyF57 KeyF58 KeyF59 KeyF60 KeyF61 KeyF62 KeyF63 KeyF64 )
These are named keys that can be handled.
const ( KeyCtrlSpace Key = iota KeyCtrlA KeyCtrlB KeyCtrlC KeyCtrlD KeyCtrlE KeyCtrlF KeyCtrlG KeyCtrlH KeyCtrlI KeyCtrlJ KeyCtrlK KeyCtrlL KeyCtrlM KeyCtrlN KeyCtrlO KeyCtrlP KeyCtrlQ KeyCtrlR KeyCtrlS KeyCtrlT KeyCtrlU KeyCtrlV KeyCtrlW KeyCtrlX KeyCtrlY KeyCtrlZ KeyCtrlLeftSq // Escape KeyCtrlBackslash KeyCtrlRightSq KeyCtrlCarat KeyCtrlUnderscore )
These are the supported control keys.
const ( KeyNUL Key = iota KeySOH KeySTX KeyETX KeyEOT KeyENQ KeyACK KeyBEL KeyBS KeyTAB KeyLF KeyVT KeyFF KeyCR KeySO KeySI KeyDLE KeyDC1 KeyDC2 KeyDC3 KeyDC4 KeyNAK KeySYN KeyETB KeyCAN KeyEM KeySUB KeyESC KeyFS KeyGS KeyRS KeyUS KeyDEL Key = 0x7F )
These are the defined ASCII values for key codes.
type Label ¶
type Label struct {
CtrlBse
// contains filtered or unexported fields
}
Label is a widget to display read-only text.
func (*Label) MinSizeHint ¶
MinSizeHint returns the minimum size the widget is allowed to be.
func (*Label) SetStyleName ¶
SetStyleName sets the identifier used for custom styling.
func (*Label) SetWordWrap ¶
SetWordWrap sets whether text content should be wrapped.
type LengthX ¶
func NewLengthX ¶
type LengthY ¶
func NewLengthY ¶
type List ¶
func (*List) ApplyStyle ¶
func (*List) ClearItems ¶
func (x *List) ClearItems()
func (*List) ClearSizeHints ¶
func (x *List) ClearSizeHints()
func (*List) MinSizeHint ¶
func (*List) OnItemActivated ¶
OnItemActivated gets called when activated (through pressing KeyEnter).
func (*List) OnSelectionChanged ¶
OnSelectionChanged gets called whenever a new item is selected.
func (*List) RaiseActivate ¶
func (x *List) RaiseActivate()
func (*List) RaiseSelectionChanged ¶
func (x *List) RaiseSelectionChanged()
func (*List) SelectedItem ¶
type Logger ¶
type Logger interface {
Printf(format string, args ...interface{})
}
Logger provides a interface for the standard logger.
type MouseEvent ¶
MouseEvent represents the event where a mouse button was pressed or released.
type Painter ¶
type Painter struct {
// contains filtered or unexported fields
}
Painter provides operations to paint on a surface.
func NewPainter ¶
NewPainter returns a new instance of Painter.
func (*Painter) DrawCursor ¶
DrawCursor draws the cursor at the given position.
func (*Painter) DrawHorizontalLine ¶
DrawHorizontalLine paints a horizontal line using box characters.
func (*Painter) DrawVerticalLine ¶
DrawVerticalLine paints a vertical line using box characters.
func (*Painter) Restore ¶
func (p *Painter) Restore()
Restore pops the latest transform from the stack.
func (*Painter) WithMask ¶
WithMask masks a painter to restrict painting within the given rectangle.
func (*Painter) WithStyle ¶
WithStyle executes the provided function with the named Style applied on top of the current one.
func (*Painter) WithStyleKey ¶
WithStyleKey executes the provided function with the named Style applied on top of the current one.
type ProBox ¶
type ProBox struct {
Box
// contains filtered or unexported fields
}
func (*ProBox) OnKeyEvent ¶
func (*ProBox) ParseCompleted ¶
func (*ProBox) SetEllapsedTxt ¶
func (*ProBox) SetSizePolicy ¶
func (x *ProBox) SetSizePolicy(h, v SizePolicy)
func (*ProBox) UpdateEllapsed ¶
type PrtBorder ¶
type PrtBorder struct {
Style Style
}
func NewPrtBorder ¶
func (*PrtBorder) ApplyStyle ¶
type PrtTitle ¶
type PrtTitle struct {
Style Style
// contains filtered or unexported fields
}
func NewPrtTitle ¶
func (*PrtTitle) ApplyStyle ¶
type ReadBox ¶
func NewReadBox ¶
func (*ReadBox) ApplyStyle ¶
func (*ReadBox) ClearSizeHints ¶
func (x *ReadBox) ClearSizeHints()
func (*ReadBox) MinSizeHint ¶
func (*ReadBox) OnKeyEvent ¶
type SizePolicy ¶
type SizePolicy int
SizePolicy determines the space occupied by a widget.
const ( // Preferred interprets the size hint as the preferred size. Preferred SizePolicy = iota // Minimum allows the widget to shrink down to the size hint. Minimum // Maximum allows the widget to grow up to the size hint. Maximum // Expanding makes the widget expand to the available space. Expanding )
type Spacer ¶
type Spacer struct {
CtrlBse
}
Spacer is a widget to fill out space.
func (*Spacer) MinSizeHint ¶
MinSizeHint returns the minimum size the widget is allowed to be.
func (*Spacer) SizePolicy ¶
func (s *Spacer) SizePolicy() (SizePolicy, SizePolicy)
SizePolicy returns the default layout behavior.
type Style ¶
type Style struct {
Fg Color
Bg Color
Reverse Decoration
Bold Decoration
Underline Decoration
}
Style determines how a cell should be painted. The zero value uses default from
type Surface ¶
type Surface interface {
SetCell(x, y int, ch rune, s Style)
SetCursor(x, y int)
HideCursor()
Begin()
End()
Size() image.Point
}
Surface defines a surface that can be painted on.
type Taber ¶
type Taber struct {
*Box
// contains filtered or unexported fields
}
func (*Taber) OnKeyEvent ¶
func (*Taber) SelectedTab ¶
func (*Taber) TabChanged ¶
type Theme ¶
type Theme struct {
// contains filtered or unexported fields
}
Theme defines the styles for a set of identifiers.
type UI ¶
type UI struct {
*UIBse
App *App
Main *Box
MainLeft *VList
MainRight *ProBox
Btm *Box
ScriptTaber *Taber
Console *ReadBox
HasLeft bool
HasBtm bool
}
func (*UI) LoadScripts ¶
func (x *UI) LoadScripts()
func (*UI) ToggleLeft ¶
func (x *UI) ToggleLeft()
type UIBse ¶
type UIBse struct {
Root *Box
// contains filtered or unexported fields
}
func (*UIBse) ClearKeybindings ¶
func (x *UIBse) ClearKeybindings()
ClearKeybindings reinitialises ui.keybindings so as to revert to a clear/original state
func (*UIBse) SetKeybinding ¶
func (*UIBse) Update ¶
func (x *UIBse) Update(fn func())
Schedule an update of the UIBse, running the given function in the UIBse goroutine.
Use this to update the UIBse in response to external events, like a timer tick. This method should be used any time you call methods to change UIBse objects after the first call to `UIBse.Run()`.
Changes invoked outside of either this callback or the other event handler callbacks may appear to work, but is likely a race condition. (Run your program with `go run -race` or `go install -race` to detect this!)
Calling Update from within an event handler, or from within an Update call, is an error, and will deadlock.