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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user