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

Add a focusable over-ride setting for widgets that are non-focusable by

default

For widgets that are non-focusable by default, you can now specify

    focusable: true

in their config to over-ride the default 'false' value.
This commit is contained in:
Chris Cummer 2019-08-31 10:00:00 -07:00
parent 248fddf3f4
commit d6208b4730
3 changed files with 7 additions and 3 deletions

View File

@ -49,6 +49,7 @@ type Common struct {
Bordered bool `help:"Whether or not the module should be displayed with a border." values:"true, false" optional:"true" default:"true"` Bordered bool `help:"Whether or not the module should be displayed with a border." values:"true, false" optional:"true" default:"true"`
Enabled bool `help:"Whether or not this module is executed and if its data displayed onscreen." values:"true, false" optional:"true" default:"false"` Enabled bool `help:"Whether or not this module is executed and if its data displayed onscreen." values:"true, false" optional:"true" default:"false"`
Focusable bool `help:"Whether or not this module is focusable." values:"true, false" optional:"true" default:"false"`
RefreshInterval int `help:"How often, in seconds, this module will update its data." values:"A positive integer, 0..n." optional:"true"` RefreshInterval int `help:"How often, in seconds, this module will update its data." values:"A positive integer, 0..n." optional:"true"`
Title string `help:"The title string to show when displaying this module" optional:"true"` Title string `help:"The title string to show when displaying this module" optional:"true"`
Config *config.Config Config *config.Config
@ -83,6 +84,7 @@ func NewCommonSettingsFromModule(name, defaultTitle string, moduleConfig *config
Bordered: moduleConfig.UBool("border", true), Bordered: moduleConfig.UBool("border", true),
Enabled: moduleConfig.UBool("enabled", false), Enabled: moduleConfig.UBool("enabled", false),
Focusable: moduleConfig.UBool("focusable", false),
RefreshInterval: moduleConfig.UInt("refreshInterval", 300), RefreshInterval: moduleConfig.UInt("refreshInterval", 300),
Title: moduleConfig.UString("title", defaultTitle), Title: moduleConfig.UString("title", defaultTitle),
Config: moduleConfig, Config: moduleConfig,

View File

@ -23,7 +23,9 @@ type Base struct {
enabledMutex *sync.Mutex enabledMutex *sync.Mutex
} }
func NewBase(app *tview.Application, commonSettings *cfg.Common, focusable bool) Base { func NewBase(app *tview.Application, commonSettings *cfg.Common, defaultFocusable bool) Base {
focusable := commonSettings.Focusable || defaultFocusable
base := Base{ base := Base{
commonSettings: commonSettings, commonSettings: commonSettings,
app: app, app: app,

View File

@ -13,9 +13,9 @@ type TextWidget struct {
} }
// NewTextWidget creates and returns an instance of TextWidget // NewTextWidget creates and returns an instance of TextWidget
func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, focusable bool) TextWidget { func NewTextWidget(app *tview.Application, commonSettings *cfg.Common, defaultFocusable bool) TextWidget {
widget := TextWidget{ widget := TextWidget{
Base: NewBase(app, commonSettings, focusable), Base: NewBase(app, commonSettings, defaultFocusable),
} }
widget.View = widget.createView(widget.bordered) widget.View = widget.createView(widget.bordered)