Documentation ¶
Index ¶
- Constants
- type Box
- type EchoMode
- type Input
- func (s *Input) DoEvent(ev Event)
- func (e *Input) DoKeyEvent(ev Event)
- func (e *Input) Draw(buf *Buffer)
- func (e *Input) OnChanged(fn func(Input *Input))
- func (e *Input) OnSubmit(fn func(Input *Input))
- func (l *Input) Resize(pos image.Point, size image.Point)
- func (e *Input) SetEchoMode(m EchoMode)
- func (e *Input) SetText(text string)
- func (e *Input) SizeHint() image.Point
- func (e *Input) Text() string
- type Label
- func (l *Label) Draw(buf *Buffer)
- func (l *Label) MinSizeHint() image.Point
- func (l *Label) Resize(pos image.Point, 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 LayoutMode
- type RuneBuffer
- func (r *RuneBuffer) Backspace()
- func (r *RuneBuffer) CursorPos() image.Point
- func (r *RuneBuffer) Delete()
- func (r *RuneBuffer) Kill()
- func (r *RuneBuffer) Len() int
- func (r *RuneBuffer) MoveBackward()
- func (r *RuneBuffer) MoveForward()
- func (r *RuneBuffer) MoveToLineEnd()
- func (r *RuneBuffer) MoveToLineStart()
- func (r *RuneBuffer) Pos() int
- func (r *RuneBuffer) Runes() []rune
- func (r *RuneBuffer) Set(buf []rune)
- func (r *RuneBuffer) SetMaxWidth(w int)
- func (r *RuneBuffer) SetWithIdx(idx int, buf []rune)
- func (r *RuneBuffer) SplitByLine() []string
- func (r *RuneBuffer) String() string
- func (r *RuneBuffer) Width() int
- func (r *RuneBuffer) WriteRune(s rune)
- func (r *RuneBuffer) WriteRunes(s []rune)
- type SizePolicy
- type Space
- type UI
- type Widget
- type WidgetBase
- func (s *WidgetBase) Append(w Widget)
- func (s *WidgetBase) DoEvent(e Event)
- func (s *WidgetBase) Draw(buf *Buffer)
- func (s *WidgetBase) GetParentMin() image.Point
- func (s *WidgetBase) Init()
- func (s *WidgetBase) Insert(i int, w Widget)
- func (w *WidgetBase) IsActive() bool
- func (w *WidgetBase) IsFocused() bool
- func (s *WidgetBase) LayoutMode() LayoutMode
- func (s *WidgetBase) Length() int
- func (s *WidgetBase) MinSizeHint() image.Point
- func (s *WidgetBase) OnEvent(fn func(w Widget, e *Event))
- func (s *WidgetBase) Prepend(w Widget)
- func (s *WidgetBase) ReLayout()
- func (s *WidgetBase) Remove(i int)
- func (s *WidgetBase) Resize(pos image.Point, size image.Point)
- func (w *WidgetBase) SetActive(a bool)
- func (s *WidgetBase) SetBorder(enabled bool)
- func (w *WidgetBase) SetFocused(f bool)
- func (w *WidgetBase) SetHeight(height int)
- func (w *WidgetBase) SetParent(p Widget)
- func (w *WidgetBase) SetStyle(style Style)
- func (w *WidgetBase) SetText(text string)
- func (s *WidgetBase) SetTitle(title string)
- func (w *WidgetBase) SetWidth(width int)
- func (s *WidgetBase) SizeHint() image.Point
- func (w *WidgetBase) SizePolicy() (SizePolicy, SizePolicy)
Constants ¶
const ( KeyF1 = "<F1>" KeyF2 = "<F2>" KeyF3 = "<F3>" KeyF4 = "<F4>" KeyF5 = "<F5>" KeyF6 = "<F6>" KeyF7 = "<F7>" KeyF8 = "<F8>" KeyF9 = "<F9>" KeyF10 = "<F10>" KeyF11 = "<F11>" KeyF12 = "<F12>" KeyInsert = "<Insert>" KeyDelete = "<Delete>" KeyHome = "<Home>" KeyEnd = "<End>" KeyPgup = "<PageUp>" KeyPgdn = "<PageDown>" KeyArrowUp = "<Up>" KeyArrowDown = "<Down>" KeyArrowLeft = "<Left>" KeyArrowRight = "<Right>" KeyCtrlSpace = "<C-<Space>>" // KeyCtrl2 KeyCtrlTilde KeyCtrlA = "<C-a>" KeyCtrlB = "<C-b>" KeyCtrlC = "<C-c>" KeyCtrlD = "<C-d>" KeyCtrlE = "<C-e>" KeyCtrlF = "<C-f>" KeyCtrlG = "<C-g>" KeyBackspace = "<C-<Backspace>>" // KeyCtrlH KeyTab = "<Tab>" // KeyCtrlI KeyCtrlJ = "<C-j>" KeyCtrlK = "<C-k>" KeyCtrlL = "<C-l>" KeyEnter = "<Enter>" // KeyCtrlM KeyCtrlN = "<C-n>" KeyCtrlO = "<C-o>" KeyCtrlP = "<C-p>" KeyCtrlQ = "<C-q>" KeyCtrlR = "<C-r>" KeyCtrlS = "<C-s>" KeyCtrlT = "<C-t>" KeyCtrlU = "<C-u>" KeyCtrlV = "<C-v>" KeyCtrlW = "<C-w>" KeyCtrlX = "<C-x>" KeyCtrlY = "<C-y>" KeyCtrlZ = "<C-z>" KeyEsc = "<Escape>" // KeyCtrlLsqBracket KeyCtrl3 KeyCtrl4 = "<C-4>" // KeyCtrlBackslash KeyCtrl5 = "<C-5>" // KeyCtrlRsqBracket KeyCtrl6 = "<C-6>" KeyCtrl7 = "<C-7>" // KeyCtrlSlash KeyCtrlUnderscore KeySpace = "<Space>" KeyBackspace2 = "<Backspace>" // KeyCtrl8: )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Box ¶
type Box struct {
WidgetBase
}
type EchoMode ¶
type EchoMode int
EchoMode is used to determine the visibility of Input text.
const ( // EchoModeNormal displays the characters as they're being entered. EchoModeNormal EchoMode = iota // EchoModeNoEcho disables text display. This is useful for when the length // of the password should be kept secret. EchoModeNoEcho // EchoModePassword replaces all characters with asterisks. EchoModePassword )
type Input ¶
type Input struct { WidgetBase // contains filtered or unexported fields }
Input is a one-line text editor. It lets the user supply the application with text, e.g., to input user and password information.
func (*Input) OnChanged ¶
OnChanged sets a function to be run whenever the content of the Input has been changed.
func (*Input) OnSubmit ¶
OnSubmit sets a function to be run whenever the user submits the Input (by pressing KeyEnter).
func (*Input) SetEchoMode ¶
SetEchoMode sets the echo mode of the Input.
type Label ¶
type Label struct { WidgetBase // 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 LayoutMode ¶
type LayoutMode int
Alignment is used to set the direction in which widgets are laid out.
const ( Horizontal LayoutMode = iota Vertical )
Available alignment options.
type RuneBuffer ¶
type RuneBuffer struct {
// contains filtered or unexported fields
}
RuneBuffer provides readline functionality for text widgets.
func (*RuneBuffer) Backspace ¶
func (r *RuneBuffer) Backspace()
Backspace deletes the rune left of the cursor.
func (*RuneBuffer) CursorPos ¶
func (r *RuneBuffer) CursorPos() image.Point
CursorPos returns the coordinate for the cursor for a given width.
func (*RuneBuffer) Delete ¶
func (r *RuneBuffer) Delete()
Delete deletes the rune at the current cursor position.
func (*RuneBuffer) Kill ¶
func (r *RuneBuffer) Kill()
Kill deletes all runes from the cursor until the end of the line.
func (*RuneBuffer) Len ¶
func (r *RuneBuffer) Len() int
Len returns the number of runes in the buffer.
func (*RuneBuffer) MoveBackward ¶
func (r *RuneBuffer) MoveBackward()
MoveBackward moves the cursor back by one rune.
func (*RuneBuffer) MoveForward ¶
func (r *RuneBuffer) MoveForward()
MoveForward moves the cursor forward by one rune.
func (*RuneBuffer) MoveToLineEnd ¶
func (r *RuneBuffer) MoveToLineEnd()
MoveToLineEnd moves the cursor to the end of the current line.
func (*RuneBuffer) MoveToLineStart ¶
func (r *RuneBuffer) MoveToLineStart()
MoveToLineStart moves the cursor to the start of the current line.
func (*RuneBuffer) Pos ¶
func (r *RuneBuffer) Pos() int
Pos returns the current index in the buffer.
func (*RuneBuffer) Set ¶
func (r *RuneBuffer) Set(buf []rune)
Set the buffer and the index at the end of the buffer.
func (*RuneBuffer) SetMaxWidth ¶
func (r *RuneBuffer) SetMaxWidth(w int)
SetMaxWidth sets the maximum text width.
func (*RuneBuffer) SetWithIdx ¶
func (r *RuneBuffer) SetWithIdx(idx int, buf []rune)
SetWithIdx set the the buffer with a given index.
func (*RuneBuffer) SplitByLine ¶
func (r *RuneBuffer) SplitByLine() []string
SplitByLine returns the lines for a given width.
func (*RuneBuffer) String ¶
func (r *RuneBuffer) String() string
func (*RuneBuffer) Width ¶
func (r *RuneBuffer) Width() int
Width returns the width of the rune buffer, taking into account for CJK.
func (*RuneBuffer) WriteRune ¶
func (r *RuneBuffer) WriteRune(s rune)
WriteRune appends a rune to the buffer.
func (*RuneBuffer) WriteRunes ¶
func (r *RuneBuffer) WriteRunes(s []rune)
WriteRunes appends runes to the buffer.
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 UI ¶
type UI interface { // SetWidget sets the root widget of the UI. //SetWidget(w Widget) // SetTheme sets the current theme of the UI. //SetTheme(p *Theme) // SetKeybinding sets the callback for when a key sequence is pressed. SetKeybinding(seq string, fn func()) // ClearKeybindings removes all previous set keybindings. ClearKeybindings() // SetFocusChain sets a chain of widgets that determines focus order. //SetFocusChain(ch FocusChain) // Run starts the UI goroutine and blocks either Quit was called or an error occurred. Run() error // Update schedules work in the UI thread and await its completion. // Note that calling Update from the UI thread will result in deadlock. Update(fn func()) // Quit shuts down the UI goroutine. Quit() // Repaint the UI Repaint() Close() }
UI defines the operations needed by the underlying engine.
type Widget ¶
type Widget interface { Drawable SetFocused(bool) IsFocused() bool SetActive(a bool) IsActive() bool SetParent(p Widget) DoEvent(e Event) OnEvent(fn func(w Widget, e *Event)) Append(w Widget) Prepend(w Widget) Insert(i int, w Widget) Remove(i int) Length() int SetBorder(enabled bool) SetTitle(title string) SetText(text string) LayoutMode() LayoutMode //子元素排列布局 SizePolicy() (SizePolicy, SizePolicy) //显示模式 MinSizeHint() image.Point SizeHint() image.Point Resize(pos image.Point, size image.Point) ReLayout() //重新布局 sync.Locker }
type WidgetBase ¶
type WidgetBase struct { Block // contains filtered or unexported fields }
func (*WidgetBase) Append ¶
func (s *WidgetBase) Append(w Widget)
Append adds the given widget at the end of the Box.
func (*WidgetBase) DoEvent ¶
func (s *WidgetBase) DoEvent(e Event)
func (*WidgetBase) Draw ¶
func (s *WidgetBase) Draw(buf *Buffer)
func (*WidgetBase) GetParentMin ¶
func (s *WidgetBase) GetParentMin() image.Point
func (*WidgetBase) Init ¶
func (s *WidgetBase) Init()
func (*WidgetBase) Insert ¶
func (s *WidgetBase) Insert(i int, w Widget)
Insert adds the widget into the Box at a given index.
func (*WidgetBase) IsActive ¶
func (w *WidgetBase) IsActive() bool
IsActive returns whether the widget is active.
func (*WidgetBase) IsFocused ¶
func (w *WidgetBase) IsFocused() bool
IsFocused returns whether the widget is focused.
func (*WidgetBase) LayoutMode ¶
func (s *WidgetBase) LayoutMode() LayoutMode
Alignment returns the current alignment of the Box.
func (*WidgetBase) Length ¶
func (s *WidgetBase) Length() int
Length returns the number of items in the box.
func (*WidgetBase) MinSizeHint ¶
func (s *WidgetBase) MinSizeHint() image.Point
MinSizeHint returns the minimum size hint for the layout.
func (*WidgetBase) OnEvent ¶
func (s *WidgetBase) OnEvent(fn func(w Widget, e *Event))
func (*WidgetBase) Prepend ¶
func (s *WidgetBase) Prepend(w Widget)
Prepend adds the given widget at the start of the Box.
func (*WidgetBase) Remove ¶
func (s *WidgetBase) Remove(i int)
Remove deletes the widget from the Box at a given index.
func (*WidgetBase) SetBorder ¶
func (s *WidgetBase) SetBorder(enabled bool)
SetBorder sets whether the border is visible or not.
func (*WidgetBase) SetFocused ¶
func (w *WidgetBase) SetFocused(f bool)
SetFocused focuses the widget.
func (*WidgetBase) SetHeight ¶
func (w *WidgetBase) SetHeight(height int)
SetHeight returns whether the widget is active.
func (*WidgetBase) SetParent ¶
func (w *WidgetBase) SetParent(p Widget)
SetActive active the widget.
func (*WidgetBase) SetStyle ¶
func (w *WidgetBase) SetStyle(style Style)
IsActive returns whether the widget is active.
func (*WidgetBase) SetTitle ¶
func (s *WidgetBase) SetTitle(title string)
SetTitle sets the title of the box.
func (*WidgetBase) SetWidth ¶
func (w *WidgetBase) SetWidth(width int)
SetWidth returns whether the widget is active.
func (*WidgetBase) SizeHint ¶
func (s *WidgetBase) SizeHint() image.Point
SizeHint returns the recommended size hint for the layout.
func (*WidgetBase) SizePolicy ¶
func (w *WidgetBase) SizePolicy() (SizePolicy, SizePolicy)
SizePolicy returns the current size policy.