wtf

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2019 License: MPL-2.0 Imports: 18 Imported by: 11

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02"

DateFormat defines the format we expect to receive dates from BambooHR in

View Source
const FriendlyDateFormat = "Mon, Jan 2"
View Source
const FriendlyDateTimeFormat = "Mon, Jan 2, 15:04"
View Source
const FullDateFormat = "Monday, Jan 2"
View Source
const MinimumTimeFormat = "15:04"
View Source
const SimpleDateFormat = "Jan 2"
View Source
const SimpleTimeFormat = "15:04 MST"
View Source
const TimeFormat = "15:04"
View Source
const TimestampFormat = "2006-01-02T15:04:05-0700"

Variables

View Source
var OpenFileUtil = "open"

Functions

func ASCIItoTviewColors added in v0.9.2

func ASCIItoTviewColors(text string) string

func BuildStars added in v0.0.10

func BuildStars(data []Bar, maxStars int, starChar string) string

BuildStars build the string to display

func CenterText

func CenterText(str string, width int) string

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 ColorFor

func ColorFor(label string) tcell.Color

func Exclude

func Exclude(strs []string, val string) bool

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

func ExecuteCommand(cmd *exec.Cmd) string

ExecuteCommand executes an external command on the local machine as the current user

func FindMatch added in v0.0.3

func FindMatch(pattern string, data string) [][]string

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 HighlightableHelper(view *tview.TextView, input string, idx, offset int) string

func IsToday

func IsToday(date time.Time) bool

func MapToStrs added in v0.9.2

func MapToStrs(aMap map[string]interface{}) map[string]string

MapToStrs takes a map of interfaces and returns a map of strings

func NameFromEmail

func NameFromEmail(email string) string

NameFromEmail takes an email address and returns the part that comes before the @ symbol

Example:

NameFromEmail("test_user@example.com")
> "Test_user"

func NamesFromEmails

func NamesFromEmails(emails []string) []string

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 NewBillboardModal(text string, closeFunc func()) *tview.Frame

func Now

func Now() time.Time

func OpenFile

func OpenFile(path string)

OpenFile opens the file defined in `path` via the operating system

func PadRow

func PadRow(offset int, max int) string

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 PrettyDate(dateStr string) string

func ReadFileBytes

func ReadFileBytes(filePath string) ([]byte, error)

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 Tomorrow

func Tomorrow() time.Time

func UnixTime

func UnixTime(unix int64) time.Time

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 Bar added in v0.9.2

type Bar struct {
	Label      string
	Percent    int
	ValueLabel string
}

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 (widget *BarGraph) BorderColor() string

func (*BarGraph) BuildBars added in v0.0.7

func (widget *BarGraph) BuildBars(data []Bar)

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 (widget *BarGraph) CommonSettings() *cfg.Common

func (*BarGraph) ConfigText added in v0.11.0

func (widget *BarGraph) ConfigText() string

func (*BarGraph) Disable added in v0.0.7

func (widget *BarGraph) Disable()

func (*BarGraph) Disabled added in v0.0.7

func (widget *BarGraph) Disabled() bool

func (*BarGraph) Enabled added in v0.0.7

func (widget *BarGraph) Enabled() bool

func (*BarGraph) FocusChar added in v0.9.2

func (widget *BarGraph) FocusChar() string

func (*BarGraph) Focusable added in v0.0.7

func (widget *BarGraph) Focusable() bool

func (*BarGraph) HelpText added in v0.10.0

func (widget *BarGraph) HelpText() string

func (*BarGraph) Key added in v0.9.2

func (widget *BarGraph) Key() string

func (*BarGraph) Name added in v0.0.7

func (widget *BarGraph) Name() string

func (*BarGraph) RefreshInterval added in v0.0.7

func (widget *BarGraph) RefreshInterval() int

RefreshInterval returns how often, in seconds, the widget will return its data

func (*BarGraph) Refreshing added in v0.18.0

func (widget *BarGraph) Refreshing() bool

Refreshing returns TRUE if the widget is currently refreshing its data, FALSE if it is not

func (*BarGraph) SetFocusChar added in v0.9.2

func (widget *BarGraph) SetFocusChar(char string)

func (*BarGraph) TextView added in v0.0.7

func (widget *BarGraph) TextView() *tview.TextView

type Display added in v0.0.9

type Display struct {
	Grid *tview.Grid
	// contains filtered or unexported fields
}

func NewDisplay added in v0.0.9

func NewDisplay(widgets []Wtfable, config *config.Config) *Display

type Enablable added in v0.18.0

type Enablable interface {
	Disabled() bool
	Enabled() bool

	Disable()
}

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

type Schedulable interface {
	Refresh()
	Refreshing() bool
	RefreshInterval() int
}

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

type TextWidget struct {
	View *tview.TextView
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL