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

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

View File

@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/gdamore/tcell"
@ -49,7 +50,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
func (widget *Widget) Refresh() {
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)
@ -147,6 +148,10 @@ func (widget *Widget) Refresh() {
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) fileName() string {
return filepath.Base(widget.filePath)
}
func (widget *Widget) keyboardIntercept(event *tcell.EventKey) *tcell.EventKey {
switch string(event.Rune()) {
case "/":