Documentation
¶
Index ¶
- func ConsoleBell()
- func FormatDuration(t time.Duration) string
- func Min[T constraints.Ordered](a, b T) T
- func WrapLine(text string, width int) (string, int)
- func WrapText(text string, width int) (string, int)
- type BuildMeta
- type FocusDirection
- type FocusFilterResult
- type FocusManager
- func (f *FocusManager) AddArrowNavigation(directions ...FocusDirection)
- func (f *FocusManager) HandleKeyEvent(event *tcell.EventKey) *tcell.EventKey
- func (f *FocusManager) ParentHasFocus() bool
- func (f *FocusManager) SetFilter(filter FocusManagerFilterHandler)
- func (f *FocusManager) SetHandler(handler FocusManagerHandler)
- func (f *FocusManager) SetLenientArrowNavigation()
- func (f *FocusManager) SetName(name string)
- func (f *FocusManager) SetPrimitives(primitives ...tview.Primitive)
- type FocusManagerFilterHandler
- type FocusManagerHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
FormatDuration returns a human friendly string representing the given duration (ie: 1.23 s).
func Min ¶
func Min[T constraints.Ordered](a, b T) T
Min returns the lesser of the two comparable values.
func WrapLine ¶
WrapLine inserts newlines so that the given text contains at most width characters per line. The newly wrapped string and the number of lines are returned. This function does not consider existing newline characters in the given text; wse WrapText instead if that's the case.
func WrapText ¶
WrapText inserts newlines so that the given text contains at most width characters per line. The newly wrapped string and the number of lines are returned. Empty strings are considered to be on one line. If the text contains newlines, each line will be considered separately. This function does not consider words; it strictly wraps only on characters.
Types ¶
type FocusDirection ¶
type FocusDirection int
const ( FocusUp FocusDirection = iota FocusDown FocusLeft FocusRight )
type FocusFilterResult ¶
type FocusFilterResult int
const ( // FocusPreHandlePropagate indicates the event should be propagated up the focus chain. FocusPreHandlePropagate FocusFilterResult = iota // FocusPreHandleIgnore indicates the event should not be handled at all. FocusPreHandleIgnore // FocusPreHandleProcess indicates the event should be handled by the current focus manager as usual. FocusPreHandleProcess )
type FocusManager ¶
type FocusManager struct {
// contains filtered or unexported fields
}
FocusManager is a utility that manages and handles changing focus amongst a set of primitives. An optional parent may be passed that will receive focus when the escape key is pressed.
func NewFocusManager ¶
func NewFocusManager(sender any, application *tview.Application, dispatcher *events.EventDispatcher, parent tview.Primitive, primitives ...tview.Primitive) *FocusManager
NewFocusManager creates a new instance of FocusManager to manage the given set of primitives.
func (*FocusManager) AddArrowNavigation ¶
func (f *FocusManager) AddArrowNavigation(directions ...FocusDirection)
AddArrowNavigation enables dispatching a directional navigation event if the given arrow key event(s) are received while the parent primitive has focus.
func (*FocusManager) HandleKeyEvent ¶
func (f *FocusManager) HandleKeyEvent(event *tcell.EventKey) *tcell.EventKey
HandleKeyEvent processes a keyboard event and changes which primitive is focused.
func (*FocusManager) ParentHasFocus ¶
func (f *FocusManager) ParentHasFocus() bool
ParentHasFocus returns true if the parent primitive currently has focus, false if not.
func (*FocusManager) SetFilter ¶
func (f *FocusManager) SetFilter(filter FocusManagerFilterHandler)
SetFilter sets the function to invoke that determines if a key event should be processed.
func (*FocusManager) SetHandler ¶
func (f *FocusManager) SetHandler(handler FocusManagerHandler)
SetHandler sets the function to invoke when the FocusManager does not handle a key event. This can be useful for chaining instances of FocusManager and other key event handlers.
func (*FocusManager) SetLenientArrowNavigation ¶
func (f *FocusManager) SetLenientArrowNavigation()
SetLenientArrowNavigation allows arrow navigation to occur without requiring the parent primitive to have focus.
func (*FocusManager) SetName ¶
func (f *FocusManager) SetName(name string)
SetName sets the name of the focus manager to distinguish it from others.
func (*FocusManager) SetPrimitives ¶
func (f *FocusManager) SetPrimitives(primitives ...tview.Primitive)
SetPrimitives sets the primitives that should receive focus. This will replace any previously configured primitives.
type FocusManagerFilterHandler ¶
type FocusManagerFilterHandler func(event *tcell.EventKey) FocusFilterResult
type FocusManagerHandler ¶
type FocusManagerHandler func(event *tcell.EventKey) *tcell.EventKey