Messages
Message is a marker interface with no methods. Any class or record that implements it can be delivered to update.
KeyPressMessage
Delivered for every key press. Usekey() to get the string representation.
KeyPressMessage also provides type() (KeyType) and runes() for lower-level access.
WindowSizeMessage
Sent at startup and whenever the terminal is resized.FocusMessage and BlurMessage
Delivered when the terminal window gains or loses focus. RequiresProgramOption.withReportFocus().
QuitMessage
A special message that causes the program to exit cleanly after the current frame is rendered. You normally produce it via aCommand rather than returning it directly from update.
Custom messages
ImplementMessage on any class or Java record. Records are the most concise option:
update:
Commands
Command is a functional interface that returns a Message when executed.
Message back into the event loop. Commands should not update model state directly.
Returning a command from update
Built-in command factories
Command provides static factory methods for common operations:
Command.none()
UseCommand.none() (or null) to signal that no command should run. Prefer Command.none() for clarity:
BatchMessage
BatchMessage runs multiple commands concurrently. Use Command.batch(...) to create one:
SequenceMessage
SequenceMessage runs commands one at a time, in order. Use Command.sequence(...) to create one:
Command.sequence executes commands serially and delivers each message as it arrives.
Command.batch runs commands concurrently with no ordering guarantee. Use sequence when
each step depends on the previous one completing.Command.sequentially(...) is similar but stops after the first command that returns a non-null message:
The Elm Architecture
How Model, Update, and View fit together.
Styling with Lipgloss
Colors, borders, padding, and layout.