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

WTF-748 Fixes and improves module templating (#786)

Fixes and improves the module templating for creating new bare-bones
text widgets.

This command:

    WTF_WIDGET_NAME=MyNewWidget go generate -run=text

now properly generates:

    * the module directory in the /modules directory
    * the widget.go file
    * the settings.go file

with no linter warnings or errors.

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2019-12-14 08:46:02 -08:00
committed by GitHub
parent 1686c9a6a9
commit 703619bf0a
7 changed files with 84 additions and 45 deletions

View File

@@ -24,5 +24,4 @@ func (widget *Widget) display() {
widget.Redraw(func() (string, string, bool) {
return widget.CommonSettings().Title, renderWidget(*widget.settings), false
})
}

View File

@@ -10,9 +10,8 @@ const (
defaultTitle = "Clocks"
)
// Settings struct to define settings got digital clock
// Settings defines the configuration properties for this module
type Settings struct {
// hello
common *cfg.Common
hourFormat string `help:"The format of the clock." values:"12 or 24"`
@@ -20,7 +19,7 @@ type Settings struct {
font string `help:"The font of the clock." values:"bigfont or digitalfont"`
}
// NewSettingsFromYAML functino to create setting instance from yaml file
// NewSettingsFromYAML creates a new settings instance from a YAML config block
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{

View File

@@ -5,7 +5,7 @@ import (
"github.com/wtfutil/wtf/view"
)
// Widget a text widget struct to hold info about the current widget
// Widget is a text widget struct to hold info about the current widget
type Widget struct {
view.TextWidget
@@ -15,7 +15,6 @@ type Widget struct {
// NewWidget creates a new widget using settings
func NewWidget(app *tview.Application, settings *Settings) *Widget {
widget := Widget{
TextWidget: view.NewTextWidget(app, settings.common),
@@ -30,9 +29,5 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
// Refresh updates the onscreen contents of the widget
func (widget *Widget) Refresh() {
widget.app.QueueUpdateDraw(func() {
widget.display()
})
widget.display()
}
/* -------------------- Unexported Functions -------------------- */

View File

@@ -28,7 +28,7 @@ func (t *tokenSource) Token() (*oauth2.Token, error) {
/* -------------------- Widget -------------------- */
// Widget is the container for transmission data
// Widget is the container for droplet data
type Widget struct {
view.KeyboardWidget
view.ScrollableWidget