Documentation ¶
Index ¶
- func GetTermboxHeight() int
- func GetTermboxWidth() int
- func MoveCursor(xOffset, y int, bufferLine string)
- func SplitBufferLines(stringToSplit string, width int) []string
- func TermboxPrint(x, y int, fg, bg termbox.Attribute, msg string)
- func TermboxPrintf(x, y int, fg, bg termbox.Attribute, format string, args ...interface{})
- type ButtonWidget
- func (this *ButtonWidget) AddCharKeyCallback(char rune, callback EventCallback)
- func (this *ButtonWidget) AddSpecialKeyCallback(key termbox.Key, callback EventCallback)
- func (this *ButtonWidget) CalculateSize()
- func (this *ButtonWidget) Draw()
- func (this *ButtonWidget) HandleEvents(event interface{})
- func (this *ButtonWidget) IsSelectable() bool
- func (this *ButtonWidget) IsSelected() bool
- func (this *ButtonWidget) Select()
- func (this *ButtonWidget) SetText(btnText string)
- func (this *ButtonWidget) Unselect()
- type CalcFunction
- type ColorizedString
- type ColorizedStringBuffer
- type ColorizedStringWidget
- func (this *ColorizedStringWidget) CalculateSize()
- func (this *ColorizedStringWidget) Draw()
- func (this *ColorizedStringWidget) HandleEvents(event interface{})
- func (this *ColorizedStringWidget) IsSelectable() bool
- func (this *ColorizedStringWidget) IsSelected() bool
- func (this *ColorizedStringWidget) Select()
- func (this *ColorizedStringWidget) Unselect()
- type EventCallback
- type LabelWidget
- func (this *LabelWidget) CalculateSize()
- func (this *LabelWidget) Draw()
- func (this *LabelWidget) HandleEvents(event interface{})
- func (this *LabelWidget) IsSelectable() bool
- func (this *LabelWidget) IsSelected() bool
- func (this *LabelWidget) Select()
- func (this *LabelWidget) SetText(text string)
- func (this *LabelWidget) Unselect()
- type PasswordInputWidget
- func (this *PasswordInputWidget) AddCharKeyCallback(char rune, callback EventCallback)
- func (this *PasswordInputWidget) AddSpecialKeyCallback(key termbox.Key, callback EventCallback)
- func (this *PasswordInputWidget) CalculateSize()
- func (this *PasswordInputWidget) Draw()
- func (this *PasswordInputWidget) GetBuffer() *TextInputBuffer
- func (this *PasswordInputWidget) HandleEvents(event interface{})
- func (this *PasswordInputWidget) IsSelectable() bool
- func (this *PasswordInputWidget) IsSelected() bool
- func (this *PasswordInputWidget) Select()
- func (this *PasswordInputWidget) Unselect()
- func (this *PasswordInputWidget) UseDefaultKeys(use bool)
- type Rectangle
- type Screen
- func (this *Screen) Activate()
- func (this *Screen) AddCharKeyCallback(char rune, callback EventCallback)
- func (this *Screen) AddSpecialKeyCallback(event termbox.Key, callback EventCallback)
- func (this *Screen) AddWidget(widget Widget)
- func (this *Screen) Deactivate()
- func (this *Screen) DoResize()
- func (this *Screen) Draw()
- func (this *Screen) GetCurrentSelectedWidget() (w Widget, ind int)
- func (this *Screen) GetSelectableWidgets() []Widget
- func (this *Screen) HandleEvents(event interface{})
- func (this *Screen) IsActive() bool
- func (this *Screen) SelectNextWidget()
- type ScreenPosition
- type StringBuffer
- type StringDisplayWidget
- func (this *StringDisplayWidget) CalculateSize()
- func (this *StringDisplayWidget) Draw()
- func (this *StringDisplayWidget) HandleEvents(event interface{})
- func (this *StringDisplayWidget) IsSelectable() bool
- func (this *StringDisplayWidget) IsSelected() bool
- func (this *StringDisplayWidget) Select()
- func (this *StringDisplayWidget) Unselect()
- type TextInputBuffer
- func (this *TextInputBuffer) Add(char rune)
- func (this *TextInputBuffer) Backspace()
- func (this *TextInputBuffer) Clear()
- func (this *TextInputBuffer) GetLines(lineLength, lineCount int) []string
- func (this *TextInputBuffer) IsEmpty() bool
- func (this *TextInputBuffer) ReturnAndClear() string
- func (this *TextInputBuffer) SetLength(length int)
- type TextInputWidget
- func (this *TextInputWidget) AddCharKeyCallback(char rune, callback EventCallback)
- func (this *TextInputWidget) AddSpecialKeyCallback(key termbox.Key, callback EventCallback)
- func (this *TextInputWidget) CalculateSize()
- func (this *TextInputWidget) Draw()
- func (this *TextInputWidget) GetBuffer() *TextInputBuffer
- func (this *TextInputWidget) HandleEvents(event interface{})
- func (this *TextInputWidget) IsSelectable() bool
- func (this *TextInputWidget) IsSelected() bool
- func (this *TextInputWidget) Select()
- func (this *TextInputWidget) Unselect()
- func (this *TextInputWidget) UseDefaultKeys(use bool)
- type UI
- func (this *UI) AddCharKeyCallback(char rune, callback EventCallback)
- func (this *UI) AddScreen(screen *Screen)
- func (this *UI) AddSpecialKeyCallback(event termbox.Key, callback EventCallback)
- func (this *UI) SetDrawDelay(delay int)
- func (this *UI) Shutdown()
- func (this *UI) Start(quitChan chan bool)
- type Widget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTermboxWidth ¶
func GetTermboxWidth() int
Gets only the termbox's width - since it constantly returns both values and we don't always want both, this is basically a wrapper around _ = h
func MoveCursor ¶
Move the cursor to the end of the provided string, starting at a given xOffset (not all widgets start at the left edge of the screen!)
func SplitBufferLines ¶
Splits up a string into a slice of strings, making "lines" of text to display. The criteria is to split by width (buffer widget width)
TODO It'd be nice to split on whitespace instead of in the middle of a word!
func TermboxPrint ¶
Prints a string to a termbox buffer. Takes the height and starting x position and then prints the string RTL
func TermboxPrintf ¶
Same as print_tb but takes a formatted string
Types ¶
type ButtonWidget ¶
type ButtonWidget struct {
// contains filtered or unexported fields
}
A widget which acts like a button. It can be selected and then "pressed" via a key binding.
func CreateButtonWidget ¶
func CreateButtonWidget(buttonText string, textPos ScreenPosition, defTextCol, selTextCol, defBgCol, selBgCol, defBorCol, selBorCol termbox.Attribute, calcFunction CalcFunction, selectable, selected bool) *ButtonWidget
A "constructor" function to create new widgets.
func (*ButtonWidget) AddCharKeyCallback ¶
func (this *ButtonWidget) AddCharKeyCallback(char rune, callback EventCallback)
Take widget level printable-key (rune) handler function
func (*ButtonWidget) AddSpecialKeyCallback ¶
func (this *ButtonWidget) AddSpecialKeyCallback(key termbox.Key, callback EventCallback)
Take widget level meta-key (termbox.Key) handler function
func (*ButtonWidget) CalculateSize ¶
func (this *ButtonWidget) CalculateSize()
Meant to be called when the terminal dimensions are resized, it calls the callback function and refigures out the sizing and positioning of the rectacngle.
func (*ButtonWidget) Draw ¶
func (this *ButtonWidget) Draw()
Draw the button every iteration of the main loop. Figure out where to put the button text within the button, make sure the borders get drawn and then draw the text in the figured out location.
func (*ButtonWidget) HandleEvents ¶
func (this *ButtonWidget) HandleEvents(event interface{})
If this widget is selected, handle key inputs based on mapped keys
func (*ButtonWidget) IsSelectable ¶
func (this *ButtonWidget) IsSelectable() bool
Check if this widget should be flaggable as selected.
func (*ButtonWidget) IsSelected ¶
func (this *ButtonWidget) IsSelected() bool
Check if this widget is flagged as selected. Accessor because eventually want to implement logic to test for isSelectable
func (*ButtonWidget) Select ¶
func (this *ButtonWidget) Select()
Selects this widget - it'd probably make sense to return an error if this widget isn't selectable
func (*ButtonWidget) SetText ¶
func (this *ButtonWidget) SetText(btnText string)
Setter for the button's displayed text.
type CalcFunction ¶
type CalcFunction func() (x1, x2, y1, y2 int)
Callback function used to dynamically resize the rectangle when the screen changes size
type ColorizedString ¶
type ColorizedString struct { Color termbox.Attribute Text string }
Holds a string and a color to print it in
type ColorizedStringBuffer ¶
type ColorizedStringBuffer struct {
// contains filtered or unexported fields
}
This type wraps a string slice to be used to display string-wrapper objects on the screen. The objects are simple tuples, containing the string and the color to display it as. Has a maximum size and will truncate old strings once this is reached
func (*ColorizedStringBuffer) Add ¶
func (this *ColorizedStringBuffer) Add(msg *ColorizedString)
Adds a new element to the end of the stack, and will clip anything over capacity off the bottom.
func (*ColorizedStringBuffer) Clear ¶
func (this *ColorizedStringBuffer) Clear()
Clear the buffer's contents.
func (*ColorizedStringBuffer) GetContents ¶
func (this *ColorizedStringBuffer) GetContents(lineLength, lineCount int) []*ColorizedString
Gets the lines out of the buffer. This will split any lines that are too long into two (or as many as it takes until they are shorter than line length) lines and then returns the last <lineCount> number of lines.
func (*ColorizedStringBuffer) Prepare ¶
func (this *ColorizedStringBuffer) Prepare(capacity int)
Call this to setup the slice when creating one of these
type ColorizedStringWidget ¶
type ColorizedStringWidget struct {
// contains filtered or unexported fields
}
A widget which essentially knows how to draw message objects. It relies on a buffer type which meets the TextBuffer interface being passed in.
To control where it is drawn on the screen, it uses a function value which returns the four corners of a rectangle, which represents it's location on the screen.
These shouldn't be created via new() - use the CreateColorizedTextWidget() call instead.
func CreateColorizedTextWidget ¶
func CreateColorizedTextWidget(textColor, borderColor, bgColor termbox.Attribute, calcFunction CalcFunction, buffer *ColorizedStringBuffer) *ColorizedStringWidget
A "constructor" function to create new widgets.
func (*ColorizedStringWidget) CalculateSize ¶
func (this *ColorizedStringWidget) CalculateSize()
Meant to be called when the terminal dimensions are resized, it calls the callback function and refigures out the sizing and positioning of the rectacngle.
func (*ColorizedStringWidget) Draw ¶
func (this *ColorizedStringWidget) Draw()
This is the draw call - it takes a buffer type which meets the text buffer interface and draws the text in it to the screen at the positions defined by its rectangle.
func (*ColorizedStringWidget) HandleEvents ¶
func (this *ColorizedStringWidget) HandleEvents(event interface{})
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.
func (*ColorizedStringWidget) IsSelectable ¶
func (this *ColorizedStringWidget) IsSelectable() bool
This widget cannot ever be selectable, so always return false.
func (*ColorizedStringWidget) IsSelected ¶
func (this *ColorizedStringWidget) IsSelected() bool
This widget cannot ever be selectable, so always return false.
func (*ColorizedStringWidget) Select ¶
func (this *ColorizedStringWidget) Select()
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.
func (*ColorizedStringWidget) Unselect ¶
func (this *ColorizedStringWidget) Unselect()
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.s
type EventCallback ¶
type EventCallback func(interface{}, interface{})
A callback function which can be mapped to a key in various levels of the interface. When the keybinding is detected, the callback is executed and passed a pointer to the ui element which was called and the key which was pressed.
The key pressed can either be a rune (for printable keys) or a meta character of type termbox.Key
type LabelWidget ¶
type LabelWidget struct {
// contains filtered or unexported fields
}
A widget which prints text to the screen, like a button but deliberately can't be selected.
func CreateLabelWidget ¶
func CreateLabelWidget(text string, drawBor bool, textPos ScreenPosition, textCol, bgCol, borCol termbox.Attribute, calcFunction CalcFunction) *LabelWidget
A "constructor" function to create new widgets.
func (*LabelWidget) CalculateSize ¶
func (this *LabelWidget) CalculateSize()
Meant to be called when the terminal dimensions are resized, it calls the callback function and refigures out the sizing and positioning of the rectacngle.
func (*LabelWidget) Draw ¶
func (this *LabelWidget) Draw()
Draw the label every iteration of the main loop. Figure out where to put the button text within the label, make sure the borders get drawn and then draw the text in the figured out location.
func (*LabelWidget) HandleEvents ¶
func (this *LabelWidget) HandleEvents(event interface{})
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.
func (*LabelWidget) IsSelectable ¶
func (this *LabelWidget) IsSelectable() bool
This widget cannot ever be selectable, so always return false.
func (*LabelWidget) IsSelected ¶
func (this *LabelWidget) IsSelected() bool
This widget cannot ever be selectable, so always return false.
func (*LabelWidget) Select ¶
func (this *LabelWidget) Select()
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.
func (*LabelWidget) SetText ¶
func (this *LabelWidget) SetText(text string)
Setter for the label's displayed text.
func (*LabelWidget) Unselect ¶
func (this *LabelWidget) Unselect()
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.s
type PasswordInputWidget ¶
type PasswordInputWidget struct {
// contains filtered or unexported fields
}
A widget meant for password input. It stores the real value in the buffer but it displays everything as an "*"
To control where it is drawn on the screen, it uses a function value which returns the four corners of a rectangle, which represents it's location on the screen.
These shouldn't be created via new() - use the CreatePasswordInputWidget() call instead.
func CreatePasswordInputWidget ¶
func CreatePasswordInputWidget(hasCursor bool, color termbox.Attribute, bg termbox.Attribute, selbg termbox.Attribute, calcFunction CalcFunction, buffer *TextInputBuffer, selectable bool, selected bool) *PasswordInputWidget
A "constructor" function to create new widgets.
func (*PasswordInputWidget) AddCharKeyCallback ¶
func (this *PasswordInputWidget) AddCharKeyCallback(char rune, callback EventCallback)
Take widget level printable-key (rune) handler function
func (*PasswordInputWidget) AddSpecialKeyCallback ¶
func (this *PasswordInputWidget) AddSpecialKeyCallback(key termbox.Key, callback EventCallback)
Take widget level meta-key (termbox.Key) handler function
func (*PasswordInputWidget) CalculateSize ¶
func (this *PasswordInputWidget) CalculateSize()
Meant to be called when the terminal dimensions are resized, it calls the callback function and refigures out the sizing and positioning of the rectacngle.
func (*PasswordInputWidget) Draw ¶
func (this *PasswordInputWidget) Draw()
This is the draw call - it takes a buffer type which meets the text buffer interface and draws the text in it to the screen at the positions defined by its rectangle.
func (*PasswordInputWidget) GetBuffer ¶
func (this *PasswordInputWidget) GetBuffer() *TextInputBuffer
Get the buffer - if we're able to switch selected items we'll probably want to be able to switch the buffer at the same time.
func (*PasswordInputWidget) HandleEvents ¶
func (this *PasswordInputWidget) HandleEvents(event interface{})
If this widget is selected, handle key inputs based on mapped keys
func (*PasswordInputWidget) IsSelectable ¶
func (this *PasswordInputWidget) IsSelectable() bool
Check if this widget should be flaggable as selected.
func (*PasswordInputWidget) IsSelected ¶
func (this *PasswordInputWidget) IsSelected() bool
Check if this widget is flagged as selected. Accessor because eventually want to implement logic to test for isSelectable
func (*PasswordInputWidget) Select ¶
func (this *PasswordInputWidget) Select()
Selects this widget - it'd probably make sense to return an error if this widget isn't selectable
func (*PasswordInputWidget) Unselect ¶
func (this *PasswordInputWidget) Unselect()
Unset selection status
func (*PasswordInputWidget) UseDefaultKeys ¶
func (this *PasswordInputWidget) UseDefaultKeys(use bool)
Enable using the default key bindings for the widget.
type Rectangle ¶
Represents a simple rectangle
func CreateRectangle ¶
Creates a new rectangle object
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Basically a widget holder at the moment
func (*Screen) AddCharKeyCallback ¶
func (this *Screen) AddCharKeyCallback(char rune, callback EventCallback)
Add a keybinding to the screen -- these override widget level keybindings so don't add keys here unless you're sure that the containing widgets won't need them.
This function is for printing keys - everything that normally prints a character to the screen. It takes runes as it's argument.
func (*Screen) AddSpecialKeyCallback ¶
func (this *Screen) AddSpecialKeyCallback(event termbox.Key, callback EventCallback)
Add a keybinding to the screen -- these override widget level keybindings so don't add keys here unless you're sure that the containing widgets won't need them.
This function is for metakeys (those of type termbox.Key) - nonprinting keys basically
func (*Screen) DoResize ¶
func (this *Screen) DoResize()
To call when the screen resizes - it cycles through each widget and forces them to recalculate
func (*Screen) Draw ¶
func (this *Screen) Draw()
Loop through our widgets and draw them all to the screen.
func (*Screen) GetCurrentSelectedWidget ¶
Iterate through the widgets and return the selected one or nil if there isn't one. Also returns position this widget was
func (*Screen) GetSelectableWidgets ¶
Get all of the selectable widgets held by the screen
func (*Screen) HandleEvents ¶
func (this *Screen) HandleEvents(event interface{})
Keyboard event handling. All calls to screen level callbacks get a pointer to the screen in question.
func (*Screen) SelectNextWidget ¶
func (this *Screen) SelectNextWidget()
Cycles through the selectable widgets
type ScreenPosition ¶
type ScreenPosition int
Represents positions - typically where text is inside a widget.
const ( // Positions TOP_LEFT ScreenPosition = 0 TOP_RIGHT ScreenPosition = 1 BOTTOM_LEFT ScreenPosition = 2 BOTTOM_RIGHT ScreenPosition = 3 CENTER ScreenPosition = 4 )
Declare some library wide constants
type StringBuffer ¶
type StringBuffer struct {
// contains filtered or unexported fields
}
This type wraps a string slice to be used to display strings on the screen. Has a maximum size and will truncate old strings once this is reached
func (*StringBuffer) Add ¶
func (this *StringBuffer) Add(str string)
Adds a new element to the end of the stack, and will clip anything over capacity off the bottom.
func (*StringBuffer) GetContents ¶
func (this *StringBuffer) GetContents(lineLength, lineCount int) []string
Gets the lines out of the buffer. This will split any lines that are too long into two (or as many as it takes until they are shorter than line length) lines and then returns the last <lineCount> number of lines.
func (*StringBuffer) Prepare ¶
func (this *StringBuffer) Prepare(capacity int)
Call this to setup the slice when creating one of these
type StringDisplayWidget ¶
type StringDisplayWidget struct {
// contains filtered or unexported fields
}
A widget which knows how to draw strings.
It pulls the strings from a buffer, which can be populated by the application. Unlike a text input widget, this is supposed to be a readonly widget.
To control where it is drawn on the screen, it uses a function value which returns the four corners of a rectangle, which represents it's location on the screen.
These shouldn't be created via new() - use the CreateColorizedTextWidget() call instead.
func CreateStringDisplayWidget ¶
func CreateStringDisplayWidget(textColor, borderColor, bgColor termbox.Attribute, calcFunction CalcFunction, buffer *StringBuffer) *StringDisplayWidget
A "constructor" function to create new widgets.
func (*StringDisplayWidget) CalculateSize ¶
func (this *StringDisplayWidget) CalculateSize()
Meant to be called when the terminal dimensions are resized, it calls the callback function and refigures out the sizing and positioning of the rectacngle.
func (*StringDisplayWidget) Draw ¶
func (this *StringDisplayWidget) Draw()
This is the draw call - it takes a buffer type which meets the text buffer interface and draws the text in it to the screen at the positions defined by its rectangle.
func (*StringDisplayWidget) HandleEvents ¶
func (this *StringDisplayWidget) HandleEvents(event interface{})
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.
func (*StringDisplayWidget) IsSelectable ¶
func (this *StringDisplayWidget) IsSelectable() bool
This widget cannot ever be selectable, so always return false.
func (*StringDisplayWidget) IsSelected ¶
func (this *StringDisplayWidget) IsSelected() bool
This widget cannot ever be selectable, so always return false.
func (*StringDisplayWidget) Select ¶
func (this *StringDisplayWidget) Select()
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.
func (*StringDisplayWidget) Unselect ¶
func (this *StringDisplayWidget) Unselect()
This kind of widget cannot be selected. For the moment do nothing, this is just here to satisfy the interface.s
type TextInputBuffer ¶
type TextInputBuffer struct {
// contains filtered or unexported fields
}
This buffer represents the storage for any field a user can type text into
func (*TextInputBuffer) Add ¶
func (this *TextInputBuffer) Add(char rune)
Adds a new element to the end of the stack (just a method form of append)
func (*TextInputBuffer) Backspace ¶
func (this *TextInputBuffer) Backspace()
Removes the last element from the buffer
func (*TextInputBuffer) GetLines ¶
func (this *TextInputBuffer) GetLines(lineLength, lineCount int) []string
Returns the text contents of this buffer as a slice of strings. The number of strings returned depends on how long the text the buffer contains and how long the desired lineLength is. lineLength can be set to 0 in order to force the buffer's contents into a single string and return a single element slice containing it.
Line count can optionally be used to return only the last n lines, if a maximum number of lines is a concern.
func (*TextInputBuffer) IsEmpty ¶
func (this *TextInputBuffer) IsEmpty() bool
Checks if this buffer is empty
func (*TextInputBuffer) ReturnAndClear ¶
func (this *TextInputBuffer) ReturnAndClear() string
Wraps the call to toString and then clear, which is what the enter key should do
func (*TextInputBuffer) SetLength ¶
func (this *TextInputBuffer) SetLength(length int)
type TextInputWidget ¶
type TextInputWidget struct {
// contains filtered or unexported fields
}
A widget which essentially knows how to draw a slice of strings. It relies on a buffer type which meets the TextBuffer interface being passed in.
To control where it is drawn on the screen, it uses a function value which returns the four corners of a rectangle, which represents it's location on the screen.
These shouldn't be created via new() - use the CreateTextInputBufferWidget() call instead.
func CreateTextInputWidget ¶
func CreateTextInputWidget(hasCursor bool, color termbox.Attribute, bg termbox.Attribute, selbg termbox.Attribute, calcFunction CalcFunction, buffer *TextInputBuffer, selectable bool, selected bool) *TextInputWidget
A "constructor" function to create new widgets.
func (*TextInputWidget) AddCharKeyCallback ¶
func (this *TextInputWidget) AddCharKeyCallback(char rune, callback EventCallback)
Take widget level printable-key (rune) handler function
func (*TextInputWidget) AddSpecialKeyCallback ¶
func (this *TextInputWidget) AddSpecialKeyCallback(key termbox.Key, callback EventCallback)
Take widget level meta-key (termbox.Key) handler function
func (*TextInputWidget) CalculateSize ¶
func (this *TextInputWidget) CalculateSize()
Meant to be called when the terminal dimensions are resized, it calls the callback function and refigures out the sizing and positioning of the rectacngle.
func (*TextInputWidget) Draw ¶
func (this *TextInputWidget) Draw()
This is the draw call - it takes a buffer type which meets the text buffer interface and draws the text in it to the screen at the positions defined by its rectangle.
func (*TextInputWidget) GetBuffer ¶
func (this *TextInputWidget) GetBuffer() *TextInputBuffer
Get the buffer - if we're able to switch selected items we'll probably want to be able to switch the buffer at the same time.
func (*TextInputWidget) HandleEvents ¶
func (this *TextInputWidget) HandleEvents(event interface{})
If this widget is selected, handle key inputs based on mapped keys
func (*TextInputWidget) IsSelectable ¶
func (this *TextInputWidget) IsSelectable() bool
Check if this widget should be flaggable as selected.
func (*TextInputWidget) IsSelected ¶
func (this *TextInputWidget) IsSelected() bool
Check if this widget is flagged as selected. Accessor because eventually want to implement logic to test for isSelectable
func (*TextInputWidget) Select ¶
func (this *TextInputWidget) Select()
Selects this widget - it'd probably make sense to return an error if this widget isn't selectable
func (*TextInputWidget) UseDefaultKeys ¶
func (this *TextInputWidget) UseDefaultKeys(use bool)
Enable using the default key bindings for the widget.
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
Represents the top level of a TermboxUIKit UI. It manages screens, handles the global level keyboard (or resize) events, and handles shutting the entire UI down.
func (*UI) AddCharKeyCallback ¶
func (this *UI) AddCharKeyCallback(char rune, callback EventCallback)
Adds a global level event binding for a printable key
func (*UI) AddSpecialKeyCallback ¶
func (this *UI) AddSpecialKeyCallback(event termbox.Key, callback EventCallback)
Adds a global level event binding for a meta key
func (*UI) SetDrawDelay ¶
Set the delay time between redraws, in milliseconds If this isn't set, it will default to 10 ms between refreshes, which can be plenty fast enough or very slow, depending on what you want your app to do. Using actual zero, even with minimal UI elements, quickly chews through CPU time.
type Widget ¶
type Widget interface { Draw() CalculateSize() // Handle widget selection IsSelectable() bool IsSelected() bool Select() Unselect() // Handle keyboard events -- this is an interface{} because // it can either be a termbox.Key or rune at the moment HandleEvents(interface{}) }
Interface defining widgets - a function to draw them to the screen and one to call when the screen is resized.