1 file changed, +9, -0
2d7ba64feat(config): add terminal size constraints
author
mogi <git@mogiya.dev> on 09-06-2026 17:59 UTC+1
committer
mogi <git@mogiya.dev> on 09-06-2026 17:59 UTC+1
parent8f7bf7c
config.py
+9, -0
+9, -0
      @@ -1,5 +1,7 @@
  1  1 """Config file parser for a_maze_ing."""
  2  2 
     3+import os
     4+
  3  5 from dataclasses import dataclass
  4  6 
  5  7 
      @@ -87,6 +89,13 @@ def parse_config(path: str) -> Config:
 87 89     height = _parse_int(raw["HEIGHT"], "HEIGHT")
 88 90     if width < 2 or height < 2:
 89 91         raise ConfigError("WIDTH and HEIGHT must be >= 2")
    92+    if width > 100 or height > 100:
    93+        raise ConfigError("WIDTH and HEIGHT must be <= 100")
    94+    ts_x, ts_y = os.get_terminal_size()
    95+    if ts_x < 2 * width + 1 or ts_x < 106:
    96+        raise ConfigError("Terminal width must be big enough")
    97+    if ts_y < (2 * height + 1) + 8:
    98+        raise ConfigError("Terminal height must be big enough")
 90 99 
 91100     clamp_endpoints = False
 92101     if "CLAMP_ENDPOINTS" in raw: