mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Removed a bunch of common boilerplate code from widget initialization
This commit is contained in:
parent
d812986abc
commit
693a04b5e1
@ -6,4 +6,4 @@ theme = "hyde-hyde"
|
|||||||
[params]
|
[params]
|
||||||
author = "Chris Cummer"
|
author = "Chris Cummer"
|
||||||
authorimage = "/img/wtf.png"
|
authorimage = "/img/wtf.png"
|
||||||
description = "...is that?"
|
description = "...is going on?"
|
||||||
|
@ -4,9 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,8 +19,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr"),
|
TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,18 +48,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(items []Item) string {
|
func (widget *Widget) contentFrom(items []Item) string {
|
||||||
if len(items) == 0 {
|
if len(items) == 0 {
|
||||||
return fmt.Sprintf("\n\n\n\n\n\n\n\n%s", wtf.CenterText("[grey]no one[white]", 50))
|
return fmt.Sprintf("\n\n\n\n\n\n\n\n%s", wtf.CenterText("[grey]no one[white]", 50))
|
||||||
|
155
color/colors.go
Normal file
155
color/colors.go
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
package color
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gdamore/tcell"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Colors = map[string]tcell.Color{
|
||||||
|
"black": tcell.ColorBlack,
|
||||||
|
"maroon": tcell.ColorMaroon,
|
||||||
|
"green": tcell.ColorGreen,
|
||||||
|
"olive": tcell.ColorOlive,
|
||||||
|
"navy": tcell.ColorNavy,
|
||||||
|
"purple": tcell.ColorPurple,
|
||||||
|
"teal": tcell.ColorTeal,
|
||||||
|
"silver": tcell.ColorSilver,
|
||||||
|
"gray": tcell.ColorGray,
|
||||||
|
"red": tcell.ColorRed,
|
||||||
|
"lime": tcell.ColorLime,
|
||||||
|
"yellow": tcell.ColorYellow,
|
||||||
|
"blue": tcell.ColorBlue,
|
||||||
|
"fuchsia": tcell.ColorFuchsia,
|
||||||
|
"aqua": tcell.ColorAqua,
|
||||||
|
"white": tcell.ColorWhite,
|
||||||
|
"aliceblue": tcell.ColorAliceBlue,
|
||||||
|
"antiquewhite": tcell.ColorAntiqueWhite,
|
||||||
|
"aquamarine": tcell.ColorAquaMarine,
|
||||||
|
"azure": tcell.ColorAzure,
|
||||||
|
"beige": tcell.ColorBeige,
|
||||||
|
"bisque": tcell.ColorBisque,
|
||||||
|
"blanchedalmond": tcell.ColorBlanchedAlmond,
|
||||||
|
"blueviolet": tcell.ColorBlueViolet,
|
||||||
|
"brown": tcell.ColorBrown,
|
||||||
|
"burlywood": tcell.ColorBurlyWood,
|
||||||
|
"cadetblue": tcell.ColorCadetBlue,
|
||||||
|
"chartreuse": tcell.ColorChartreuse,
|
||||||
|
"chocolate": tcell.ColorChocolate,
|
||||||
|
"coral": tcell.ColorCoral,
|
||||||
|
"cornflowerblue": tcell.ColorCornflowerBlue,
|
||||||
|
"cornsilk": tcell.ColorCornsilk,
|
||||||
|
"crimson": tcell.ColorCrimson,
|
||||||
|
"darkblue": tcell.ColorDarkBlue,
|
||||||
|
"darkcyan": tcell.ColorDarkCyan,
|
||||||
|
"darkgoldenrod": tcell.ColorDarkGoldenrod,
|
||||||
|
"darkgray": tcell.ColorDarkGray,
|
||||||
|
"darkgreen": tcell.ColorDarkGreen,
|
||||||
|
"darkkhaki": tcell.ColorDarkKhaki,
|
||||||
|
"darkmagenta": tcell.ColorDarkMagenta,
|
||||||
|
"darkolivegreen": tcell.ColorDarkOliveGreen,
|
||||||
|
"darkorange": tcell.ColorDarkOrange,
|
||||||
|
"darkorchid": tcell.ColorDarkOrchid,
|
||||||
|
"darkred": tcell.ColorDarkRed,
|
||||||
|
"darksalmon": tcell.ColorDarkSalmon,
|
||||||
|
"darkseagreen": tcell.ColorDarkSeaGreen,
|
||||||
|
"darkslateblue": tcell.ColorDarkSlateBlue,
|
||||||
|
"darkslategray": tcell.ColorDarkSlateGray,
|
||||||
|
"darkturquoise": tcell.ColorDarkTurquoise,
|
||||||
|
"darkviolet": tcell.ColorDarkViolet,
|
||||||
|
"deeppink": tcell.ColorDeepPink,
|
||||||
|
"deepskyblue": tcell.ColorDeepSkyBlue,
|
||||||
|
"dimgray": tcell.ColorDimGray,
|
||||||
|
"dodgerblue": tcell.ColorDodgerBlue,
|
||||||
|
"firebrick": tcell.ColorFireBrick,
|
||||||
|
"floralwhite": tcell.ColorFloralWhite,
|
||||||
|
"forestgreen": tcell.ColorForestGreen,
|
||||||
|
"gainsboro": tcell.ColorGainsboro,
|
||||||
|
"ghostwhite": tcell.ColorGhostWhite,
|
||||||
|
"gold": tcell.ColorGold,
|
||||||
|
"goldenrod": tcell.ColorGoldenrod,
|
||||||
|
"greenyellow": tcell.ColorGreenYellow,
|
||||||
|
"honeydew": tcell.ColorHoneydew,
|
||||||
|
"hotpink": tcell.ColorHotPink,
|
||||||
|
"indianred": tcell.ColorIndianRed,
|
||||||
|
"indigo": tcell.ColorIndigo,
|
||||||
|
"ivory": tcell.ColorIvory,
|
||||||
|
"khaki": tcell.ColorKhaki,
|
||||||
|
"lavender": tcell.ColorLavender,
|
||||||
|
"lavenderblush": tcell.ColorLavenderBlush,
|
||||||
|
"lawngreen": tcell.ColorLawnGreen,
|
||||||
|
"lemonchiffon": tcell.ColorLemonChiffon,
|
||||||
|
"lightblue": tcell.ColorLightBlue,
|
||||||
|
"lightcoral": tcell.ColorLightCoral,
|
||||||
|
"lightcyan": tcell.ColorLightCyan,
|
||||||
|
"lightgoldenrodyellow": tcell.ColorLightGoldenrodYellow,
|
||||||
|
"lightgray": tcell.ColorLightGray,
|
||||||
|
"lightgreen": tcell.ColorLightGreen,
|
||||||
|
"lightpink": tcell.ColorLightPink,
|
||||||
|
"lightsalmon": tcell.ColorLightSalmon,
|
||||||
|
"lightseagreen": tcell.ColorLightSeaGreen,
|
||||||
|
"lightskyblue": tcell.ColorLightSkyBlue,
|
||||||
|
"lightslategray": tcell.ColorLightSlateGray,
|
||||||
|
"lightsteelblue": tcell.ColorLightSteelBlue,
|
||||||
|
"lightyellow": tcell.ColorLightYellow,
|
||||||
|
"limegreen": tcell.ColorLimeGreen,
|
||||||
|
"linen": tcell.ColorLinen,
|
||||||
|
"mediumaquamarine": tcell.ColorMediumAquamarine,
|
||||||
|
"mediumblue": tcell.ColorMediumBlue,
|
||||||
|
"mediumorchid": tcell.ColorMediumOrchid,
|
||||||
|
"mediumpurple": tcell.ColorMediumPurple,
|
||||||
|
"mediumseagreen": tcell.ColorMediumSeaGreen,
|
||||||
|
"mediumslateblue": tcell.ColorMediumSlateBlue,
|
||||||
|
"mediumspringgreen": tcell.ColorMediumSpringGreen,
|
||||||
|
"mediumturquoise": tcell.ColorMediumTurquoise,
|
||||||
|
"mediumvioletred": tcell.ColorMediumVioletRed,
|
||||||
|
"midnightblue": tcell.ColorMidnightBlue,
|
||||||
|
"mintcream": tcell.ColorMintCream,
|
||||||
|
"mistyrose": tcell.ColorMistyRose,
|
||||||
|
"moccasin": tcell.ColorMoccasin,
|
||||||
|
"navajowhite": tcell.ColorNavajoWhite,
|
||||||
|
"oldlace": tcell.ColorOldLace,
|
||||||
|
"olivedrab": tcell.ColorOliveDrab,
|
||||||
|
"orange": tcell.ColorOrange,
|
||||||
|
"orangered": tcell.ColorOrangeRed,
|
||||||
|
"orchid": tcell.ColorOrchid,
|
||||||
|
"palegoldenrod": tcell.ColorPaleGoldenrod,
|
||||||
|
"palegreen": tcell.ColorPaleGreen,
|
||||||
|
"paleturquoise": tcell.ColorPaleTurquoise,
|
||||||
|
"palevioletred": tcell.ColorPaleVioletRed,
|
||||||
|
"papayawhip": tcell.ColorPapayaWhip,
|
||||||
|
"peachpuff": tcell.ColorPeachPuff,
|
||||||
|
"peru": tcell.ColorPeru,
|
||||||
|
"pink": tcell.ColorPink,
|
||||||
|
"plum": tcell.ColorPlum,
|
||||||
|
"powderblue": tcell.ColorPowderBlue,
|
||||||
|
"rebeccapurple": tcell.ColorRebeccaPurple,
|
||||||
|
"rosybrown": tcell.ColorRosyBrown,
|
||||||
|
"royalblue": tcell.ColorRoyalBlue,
|
||||||
|
"saddlebrown": tcell.ColorSaddleBrown,
|
||||||
|
"salmon": tcell.ColorSalmon,
|
||||||
|
"sandybrown": tcell.ColorSandyBrown,
|
||||||
|
"seagreen": tcell.ColorSeaGreen,
|
||||||
|
"seashell": tcell.ColorSeashell,
|
||||||
|
"sienna": tcell.ColorSienna,
|
||||||
|
"skyblue": tcell.ColorSkyblue,
|
||||||
|
"slateblue": tcell.ColorSlateBlue,
|
||||||
|
"slategray": tcell.ColorSlateGray,
|
||||||
|
"snow": tcell.ColorSnow,
|
||||||
|
"springgreen": tcell.ColorSpringGreen,
|
||||||
|
"steelblue": tcell.ColorSteelBlue,
|
||||||
|
"tan": tcell.ColorTan,
|
||||||
|
"thistle": tcell.ColorThistle,
|
||||||
|
"tomato": tcell.ColorTomato,
|
||||||
|
"turquoise": tcell.ColorTurquoise,
|
||||||
|
"violet": tcell.ColorViolet,
|
||||||
|
"wheat": tcell.ColorWheat,
|
||||||
|
"whitesmoke": tcell.ColorWhiteSmoke,
|
||||||
|
"yellowgreen": tcell.ColorYellowGreen,
|
||||||
|
}
|
||||||
|
|
||||||
|
func ColorFor(label string) tcell.Color {
|
||||||
|
if _, ok := Colors[label]; ok {
|
||||||
|
return Colors[label]
|
||||||
|
} else {
|
||||||
|
return tcell.ColorBlue
|
||||||
|
}
|
||||||
|
}
|
@ -5,9 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
"google.golang.org/api/calendar/v3"
|
"google.golang.org/api/calendar/v3"
|
||||||
)
|
)
|
||||||
@ -23,8 +21,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal"),
|
TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,18 +41,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGrey)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(events *calendar.Events) string {
|
func (widget *Widget) contentFrom(events *calendar.Events) string {
|
||||||
if events == nil {
|
if events == nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -6,9 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,8 +21,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" Git ", "git"),
|
TextWidget: wtf.NewTextWidget(" Git ", "git"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,18 +45,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(data map[string][]string) string {
|
func (widget *Widget) contentFrom(data map[string][]string) string {
|
||||||
str := " [red]Branch[white]\n"
|
str := " [red]Branch[white]\n"
|
||||||
str = str + fmt.Sprintf(" %s", data["branch"][0])
|
str = str + fmt.Sprintf(" %s", data["branch"][0])
|
||||||
|
@ -4,10 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
ghb "github.com/google/go-github/github"
|
ghb "github.com/google/go-github/github"
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,8 +20,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" Github ", "github"),
|
TextWidget: wtf.NewTextWidget(" Github ", "github"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,18 +49,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) prsForReview(prs []*ghb.PullRequest, username string) string {
|
func (widget *Widget) prsForReview(prs []*ghb.PullRequest, username string) string {
|
||||||
if len(prs) > 0 {
|
if len(prs) > 0 {
|
||||||
str := ""
|
str := ""
|
||||||
|
@ -4,9 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,8 +19,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget("JIRA", "jira"),
|
TextWidget: wtf.NewTextWidget("JIRA", "jira"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,17 +54,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
func (widget *Widget) contentFrom(searchResult *SearchResult) string {
|
||||||
str := " [red]Assigned Issues[white]\n"
|
str := " [red]Assigned Issues[white]\n"
|
||||||
|
|
||||||
|
@ -4,9 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
nr "github.com/yfronto/newrelic"
|
nr "github.com/yfronto/newrelic"
|
||||||
)
|
)
|
||||||
@ -22,8 +20,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" New Relic ", "newrelic"),
|
TextWidget: wtf.NewTextWidget(" New Relic ", "newrelic"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,18 +55,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
|
func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
|
||||||
str := fmt.Sprintf(
|
str := fmt.Sprintf(
|
||||||
" %s\n",
|
" %s\n",
|
||||||
|
@ -5,9 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,8 +20,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" ⏰ OpsGenie ", "opsgenie"),
|
TextWidget: wtf.NewTextWidget(" ⏰ OpsGenie ", "opsgenie"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,18 +49,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string {
|
func (widget *Widget) contentFrom(onCallResponse *OnCallResponse) string {
|
||||||
str := ""
|
str := ""
|
||||||
|
|
||||||
|
@ -4,9 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,8 +19,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security"),
|
TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,18 +40,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(data *SecurityData) string {
|
func (widget *Widget) contentFrom(data *SecurityData) string {
|
||||||
|
|
||||||
str := " [red]WiFi[white]\n"
|
str := " [red]WiFi[white]\n"
|
||||||
|
@ -5,9 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,8 +23,6 @@ func NewWidget() *Widget {
|
|||||||
Current: 0,
|
Current: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,18 +48,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) animation() string {
|
func (widget *Widget) animation() string {
|
||||||
icons := []string{"👍", "🤜", "🤙", "🤜", "🤘", "🤜", "✊", "🤜", "👌", "🤜"}
|
icons := []string{"👍", "🤜", "🤙", "🤜", "🤘", "🤜", "✊", "🤜", "👌", "🤜"}
|
||||||
next := icons[widget.Current]
|
next := icons[widget.Current]
|
||||||
|
@ -6,9 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
owm "github.com/briandowns/openweathermap"
|
owm "github.com/briandowns/openweathermap"
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,8 +21,6 @@ func NewWidget() *Widget {
|
|||||||
TextWidget: wtf.NewTextWidget(" Weather ", "weather"),
|
TextWidget: wtf.NewTextWidget(" Weather ", "weather"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.addView()
|
|
||||||
|
|
||||||
return &widget
|
return &widget
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,18 +43,6 @@ func (widget *Widget) Refresh() {
|
|||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *Widget) addView() {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
|
|
||||||
view.SetBorder(true)
|
|
||||||
view.SetBorderColor(tcell.ColorGray)
|
|
||||||
view.SetDynamicColors(true)
|
|
||||||
view.SetTitle(widget.Name)
|
|
||||||
view.SetWrap(false)
|
|
||||||
|
|
||||||
widget.View = view
|
|
||||||
}
|
|
||||||
|
|
||||||
func (widget *Widget) contentFrom(data *owm.CurrentWeatherData) string {
|
func (widget *Widget) contentFrom(data *owm.CurrentWeatherData) string {
|
||||||
if len(data.Weather) == 0 {
|
if len(data.Weather) == 0 {
|
||||||
return " Weather data is unavailable."
|
return " Weather data is unavailable."
|
||||||
@ -138,6 +122,8 @@ func icon(data *owm.CurrentWeatherData) string {
|
|||||||
icon = "🌤"
|
icon = "🌤"
|
||||||
case "scattered clouds":
|
case "scattered clouds":
|
||||||
icon = "☁️"
|
icon = "☁️"
|
||||||
|
case "shower rain":
|
||||||
|
icon = "☔️"
|
||||||
case "snow":
|
case "snow":
|
||||||
icon = "❄️"
|
icon = "❄️"
|
||||||
case "sunny":
|
case "sunny":
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
|
"github.com/senorprogrammer/wtf/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
@ -34,9 +35,23 @@ func NewTextWidget(name string, configKey string) TextWidget {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.addView()
|
||||||
|
|
||||||
return widget
|
return widget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (widget *TextWidget) addView() {
|
||||||
|
view := tview.NewTextView()
|
||||||
|
|
||||||
|
view.SetBorder(true)
|
||||||
|
view.SetBorderColor(color.ColorFor(Config.UString("wtf.border.normal")))
|
||||||
|
view.SetDynamicColors(true)
|
||||||
|
view.SetTitle(widget.Name)
|
||||||
|
view.SetWrap(false)
|
||||||
|
|
||||||
|
widget.View = view
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------- Exported Functions -------------------- */
|
/* -------------------- Exported Functions -------------------- */
|
||||||
|
|
||||||
func (widget *TextWidget) Disabled() bool {
|
func (widget *TextWidget) Disabled() bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user