wtf

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MPL-2.0 Imports: 16 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 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)

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) (bool, error)

Check that all the loaded widgets are valid for display

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

	Position
	// 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) 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) IsPositionable added in v0.9.2

func (widget *BarGraph) IsPositionable() bool

IsPositionable returns TRUE if the widget has valid position parameters, FALSE if it has invalid position parameters (ie: cannot be placed onscreen)

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

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 Enabler

type Enabler interface {
	Disabled() bool
	Enabled() bool
	IsPositionable() bool

	Disable()
}

type FocusState

type FocusState int

type FocusTracker

type FocusTracker struct {
	App     *tview.Application
	Idx     int
	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

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

func (widget *MultiSourceWidget) Next()

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

func (widget *MultiSourceWidget) Prev()

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 Position

type Position struct {
	// contains filtered or unexported fields
}

func NewPosition added in v0.0.3

func NewPosition(top, left, width, height int) Position

func (*Position) Height

func (pos *Position) Height() int

func (*Position) IsValid added in v0.9.2

func (pos *Position) IsValid() bool

func (*Position) Left

func (pos *Position) Left() int

func (*Position) Top

func (pos *Position) Top() int

func (*Position) Width

func (pos *Position) Width() int

type Scheduler

type Scheduler interface {
	Refresh()
	RefreshInterval() int
}

type ScrollableWidget added in v0.10.0

type ScrollableWidget struct {
	TextWidget

	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

	CommonSettings *cfg.Common
	Position
	// 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) 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) IsPositionable added in v0.9.2

func (widget *TextWidget) IsPositionable() bool

IsPositionable returns TRUE if the widget has valid position parameters, FALSE if it has invalid position parameters (ie: cannot be placed onscreen)

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

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 {
	Enabler
	Scheduler

	BorderColor() string
	FocusChar() string
	Focusable() bool
	Name() string
	SetFocusChar(string)
	TextView() *tview.TextView
	HelpText() string

	Height() int
	Left() int
	Top() int
	Width() int
}

Jump to

Keyboard shortcuts

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