mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-718 Fixes missing grid issue when running CmdRunner (#740)
Closes #718 and closes #730. Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
7c22408636
commit
a18fce88ac
@ -1,4 +1,5 @@
|
||||
wtf:
|
||||
grid:
|
||||
mods:
|
||||
battery:
|
||||
type: power
|
||||
|
@ -27,7 +27,6 @@ type Settings struct {
|
||||
|
||||
// NewSettingsFromYAML loads the cmdrunner portion of the WTF config
|
||||
func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, moduleConfig, globalConfig),
|
||||
|
||||
@ -37,7 +36,11 @@ func NewSettingsFromYAML(name string, moduleConfig *config.Config, globalConfig
|
||||
maxLines: moduleConfig.UInt("maxLines", 256),
|
||||
}
|
||||
|
||||
settings.width, settings.height = utils.CalculateDimensions(moduleConfig, globalConfig)
|
||||
width, height, err := utils.CalculateDimensions(moduleConfig, globalConfig)
|
||||
if err == nil {
|
||||
settings.width = width
|
||||
settings.height = height
|
||||
}
|
||||
|
||||
return &settings
|
||||
}
|
||||
|
@ -128,16 +128,21 @@ func ParseJSON(obj interface{}, text io.Reader) error {
|
||||
}
|
||||
|
||||
// CalculateDimensions reads the module dimensions from the module and global config. The border is already substracted.
|
||||
func CalculateDimensions(moduleConfig, globalConfig *config.Config) (int, int) {
|
||||
func CalculateDimensions(moduleConfig, globalConfig *config.Config) (int, int, error) {
|
||||
grid, err := globalConfig.Get("wtf.grid")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
cols := ToInts(grid.UList("wtf.grid.columns"))
|
||||
rows := ToInts(grid.UList("wtf.grid.rows"))
|
||||
|
||||
// Read the source data from the config
|
||||
left := moduleConfig.UInt("position.left", 0)
|
||||
top := moduleConfig.UInt("position.top", 0)
|
||||
width := moduleConfig.UInt("position.width", 0)
|
||||
height := moduleConfig.UInt("position.height", 0)
|
||||
|
||||
cols := ToInts(globalConfig.UList("wtf.grid.columns"))
|
||||
rows := ToInts(globalConfig.UList("wtf.grid.rows"))
|
||||
|
||||
// Make sure the values are in bounds
|
||||
left = Clamp(left, 0, len(cols)-1)
|
||||
top = Clamp(top, 0, len(rows)-1)
|
||||
@ -157,7 +162,7 @@ func CalculateDimensions(moduleConfig, globalConfig *config.Config) (int, int) {
|
||||
w = MaxInt(w, 0)
|
||||
h = MaxInt(h, 0)
|
||||
|
||||
return w, h
|
||||
return w, h, nil
|
||||
}
|
||||
|
||||
// MaxInt returns the larger of x or y
|
||||
|
Loading…
x
Reference in New Issue
Block a user