
I embedded a scripting engine in a TUI app and it kind of blew up into its own thing
A few years ago I was working on a BLE device simulator for mobile app testing. I needed a way to script device behavior without recompiling every time, so I built a small embedded scripting engine for .NET. Stack-based, RPN style, vaguely inspired by HP calculator RPL.
That engine eventually became MOGWAI, which I've been developing on the side for about 10 years and open-sourced earlier this year.
Recently I thought: what if I used MOGWAI as the scripting layer for a TUI app builder? You describe your UI in a script, MOGWAI runs it, Terminal.Gui renders it. No C# required by the end user.
So I built GIZMO.
Here's what a real-time clock looks like:
mogwai.reset
timer 'clock' every 1000 do
{
now ->date -> '$d'
$d hour: get "00" ->format -> '$h'
$d minute: get "00" ->format -> '$m'
$d second: get "00" ->format -> '$s'
"{! $h}:{! $m}:{! $s}" eval -> '$time'
[! name: 'lbl' text: @$time] window.update
}
[!
name: 'main'
title: "Clock"
childs:
(
[ui.kind: 'ui.label' name: 'lbl' text: "00:00:00"]
[ui.kind: 'ui.button' label: "Close" onClick: { false window.hide }]
)
]
'clock' timer.start
window.show drop
The syntax is unusual, I know. RPN takes a minute to click but once it does it's kind of addictive.
The interesting part on the .NET side is the integration between MOGWAI and Terminal.Gui. Both need to run on the main thread, so there's a shared pump that keeps both alive. MOGWAI timers stay active even when a dialog is open.
GIZMO ships as self-contained executables (no .NET runtime needed), includes 15 UI components, a theme system, and a built-in TUI code editor you can launch from the REPL.
Still early but it works. Happy to answer questions about the architecture or the scripting engine.
GitHub: https://github.com/Sydney680928/Gizmo Website: https://gizmo.mogwai.eu.com