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 {
widget := Widget{
TextWidget: wtf.NewTextWidget(" πŸ‘½ BambooHR ", "bamboohr", false),
TextWidget: wtf.NewTextWidget(" BambooHR ", "bamboohr", false),
}
return &widget
@ -37,7 +37,7 @@ func (widget *Widget) Refresh() {
)
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)))
}

View File

@ -18,7 +18,7 @@ type Widget struct {
func NewWidget() *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"))

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@ func (widget *Widget) display() {
}
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 = str + " [red]Branch[white]\n"

View File

@ -14,7 +14,7 @@ func (widget *Widget) display() {
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 = str + " [red]Stats[white]\n"

View File

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

View File

@ -39,7 +39,7 @@ func (widget *Widget) Refresh() {
}
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()
if depErr != nil {

View File

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

View File

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

View File

@ -35,7 +35,6 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.prettyWeather()
widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name))
widget.View.SetText(fmt.Sprintf("%s", widget.result))
}

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ type Widget struct {
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(" πŸ“„ Text File ", "textfile", true),
TextWidget: wtf.NewTextWidget(" Text File ", "textfile", true),
app: app,
filePath: Config.UString("wtf.mods.textfile.filePath"),
@ -53,7 +53,7 @@ func (widget *Widget) Refresh() {
}
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)

View File

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