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

Make every widget a keyboard widget

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2020-11-26 02:10:21 -08:00
parent 2430fe9f56
commit 4a820dd0e5
112 changed files with 225 additions and 401 deletions

View File

@@ -9,6 +9,7 @@ import (
type Widget struct {
view.TextWidget
location *location
lastError error
settings *Settings
@@ -17,10 +18,11 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
locationData, err := GetLocationData(settings.city)
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
location: locationData,
lastError: err,
settings: settings,
TextWidget: view.NewTextWidget(app, nil, settings.common),
location: locationData,
lastError: err,
settings: settings,
}
widget.View.SetWrap(true)
@@ -42,7 +44,6 @@ func (widget *Widget) content() (string, string, bool) {
}
func (widget *Widget) Refresh() {
widget.Redraw(widget.content)
}

View File

@@ -19,7 +19,7 @@ type Widget struct {
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(app, nil, settings.common),
settings: settings,
}

View File

@@ -3,7 +3,7 @@ package weather
import "github.com/gdamore/tcell"
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.InitializeRefreshKeyboardControl(widget.Refresh)
widget.SetKeyboardChar("h", widget.PrevSource, "Select previous city")
widget.SetKeyboardChar("l", widget.NextSource, "Select next city")

View File

@@ -9,7 +9,6 @@ import (
// Widget is the container for weather data.
type Widget struct {
view.KeyboardWidget
view.MultiSourceWidget
view.TextWidget
@@ -23,16 +22,14 @@ type Widget struct {
// NewWidget creates and returns a new instance of the weather Widget
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
widget := Widget{
KeyboardWidget: view.NewKeyboardWidget(app, pages, settings.common),
MultiSourceWidget: view.NewMultiSourceWidget(settings.common, "cityid", "cityids"),
TextWidget: view.NewTextWidget(app, settings.common),
TextWidget: view.NewTextWidget(app, pages, settings.common),
pages: pages,
settings: settings,
}
widget.initializeKeyboardControls()
widget.View.SetInputCapture(widget.InputCapture)
widget.SetDisplayFunction(widget.display)
@@ -69,10 +66,6 @@ func (widget *Widget) Refresh() {
widget.display()
}
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
/* -------------------- Unexported Functions -------------------- */
func (widget *Widget) apiKeyValid() bool {