Documentation ¶
Index ¶
- Constants
- Variables
- func ASCIItoTviewColors(text string) string
- func BuildStars(data []Bar, maxStars int, starChar string) string
- func CenterText(str string, width int) string
- func ColorFor(label string) tcell.Color
- func Exclude(strs []string, val string) bool
- func ExecuteCommand(cmd *exec.Cmd) string
- func FindMatch(pattern string, data string) [][]string
- func HighlightableHelper(view *tview.TextView, input string, idx, offset int) string
- func IsToday(date time.Time) bool
- func MapToStrs(aMap map[string]interface{}) map[string]string
- func NameFromEmail(email string) string
- func NamesFromEmails(emails []string) []string
- func NewBillboardModal(text string, closeFunc func()) *tview.Frame
- func Now() time.Time
- func OpenFile(path string)
- func PadRow(offset int, max int) string
- func PrettyDate(dateStr string) string
- func ReadFileBytes(filePath string) ([]byte, error)
- func Schedule(widget Wtfable)
- func ToInts(slice []interface{}) []int
- func ToStrs(slice []interface{}) []string
- func Tomorrow() time.Time
- func UnixTime(unix int64) time.Time
- func ValidateWidgets(widgets []Wtfable)
- type Bar
- type BarGraph
- func (widget *BarGraph) BorderColor() string
- func (widget *BarGraph) BuildBars(data []Bar)
- func (widget *BarGraph) CommonSettings() *cfg.Common
- func (widget *BarGraph) ConfigText() string
- func (widget *BarGraph) Disable()
- func (widget *BarGraph) Disabled() bool
- func (widget *BarGraph) Enabled() bool
- func (widget *BarGraph) FocusChar() string
- func (widget *BarGraph) Focusable() bool
- func (widget *BarGraph) HelpText() string
- func (widget *BarGraph) Key() string
- func (widget *BarGraph) Name() string
- func (widget *BarGraph) RefreshInterval() int
- func (widget *BarGraph) Refreshing() bool
- func (widget *BarGraph) SetFocusChar(char string)
- func (widget *BarGraph) TextView() *tview.TextView
- type Display
- type Enablable
- type FocusState
- type FocusTracker
- type KeyboardWidget
- func (widget *KeyboardWidget) HelpText() string
- func (widget *KeyboardWidget) InputCapture(event *tcell.EventKey) *tcell.EventKey
- func (widget *KeyboardWidget) SetKeyboardChar(char string, fn func(), helpText string)
- func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func(), helpText string)
- func (widget *KeyboardWidget) SetView(view *tview.TextView)
- func (widget *KeyboardWidget) ShowHelp()
- type MultiSourceWidget
- type Schedulable
- type ScrollableWidget
- func (widget *ScrollableWidget) GetSelected() int
- func (widget *ScrollableWidget) Next()
- func (widget *ScrollableWidget) Prev()
- func (widget *ScrollableWidget) Redraw(title, content string, wrap bool)
- func (widget *ScrollableWidget) RowColor(idx int) string
- func (widget *ScrollableWidget) SetItemCount(items int)
- func (widget *ScrollableWidget) SetRenderFunction(displayFunc func())
- func (widget *ScrollableWidget) Unselect()
- type TextWidget
- func (widget *TextWidget) BorderColor() string
- func (widget *TextWidget) Bordered() bool
- func (widget *TextWidget) CommonSettings() *cfg.Common
- func (widget *TextWidget) ConfigText() string
- func (widget *TextWidget) ContextualTitle(defaultStr string) string
- func (widget *TextWidget) Disable()
- func (widget *TextWidget) Disabled() bool
- func (widget *TextWidget) Enabled() bool
- func (widget *TextWidget) FocusChar() string
- func (widget *TextWidget) Focusable() bool
- func (widget *TextWidget) HelpText() string
- func (widget *TextWidget) Name() string
- func (widget *TextWidget) Redraw(title, text string, wrap bool)
- func (widget *TextWidget) RefreshInterval() int
- func (widget *TextWidget) Refreshing() bool
- func (widget *TextWidget) SetFocusChar(char string)
- func (widget *TextWidget) String() string
- func (widget *TextWidget) TextView() *tview.TextView
- type Wtfable
Constants ¶
const DateFormat = "2006-01-02"
DateFormat defines the format we expect to receive dates from BambooHR in
const FriendlyDateFormat = "Mon, Jan 2"
const FriendlyDateTimeFormat = "Mon, Jan 2, 15:04"
const FullDateFormat = "Monday, Jan 2"
const MinimumTimeFormat = "15:04"
const SimpleDateFormat = "Jan 2"
const SimpleTimeFormat = "15:04 MST"
const TimeFormat = "15:04"
const TimestampFormat = "2006-01-02T15:04:05-0700"
Variables ¶
var OpenFileUtil = "open"
Functions ¶
func ASCIItoTviewColors ¶ added in v0.9.2
func BuildStars ¶ added in v0.0.10
BuildStars build the string to display
func CenterText ¶
CenterText takes a string and a width and pads the left and right of the string with empty spaces to ensure that the string is in the middle of the returned value
Example:
x := CenterText("cat", 11) > " cat "
func Exclude ¶
Exclude takes a slice of strings and a target string and returns the contents of the original slice of strings without the target string in it
Example:
x := Exclude([]string{"cat", "dog", "rat"}, "dog") > []string{"cat", "rat"}
func ExecuteCommand ¶
ExecuteCommand executes an external command on the local machine as the current user
func FindMatch ¶ added in v0.0.3
FindMatch takes a regex pattern and a string of data and returns back all the matches in that string
func HighlightableHelper ¶ added in v0.11.0
func NameFromEmail ¶
NameFromEmail takes an email address and returns the part that comes before the @ symbol
Example:
NameFromEmail("test_user@example.com") > "Test_user"
func NamesFromEmails ¶
NamesFromEmails takes a slice of email addresses and returns a slice of the parts that come before the @ symbol
Example:
NamesFromEmail("test_user@example.com", "other_user@example.com") > []string{"Test_user", "Other_user"}
func NewBillboardModal ¶
func OpenFile ¶
func OpenFile(path string)
OpenFile opens the file defined in `path` via the operating system
func PadRow ¶
PadRow returns a padding for a row to make it the full width of the containing widget. Useful for ensurig row highlighting spans the full width (I suspect tcell has a better way to do this, but I haven't yet found it)
func PrettyDate ¶
func ReadFileBytes ¶
ReadFileBytes reads the contents of a file and returns those contents as a slice of bytes
func Schedule ¶
func Schedule(widget Wtfable)
Schedule kicks off the first refresh of a module's data and then queues the rest of the data refreshes on a timer
func ToInts ¶
func ToInts(slice []interface{}) []int
ToInts takes a slice of interfaces and returns a slice of ints
func ToStrs ¶
func ToStrs(slice []interface{}) []string
ToStrs takes a slice of interfaces and returns a slice of strings
func ValidateWidgets ¶ added in v0.9.2
func ValidateWidgets(widgets []Wtfable)
ValidateWidgets rolls through all the enabled widgets and looks for configuration errors. If it finds any it stringifies them, writes them to the console, and kills the app gracefully
Types ¶
type BarGraph ¶ added in v0.0.7
type BarGraph struct { RefreshInt int View *tview.TextView // contains filtered or unexported fields }
BarGraph lets make graphs
func NewBarGraph ¶ added in v0.0.7
func NewBarGraph(app *tview.Application, name string, settings *cfg.Common, focusable bool) BarGraph
NewBarGraph initialize your fancy new graph
func (*BarGraph) BorderColor ¶ added in v0.0.7
func (*BarGraph) BuildBars ¶ added in v0.0.7
BuildBars will build a string of * to represent your data of time[value] time should be passed as a int64
func (*BarGraph) CommonSettings ¶ added in v0.14.0
func (*BarGraph) ConfigText ¶ added in v0.11.0
func (*BarGraph) RefreshInterval ¶ added in v0.0.7
RefreshInterval returns how often, in seconds, the widget will return its data
func (*BarGraph) Refreshing ¶ added in v0.18.0
Refreshing returns TRUE if the widget is currently refreshing its data, FALSE if it is not
func (*BarGraph) SetFocusChar ¶ added in v0.9.2
type Enablable ¶ added in v0.18.0
Enablable is the interface that enforces enable/disable capabilities on a module
type FocusState ¶
type FocusState int
type FocusTracker ¶
type FocusTracker struct { App *tview.Application Idx int IsFocused bool Widgets []Wtfable // contains filtered or unexported fields }
FocusTracker is used by the app to track which onscreen widget currently has focus, and to move focus between widgets.
func NewFocusTracker ¶ added in v0.9.2
func NewFocusTracker(app *tview.Application, widgets []Wtfable, config *config.Config) FocusTracker
func (*FocusTracker) FocusOn ¶ added in v0.9.2
func (tracker *FocusTracker) FocusOn(char string) bool
func (*FocusTracker) Next ¶
func (tracker *FocusTracker) Next()
Next sets the focus on the next widget in the widget list. If the current widget is the last widget, sets focus on the first widget.
func (*FocusTracker) None ¶
func (tracker *FocusTracker) None()
None removes focus from the currently-focused widget.
func (*FocusTracker) Prev ¶
func (tracker *FocusTracker) Prev()
Prev sets the focus on the previous widget in the widget list. If the current widget is the last widget, sets focus on the last widget.
func (*FocusTracker) Refocus ¶
func (tracker *FocusTracker) Refocus()
type KeyboardWidget ¶ added in v0.9.2
type KeyboardWidget struct {
// contains filtered or unexported fields
}
KeyboardWidget manages keyboard control for a widget
func NewKeyboardWidget ¶ added in v0.9.2
func NewKeyboardWidget(app *tview.Application, pages *tview.Pages, settings *cfg.Common) KeyboardWidget
NewKeyboardWidget creates and returns a new instance of KeyboardWidget
func (*KeyboardWidget) HelpText ¶ added in v0.10.0
func (widget *KeyboardWidget) HelpText() string
HelpText returns the help text and keyboard command info for this widget
func (*KeyboardWidget) InputCapture ¶ added in v0.9.2
func (widget *KeyboardWidget) InputCapture(event *tcell.EventKey) *tcell.EventKey
InputCapture is the function passed to tview's SetInputCapture() function This is done during the main widget's creation process using the following code:
widget.View.SetInputCapture(widget.InputCapture)
func (*KeyboardWidget) SetKeyboardChar ¶ added in v0.9.2
func (widget *KeyboardWidget) SetKeyboardChar(char string, fn func(), helpText string)
SetKeyboardChar sets a character/function combination that responds to key presses Example:
widget.SetKeyboardChar("d", widget.deleteSelectedItem)
func (*KeyboardWidget) SetKeyboardKey ¶ added in v0.9.2
func (widget *KeyboardWidget) SetKeyboardKey(key tcell.Key, fn func(), helpText string)
SetKeyboardKey sets a tcell.Key/function combination that responds to key presses Example:
widget.SetKeyboardKey(tcell.KeyCtrlD, widget.deleteSelectedItem)
func (*KeyboardWidget) SetView ¶ added in v0.10.0
func (widget *KeyboardWidget) SetView(view *tview.TextView)
func (*KeyboardWidget) ShowHelp ¶ added in v0.10.0
func (widget *KeyboardWidget) ShowHelp()
type MultiSourceWidget ¶ added in v0.9.2
type MultiSourceWidget struct { DisplayFunction func() Idx int Sources []string // contains filtered or unexported fields }
func NewMultiSourceWidget ¶ added in v0.9.2
func NewMultiSourceWidget(moduleConfig *cfg.Common, singular, plural string) MultiSourceWidget
NewMultiSourceWidget creates and returns an instance of MultiSourceWidget
func (*MultiSourceWidget) CurrentSource ¶ added in v0.9.2
func (widget *MultiSourceWidget) CurrentSource() string
CurrentSource returns the string representations of the currently-displayed source
func (*MultiSourceWidget) NextSource ¶ added in v0.10.3
func (widget *MultiSourceWidget) NextSource()
Next displays the next source in the source list. If the current source is the last source it wraps around to the first source
func (*MultiSourceWidget) PrevSource ¶ added in v0.10.3
func (widget *MultiSourceWidget) PrevSource()
Prev displays the previous source in the source list. If the current source is the first source, it wraps around to the last source
func (*MultiSourceWidget) SetDisplayFunction ¶ added in v0.9.2
func (widget *MultiSourceWidget) SetDisplayFunction(displayFunc func())
SetDisplayFunction stores the function that should be called when the source is changed. This is typically called from within the initializer for the struct that embeds MultiSourceWidget
Example:
widget := Widget{ MultiSourceWidget: wtf.NewMultiSourceWidget(settings.common, "person", "people") } widget.SetDisplayFunction(widget.display)
type Schedulable ¶ added in v0.18.0
Schedulable is the interface that enforces scheduling capabilities on a module
type ScrollableWidget ¶ added in v0.10.0
type ScrollableWidget struct { TextWidget Selected int RenderFunction func() // contains filtered or unexported fields }
func NewScrollableWidget ¶ added in v0.10.0
func NewScrollableWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) ScrollableWidget
func (*ScrollableWidget) GetSelected ¶ added in v0.10.0
func (widget *ScrollableWidget) GetSelected() int
func (*ScrollableWidget) Next ¶ added in v0.10.0
func (widget *ScrollableWidget) Next()
func (*ScrollableWidget) Prev ¶ added in v0.10.0
func (widget *ScrollableWidget) Prev()
func (*ScrollableWidget) Redraw ¶ added in v0.10.0
func (widget *ScrollableWidget) Redraw(title, content string, wrap bool)
func (*ScrollableWidget) RowColor ¶ added in v0.10.0
func (widget *ScrollableWidget) RowColor(idx int) string
func (*ScrollableWidget) SetItemCount ¶ added in v0.10.0
func (widget *ScrollableWidget) SetItemCount(items int)
func (*ScrollableWidget) SetRenderFunction ¶ added in v0.10.0
func (widget *ScrollableWidget) SetRenderFunction(displayFunc func())
func (*ScrollableWidget) Unselect ¶ added in v0.10.0
func (widget *ScrollableWidget) Unselect()
type TextWidget ¶
func NewTextWidget ¶
func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) TextWidget
func (*TextWidget) BorderColor ¶
func (widget *TextWidget) BorderColor() string
func (*TextWidget) Bordered ¶ added in v0.16.0
func (widget *TextWidget) Bordered() bool
Bordered returns whether or not this widget should be drawn with a border
func (*TextWidget) CommonSettings ¶ added in v0.9.2
func (widget *TextWidget) CommonSettings() *cfg.Common
func (*TextWidget) ConfigText ¶ added in v0.11.0
func (widget *TextWidget) ConfigText() string
func (*TextWidget) ContextualTitle ¶ added in v0.9.2
func (widget *TextWidget) ContextualTitle(defaultStr string) string
func (*TextWidget) Disable ¶ added in v0.0.7
func (widget *TextWidget) Disable()
func (*TextWidget) Disabled ¶
func (widget *TextWidget) Disabled() bool
func (*TextWidget) Enabled ¶
func (widget *TextWidget) Enabled() bool
func (*TextWidget) FocusChar ¶ added in v0.9.2
func (widget *TextWidget) FocusChar() string
func (*TextWidget) Focusable ¶
func (widget *TextWidget) Focusable() bool
func (*TextWidget) HelpText ¶ added in v0.10.0
func (widget *TextWidget) HelpText() string
func (*TextWidget) Name ¶
func (widget *TextWidget) Name() string
func (*TextWidget) Redraw ¶ added in v0.10.0
func (widget *TextWidget) Redraw(title, text string, wrap bool)
func (*TextWidget) RefreshInterval ¶
func (widget *TextWidget) RefreshInterval() int
RefreshInterval returns how often, in seconds, the widget will return its data
func (*TextWidget) Refreshing ¶ added in v0.18.0
func (widget *TextWidget) Refreshing() bool
Refreshing returns TRUE if the widget is currently refreshing its data, FALSE if it is not
func (*TextWidget) SetFocusChar ¶ added in v0.9.2
func (widget *TextWidget) SetFocusChar(char string)
func (*TextWidget) String ¶ added in v0.9.2
func (widget *TextWidget) String() string
func (*TextWidget) TextView ¶
func (widget *TextWidget) TextView() *tview.TextView
type Wtfable ¶
type Wtfable interface { Enablable Schedulable BorderColor() string ConfigText() string FocusChar() string Focusable() bool HelpText() string Name() string SetFocusChar(string) TextView() *tview.TextView CommonSettings() *cfg.Common }
Wtfable is the interface that enforces WTF system capabilities on a module