1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Implement ASCII-only widget titles

Widget titles can now be specified in the config file via a 'title' key.
Example:

  wtf:
    mods:
      todo:
        title: Tada

which can include emoji. No need to force everyone to look at my emoji,
now they can define their own.
This commit is contained in:
Chris Cummer 2018-06-03 20:54:07 -07:00
parent c14902abb6
commit 218b6937b1
17 changed files with 22 additions and 24 deletions

View File

@ -16,7 +16,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 👽 BambooHR ", "bamboohr", false), TextWidget: wtf.NewTextWidget(" BambooHR ", "bamboohr", false),
} }
return &widget return &widget
@ -37,7 +37,7 @@ func (widget *Widget) Refresh() {
) )
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(todayItems))) widget.View.SetTitle(fmt.Sprintf("%s(%d)", widget.Name, len(todayItems)))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(todayItems))) widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(todayItems)))
} }

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🕗 World Clocks ", "clocks", false), TextWidget: wtf.NewTextWidget(" World Clocks ", "clocks", false),
} }
widget.clockColl = widget.buildClockCollection(Config.UMap("wtf.mods.clocks.locations")) widget.clockColl = widget.buildClockCollection(Config.UMap("wtf.mods.clocks.locations"))

View File

@ -22,7 +22,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🏃 Runner ", "cmdrunner", false), TextWidget: wtf.NewTextWidget(" CmdRunner ", "cmdrunner", false),
args: wtf.ToStrs(Config.UList("wtf.mods.cmdrunner.args")), args: wtf.ToStrs(Config.UList("wtf.mods.cmdrunner.args")),
cmd: Config.UString("wtf.mods.cmdrunner.cmd"), cmd: Config.UString("wtf.mods.cmdrunner.cmd"),

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"reflect"
"time" "time"
"github.com/olebedev/config" "github.com/olebedev/config"
@ -32,7 +31,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
started = false started = false
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" $ CryptoLive ", "cryptolive", false), TextWidget: wtf.NewTextWidget(" CryptoLive ", "cryptolive", false),
updateInterval: Config.UInt("wtf.mods.cryptolive.updateInterval", 10), updateInterval: Config.UInt("wtf.mods.cryptolive.updateInterval", 10),
} }

View File

@ -20,7 +20,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🍿 Calendar ", "gcal", false), TextWidget: wtf.NewTextWidget(" Calendar ", "gcal", false),
} }
return &widget return &widget

View File

@ -17,7 +17,7 @@ func (widget *Widget) display() {
} }
title := fmt.Sprintf("[green]%s[white]\n", repoData.Repository) title := fmt.Sprintf("[green]%s[white]\n", repoData.Repository)
widget.View.SetTitle(fmt.Sprintf(" Git: %s ", title)) widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name, title))
str := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n" str := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n"
str = str + " [red]Branch[white]\n" str = str + " [red]Branch[white]\n"

View File

@ -14,7 +14,7 @@ func (widget *Widget) display() {
return return
} }
widget.View.SetTitle(fmt.Sprintf(" Github: %s ", widget.title(repo))) widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name, widget.title(repo)))
str := wtf.SigilStr(len(widget.GithubRepos), widget.Idx, widget.View) + "\n" str := wtf.SigilStr(len(widget.GithubRepos), widget.Idx, widget.View) + "\n"
str = str + " [red]Stats[white]\n" str = str + " [red]Stats[white]\n"

View File

@ -16,7 +16,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget("JIRA", "jira", false), TextWidget: wtf.NewTextWidget(" Jira ", "jira", false),
} }
return &widget return &widget
@ -35,13 +35,13 @@ func (widget *Widget) Refresh() {
if err != nil { if err != nil {
widget.View.SetWrap(true) widget.View.SetWrap(true)
widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name)) widget.View.SetTitle(fmt.Sprintf("%s", widget.Name))
fmt.Fprintf(widget.View, "%v", err) fmt.Fprintf(widget.View, "%v", err)
} else { } else {
widget.View.SetWrap(false) widget.View.SetWrap(false)
widget.View.SetTitle( widget.View.SetTitle(
fmt.Sprintf( fmt.Sprintf(
" %s: [green]%s[white] ", "%s- [green]%s[white]",
widget.Name, widget.Name,
Config.UString("wtf.mods.jira.project"), Config.UString("wtf.mods.jira.project"),
), ),

View File

@ -39,7 +39,7 @@ func (widget *Widget) Refresh() {
} }
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf(" New Relic: [green]%s[white] ", appName)) widget.View.SetTitle(fmt.Sprintf("%s- [green]%s[white]", widget.Name, appName))
widget.View.Clear() widget.View.Clear()
if depErr != nil { if depErr != nil {

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" OpsGenie ", "opsgenie", false), TextWidget: wtf.NewTextWidget(" OpsGenie ", "opsgenie", false),
} }
return &widget return &widget
@ -33,7 +33,7 @@ func (widget *Widget) Refresh() {
data, err := Fetch() data, err := Fetch()
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.View.SetTitle(" ⏰ On Call ") widget.View.SetTitle(widget.Name)
if err != nil { if err != nil {
widget.View.SetWrap(true) widget.View.SetWrap(true)

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" ⚡️ Power ", "power", false), TextWidget: wtf.NewTextWidget(" Power ", "power", false),
Battery: NewBattery(), Battery: NewBattery(),
} }

View File

@ -22,7 +22,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget("Pretty Weather", "prettyweather", false), TextWidget: wtf.NewTextWidget(" Pretty Weather ", "prettyweather", false),
} }
return &widget return &widget
@ -35,7 +35,6 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.prettyWeather() widget.prettyWeather()
widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name))
widget.View.SetText(fmt.Sprintf("%s", widget.result)) widget.View.SetText(fmt.Sprintf("%s", widget.result))
} }

View File

@ -17,7 +17,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🤺 Security ", "security", false), TextWidget: wtf.NewTextWidget(" Security ", "security", false),
} }
return &widget return &widget

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget() *Widget { func NewWidget() *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 🎉 Status ", "status", false), TextWidget: wtf.NewTextWidget(" Status ", "status", false),
CurrentIcon: 0, CurrentIcon: 0,
} }

View File

@ -21,7 +21,7 @@ type Widget struct {
func NewWidget(date, version string) *Widget { func NewWidget(date, version string) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" Build ", "system", false), TextWidget: wtf.NewTextWidget(" System ", "system", false),
Date: date, Date: date,
Version: version, Version: version,

View File

@ -30,7 +30,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 📄 Text File ", "textfile", true), TextWidget: wtf.NewTextWidget(" Text File ", "textfile", true),
app: app, app: app,
filePath: Config.UString("wtf.mods.textfile.filePath"), filePath: Config.UString("wtf.mods.textfile.filePath"),
@ -53,7 +53,7 @@ func (widget *Widget) Refresh() {
} }
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf(" 📄 %s ", widget.filePath)) widget.View.SetTitle(fmt.Sprintf("%s %s", widget.Name, widget.filePath))
filePath, _ := wtf.ExpandHomeDir(widget.filePath) filePath, _ := wtf.ExpandHomeDir(widget.filePath)

View File

@ -44,7 +44,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{ widget := Widget{
TextWidget: wtf.NewTextWidget(" 📝 Todo ", "todo", true), TextWidget: wtf.NewTextWidget(" Todo ", "todo", true),
app: app, app: app,
filePath: Config.UString("wtf.mods.todo.filename"), filePath: Config.UString("wtf.mods.todo.filename"),