InterruptMsg class

Message sent when the runtime receives a terminal interrupt.

This is distinct from QuitMsg in that it represents an external interrupt request rather than a programmatic quit command.

By default, pressing Ctrl+C produces this message instead of a Ctrl+C KeyMsg. Disable that behavior with ProgramOptions(sendInterrupt: false) or ProgramOptions.withoutInterruptMsg() if a model needs legacy key-based handling.

The model can handle this to:

  • Prompt for confirmation before quitting
  • Save state before exiting
  • Cancel a long-running operation
  • Ignore the interrupt entirely

Example

@override
(Model, Cmd?) update(Msg msg) {
  return switch (msg) {
    InterruptMsg() when hasUnsavedChanges => (
      copyWith(showConfirmDialog: true),
      null,
    ),
    InterruptMsg() => (this, Cmd.quit()),
    _ => (this, null),
  };
}
Inheritance

Constructors

InterruptMsg()
Creates an interrupt message.
const

Properties

dropWhenInputQueued bool
Whether this message can be dropped when fresher user input is queued.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited