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

Fix multiple small issues with widget titles

This commit is contained in:
Chris Cummer 2018-07-28 17:37:05 -07:00
parent 34977f7ffa
commit 3ce6daee71
4 changed files with 14 additions and 4 deletions

View File

@ -29,7 +29,7 @@ func (widget *Widget) Refresh() {
) )
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf("%s (%d)", widget.Name, len(todayItems))) widget.View.SetTitle(fmt.Sprintf("%s (%d) ", widget.Name, len(todayItems)))
widget.View.SetText(widget.contentFrom(todayItems)) widget.View.SetText(widget.contentFrom(todayItems))
} }

View File

@ -42,7 +42,12 @@ func (widget *Widget) Refresh() {
func (widget *Widget) String() string { func (widget *Widget) String() string {
args := strings.Join(widget.args, " ") args := strings.Join(widget.args, " ")
if args != "" {
return fmt.Sprintf(" %s %s ", widget.cmd, args) return fmt.Sprintf(" %s %s ", widget.cmd, args)
} else {
return fmt.Sprintf(" %s ", widget.cmd)
}
} }
func (widget *Widget) execute() { func (widget *Widget) execute() {

View File

@ -14,7 +14,7 @@ func (widget *Widget) display() {
return return
} }
widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name, 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

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"strings" "strings"
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
@ -49,7 +50,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
func (widget *Widget) Refresh() { func (widget *Widget) Refresh() {
widget.UpdateRefreshedAt() widget.UpdateRefreshedAt()
widget.View.SetTitle(fmt.Sprintf("%s %s", widget.Name, widget.filePath)) widget.View.SetTitle(fmt.Sprintf(" %s ", widget.fileName()))
filePath, _ := wtf.ExpandHomeDir(widget.filePath) filePath, _ := wtf.ExpandHomeDir(widget.filePath)
@ -147,6 +148,10 @@ func (widget *Widget) Refresh() {
/* -------------------- Unexported Functions -------------------- */ /* -------------------- Unexported Functions -------------------- */
func (widget *Widget) fileName() string {
return filepath.Base(widget.filePath)
}
func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey { func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
switch string(event.Rune()) { switch string(event.Rune()) {
case "/": case "/":