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

use widget.View.SetText to print

This commit is contained in:
Hossein Mehrabi 2018-06-03 10:53:26 +04:30
parent 86e58ef367
commit 6443df092f
17 changed files with 38 additions and 49 deletions

View File

@ -38,9 +38,8 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf(" 👽 Away (%d) ", len(todayItems)))
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", widget.contentFrom(todayItems))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(todayItems)))
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -23,5 +23,5 @@ func (widget *Widget) display(clocks []Clock) {
)
}
fmt.Fprintf(widget.View, "%s", str)
widget.View.SetText(fmt.Sprintf("%s", str))
}

View File

@ -34,7 +34,6 @@ func (widget *Widget) Refresh() {
}
widget.UpdateRefreshedAt()
widget.View.Clear()
widget.display(widget.clockColl.Sorted())
}

View File

@ -40,10 +40,9 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.execute()
widget.View.Clear()
widget.View.SetTitle(fmt.Sprintf(" %s ", widget))
fmt.Fprintf(widget.View, "%s", widget.result)
widget.View.SetText(fmt.Sprintf("%s", widget.result))
}
func (widget *Widget) String() string {

View File

@ -36,9 +36,8 @@ func (widget *Widget) Refresh() {
events, _ := Fetch()
widget.UpdateRefreshedAt()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", widget.contentFrom(events))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(events)))
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -9,7 +9,6 @@ import (
)
func (widget *Widget) display() {
widget.View.Clear()
repoData := widget.currentData()
if repoData == nil {
@ -28,7 +27,7 @@ func (widget *Widget) display() {
str = str + "\n"
str = str + widget.formatCommits(repoData.Commits)
fmt.Fprintf(widget.View, "%s", str)
widget.View.SetText(fmt.Sprintf("%s", str))
}
func (widget *Widget) formatChanges(data []string) string {

View File

@ -7,7 +7,6 @@ import (
)
func (widget *Widget) display() {
widget.View.Clear()
repo := widget.currentGithubRepo()
if repo == nil {
@ -27,7 +26,7 @@ func (widget *Widget) display() {
str = str + " [red]My Pull Requests[white]\n"
str = str + widget.displayMyPullRequests(repo, Config.UString("wtf.mods.github.username"))
fmt.Fprintf(widget.View, str)
widget.View.SetText(str)
}
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {

View File

@ -32,7 +32,6 @@ func (widget *Widget) Refresh() {
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), Config.UString("wtf.mods.jira.project", ""), Config.UString("wtf.mods.jira.jql", ""))
widget.UpdateRefreshedAt()
widget.View.Clear()
if err != nil {
widget.View.SetWrap(true)
@ -47,7 +46,7 @@ func (widget *Widget) Refresh() {
Config.UString("wtf.mods.jira.project"),
),
)
fmt.Fprintf(widget.View, "%s", widget.contentFrom(searchResult))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(searchResult)))
}
}

View File

@ -44,10 +44,10 @@ func (widget *Widget) Refresh() {
if depErr != nil {
widget.View.SetWrap(true)
fmt.Fprintf(widget.View, "%s", depErr)
widget.View.SetText(fmt.Sprintf("%s", depErr))
} else {
widget.View.SetWrap(false)
fmt.Fprintf(widget.View, "%s", widget.contentFrom(deploys))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(deploys)))
}
}
@ -70,7 +70,7 @@ func (widget *Widget) contentFrom(deploys []nr.ApplicationDeployment) string {
var revLen = 8
if revLen > len(deploy.Revision) {
revLen = len(deploy.Revision)
revLen = len(deploy.Revision)
}
str = str + fmt.Sprintf(

View File

@ -34,14 +34,13 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.View.SetTitle(" ⏰ On Call ")
widget.View.Clear()
if err != nil {
widget.View.SetWrap(true)
fmt.Fprintf(widget.View, "%s", err)
widget.View.SetText(fmt.Sprintf("%s", err))
} else {
widget.View.SetWrap(false)
fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(data)))
}
}

View File

@ -34,12 +34,11 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.Battery.Refresh()
widget.View.Clear()
str := ""
str = str + fmt.Sprintf(" %10s: %s\n", "Source", powerSource())
str = str + "\n"
str = str + widget.Battery.String()
fmt.Fprintf(widget.View, "%s", str)
widget.View.SetText(fmt.Sprintf("%s", str))
}

View File

@ -2,11 +2,12 @@ package prettyweather
import (
"fmt"
"github.com/olebedev/config"
"github.com/senorprogrammer/wtf/wtf"
"io/ioutil"
"net/http"
"strings"
"github.com/olebedev/config"
"github.com/senorprogrammer/wtf/wtf"
)
// Config is a pointer to the global config object
@ -34,10 +35,9 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.prettyWeather()
widget.View.Clear()
widget.View.SetTitle(fmt.Sprintf(" %s ", widget.Name))
fmt.Fprintf(widget.View, "%s", widget.result)
widget.View.SetText(fmt.Sprintf("%s", widget.result))
}
//this method reads the config and calls wttr.in for pretty weather

View File

@ -34,9 +34,8 @@ func (widget *Widget) Refresh() {
data.Fetch()
widget.UpdateRefreshedAt()
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", widget.contentFrom(data))
widget.View.SetText(fmt.Sprintf("%s", widget.contentFrom(data)))
}
/* -------------------- Unexported Functions -------------------- */

View File

@ -33,12 +33,12 @@ func (widget *Widget) Refresh() {
}
widget.UpdateRefreshedAt()
widget.View.Clear()
fmt.Fprintf(
widget.View,
"\n%s",
widget.animation(),
widget.View.SetText(
fmt.Sprintf(
"\n%s",
widget.animation(),
),
)
}

View File

@ -38,19 +38,19 @@ func (widget *Widget) Refresh() {
}
widget.UpdateRefreshedAt()
widget.View.Clear()
fmt.Fprintf(
widget.View,
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
"Built",
widget.prettyDate(),
"Vers",
widget.Version,
"OS",
widget.systemInfo.ProductVersion,
"Build",
widget.systemInfo.BuildVersion,
widget.View.SetText(
fmt.Sprintf(
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
"Built",
widget.prettyDate(),
"Vers",
widget.Version,
"OS",
widget.systemInfo.ProductVersion,
"Build",
widget.systemInfo.BuildVersion,
),
)
}

View File

@ -54,7 +54,6 @@ func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf(" 📄 %s ", widget.filePath))
widget.View.Clear()
filePath, _ := wtf.ExpandHomeDir(widget.filePath)
@ -64,9 +63,9 @@ func (widget *Widget) Refresh() {
}
if err != nil {
fmt.Fprintf(widget.View, "%s", err)
widget.View.SetText(fmt.Sprintf("%s", err))
} else {
fmt.Fprintf(widget.View, "%s", string(fileData))
widget.View.SetText(fmt.Sprintf("%s", string(fileData)))
}
}

View File

@ -29,7 +29,7 @@ func (widget *Widget) display() {
widget.SetList(&newList)
widget.View.Clear()
fmt.Fprintf(widget.View, "%s", str)
widget.View.SetText(fmt.Sprintf("%s", str))
}
func (widget *Widget) formattedItemLine(item *Item, selectedItem *Item, maxLen int) string {