run method
Runs the TUI program.
This method:
- Sets up the terminal
- Initializes the model
- Starts the event loop
- Waits for quit signal
- Cleans up and exits
Returns when the program exits (via Cmd.quit or interrupt).
If ProgramOptions.catchPanics is true (default), exceptions are caught, the terminal is restored, and a formatted error is printed.
Implementation
Future<void> run() async {
if (_running) {
throw StateError('Program is already running');
}
_running = true;
_cancelled = false;
_runCompleter = Completer<void>();
_panic = null;
_panicStackTrace = null;
if (_options.catchPanics) {
await _runWithPanicRecovery();
} else {
await _runWithoutPanicRecovery();
}
}