commit e048b6050b6501361a5fbdde4aa384eaff975e6c
parent 22afbd7a319706889a4c8c843679fc7f485fb65d
Author: Skylar Hill <stellarskylark@posteo.net>
Date: Sat, 4 Jun 2022 16:32:23 -0500
More error messages
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/tui.nim b/src/tui.nim
@@ -99,10 +99,10 @@ proc placeWindows(tb: TerminalBuffer, windows: seq[YamlNode], descY: int): Table
result[win.content] = (currentX, 3, currentX + windowWidth - 1, descY - 1)
currentX += windowWidth
-proc exitProc() {.noconv.} =
+proc exitProc(message = "") {.noconv.} =
illwillDeinit()
showCursor()
- quit(0)
+ quit(message, 0)
proc command(cmdline: string, sheet: YamlDocument): string =
if cmdline == "":
@@ -121,7 +121,6 @@ proc runTui*(sheet: YamlDocument): void =
var tabIndex = 0
illwillInit(fullscreen=true)
- setControlCHook(exitProc)
hideCursor()
var selWinIndex = 0
@@ -141,7 +140,13 @@ proc runTui*(sheet: YamlDocument): void =
for name, content in sheet.root["expressions"].fields.pairs:
let win = content.getContent("window")
- var working = itemsByWindow[win]
+ if win == "":
+ exitProc(fmt"Error reading {name.content}: no window specified.")
+ var working: seq[string]
+ try:
+ working = itemsByWindow[win]
+ except KeyError:
+ exitProc(fmt"Error reading {name.content}: window '{win}' does not exist.")
working.add(name.content)
itemsByWindow[win] = working
diff --git a/src/verb.nim b/src/verb.nim
@@ -8,7 +8,7 @@ import
import utils
-let reRawExp = re"[a-zA-Z\-']+[a-zA-Z']"
+let reRawExp = re"[a-zA-Z\-']?[a-zA-Z']+"
let reProcessedExp = re"^[\d*+\-/()]*$"
let reDice = re"(\d+x)?(\d*d[\d%]+)(\*\d+)?([+-]\d+)?(s\d+)?"