diff --git a/_sample_configs/uniconfig.yml b/_sample_configs/uniconfig.yml new file mode 100644 index 00000000..6e3d88c1 --- /dev/null +++ b/_sample_configs/uniconfig.yml @@ -0,0 +1,19 @@ +wtf: + grid: + columns: [40] + rows: [16] + refreshInterval: 1 + mods: + textfile: + enabled: true + filePaths: + - "~/.config/wtf/config.yml" + - "~/.config/wtf/log.txt" + format: true + formatStyle: "vim" + position: + top: 1 + left: 1 + height: 2 + width: 1 + refreshInterval: 15 diff --git a/main.go b/main.go index 5da8d00e..b6bf52be 100644 --- a/main.go +++ b/main.go @@ -299,7 +299,7 @@ func main() { app.SetInputCapture(keyboardIntercept) // Loop in a routine to redraw the screen - go redrawApp(app) + //go redrawApp(app) go watchForConfigChanges(app, flags.Config, display.Grid, pages) if err := app.SetRoot(pages, true).Run(); err != nil { diff --git a/textfile/widget.go b/textfile/widget.go index 048d27ec..a050ace8 100644 --- a/textfile/widget.go +++ b/textfile/widget.go @@ -54,6 +54,9 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget { widget.View.SetWrap(true) widget.View.SetWordWrap(true) widget.View.SetInputCapture(widget.keyboardIntercept) + widget.View.SetChangedFunc(func() { + app.Draw() + }) go widget.watchForFileChanges() @@ -72,7 +75,7 @@ func (widget *Widget) Refresh() { func (widget *Widget) display() { title := fmt.Sprintf("[green]%s[white]", widget.CurrentSource()) - widget.View.SetTitle(widget.ContextualTitle(title)) + title = widget.ContextualTitle(title) text := wtf.SigilStr(len(widget.Sources), widget.Idx, widget.View) + "\n" @@ -82,6 +85,7 @@ func (widget *Widget) display() { text = text + widget.plainText() } + widget.View.SetTitle(title) widget.View.SetText(text) } diff --git a/wtf/utils.go b/wtf/utils.go index 4ebb989c..2ee581ab 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -6,6 +6,7 @@ import ( "os/exec" "regexp" "strings" + //"sync" "github.com/rivo/tview" ) @@ -26,6 +27,20 @@ func CenterText(str string, width int) string { return fmt.Sprintf("%[1]*s", -width, fmt.Sprintf("%[1]*s", (width+len(str))/2, str)) } +func DefaultFocussedRowColor() string { + foreColor := Config.UString("wtf.colors.highlight.fore", "black") + backColor := Config.UString("wtf.colors.highlight.back", "orange") + + return fmt.Sprintf("%s:%s", foreColor, backColor) +} + +func DefaultRowColor() string { + foreColor := Config.UString("wtf.colors.foreground", "white") + backColor := Config.UString("wtf.colors.background", "black") + + return fmt.Sprintf("%s:%s", foreColor, backColor) +} + func ExecuteCommand(cmd *exec.Cmd) string { stdout, err := cmd.StdoutPipe() if err != nil { @@ -109,24 +124,14 @@ func ReadFileBytes(filePath string) ([]byte, error) { } func RightAlignFormat(view *tview.TextView) string { + //mutex := &sync.Mutex{} + //mutex.Lock() _, _, w, _ := view.GetInnerRect() + //mutex.Unlock() + return fmt.Sprintf("%%%ds", w-1) } -func DefaultRowColor() string { - foreColor := Config.UString("wtf.colors.foreground", "white") - backColor := Config.UString("wtf.colors.background", "black") - - return fmt.Sprintf("%s:%s", foreColor, backColor) -} - -func DefaultFocussedRowColor() string { - foreColor := Config.UString("wtf.colors.highlight.fore", "black") - backColor := Config.UString("wtf.colors.highlight.back", "orange") - - return fmt.Sprintf("%s:%s", foreColor, backColor) -} - func RowColor(module string, idx int) string { evenKey := fmt.Sprintf("wtf.mods.%s.colors.rows.even", module) oddKey := fmt.Sprintf("wtf.mods.%s.colors.rows.odd", module)