run method

Future<void> run()

Runs the TUI program.

This method:

  1. Sets up the terminal
  2. Initializes the model
  3. Starts the event loop
  4. Waits for quit signal
  5. 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();
  }
}