Program options
Configure a Program with the ProgramOptions struct for common flags, or the fluent programOptions function list for finer control over the renderer, input tracking and message filtering.
Configuring a Program
dart
Program(
options: const ProgramOptions(
altScreen: true,
hideCursor: true,
tickInterval: Duration(milliseconds: 100),
logFile: File('debug.log'),
),
programOptions: [
withFps(60), // default 60, max 120
withCellRenderer(), // cell-level diff (less flicker on older terminals)
withAltScreen(), // enter alternate screen buffer
withHideCursor(), // hide terminal cursor
withTickInterval(const Duration(milliseconds: 100)), // global tick rate
withMouseCellMotion(), // enable button-event mouse tracking
withMouseAllMotion(), // enable all-motion mouse tracking
withReportFocus(), // enable focus/blur reporting (FocusMsg / BlurMsg)
withWindowSize(120, 40), // inject a fixed window size (useful in tests)
withFilter((model, msg) { // intercept / transform messages
if (msg is QuitMsg) return null; // suppress
return msg;
}),
],
).run(MyModel());| Option | Effect |
|---|---|
| withFps(n) | Cap screen output frame rate (default 60, max 120). |
| withCellRenderer() | Use the cell-level diff renderer for older terminals. |
| withAltScreen() | Render on the alternate screen buffer. |
| withHideCursor() | Hide the terminal cursor. |
| withMouseCellMotion() / withMouseAllMotion() | Enable mouse tracking. |
| withReportFocus() | Deliver FocusMsg / BlurMsg on focus changes. |
| withWindowSize(w, h) | Inject a fixed window size (handy in tests). |
| withFilter(fn) | Intercept, transform or suppress messages globally. |