fix crash

This commit is contained in:
2024-05-27 14:04:40 +02:00
parent aeebfb1997
commit ba247d0606

View File

@@ -8,6 +8,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/alecthomas/repr"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/tlinden/golsky/rle" "github.com/tlinden/golsky/rle"
) )
@@ -66,8 +67,14 @@ func (config *Config) ParseGeom(geom string) error {
// fit into window // fit into window
config.ScreenWidth = width - (width % config.Width) config.ScreenWidth = width - (width % config.Width)
config.ScreenHeight = height - (height % config.Height) config.ScreenHeight = height - (height % config.Height)
if config.ScreenWidth == 0 || config.ScreenHeight == 0 {
return errors.New("the number of requested cells don't fit into the requested window size")
}
config.Cellsize = config.ScreenWidth / config.Width config.Cellsize = config.ScreenWidth / config.Width
repr.Println(config)
return nil return nil
} }