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

Refactor a number of widgets to display client errors

Rather than swallowing or crashing, display appropriate errors
This commit is contained in:
Sean Smith
2019-09-01 13:19:07 -04:00
parent ff77a3deb0
commit 8835f532cc
12 changed files with 83 additions and 60 deletions

View File

@@ -45,7 +45,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.SetDisplayFunction(widget.display)
widget.SetDisplayFunction(widget.Refresh)
widget.View.SetWordWrap(true)
widget.View.SetWrap(settings.wrapText)
@@ -61,7 +61,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
// Refresh is only called once on start-up. Its job is to display the
// text files that first time. After that, the watcher takes over
func (widget *Widget) Refresh() {
widget.display()
widget.Redraw(widget.content)
}
func (widget *Widget) HelpText() string {
@@ -70,10 +70,6 @@ func (widget *Widget) HelpText() string {
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) display() {
widget.Redraw(widget.content)
}
func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf("[green]%s[white]", widget.CurrentSource())
@@ -142,7 +138,7 @@ func (widget *Widget) watchForFileChanges() {
for {
select {
case <-watch.Event:
widget.display()
widget.Refresh()
case err := <-watch.Error:
fmt.Println(err)
os.Exit(1)