TextEditor is a small MoonBit terminal editor demo that exercises the published TerminalEvent, LunarEvent, and LunarTUI packages together.
It is intentionally minimal: the goal is to validate the event pipeline, widget event handling, redraw behavior, and file saving path after the projects are consumed from mooncake instead of a local moon.work workspace.
Typing text in the editor:
Saving the buffer to disk:
TerminalEvent C++ core
-> TerminalEvent C FFI
-> LunarEvent MoonBit event API
-> LunarEvent/lunartui adapter
-> LunarTUI widget event handling
-> TextEditor redraw loop
The repository has no moon.work; dependencies are resolved from mooncake:
import {
"FrozenLemonTee/LunarEvent@0.1.0",
"FrozenLemonTee/LunarTUI@0.0.2",
"moonbitlang/x@0.4.40",
}moon update
moon run cmd/mainThe demo is designed for a POSIX terminal. On Windows, the current TerminalEvent backend may report raw mode as unavailable unless the program is run in a compatible POSIX terminal environment such as WSL.
- Type text to insert characters at the cursor.
- Arrow keys move the cursor.
Backspaceedits text.Tabinserts two spaces.Enterinserts a new line.Ctrl+Ssaves the buffer toterminal-event-demo.txt.qorEscexits and restores the terminal.
moon test cmd/main --target nativeThe tests cover line serialization and file saving.

