struct

Termisu::Event::ModeChange

Inherits Struct / Value / Object

Terminal mode change event.

Generated when the terminal mode is changed via set_mode or with_mode. Includes both the new mode and previous mode for tracking transitions.

Example:

termisu.each_event do |event|
  case event
  when Termisu::Event::ModeChange
    puts "Mode changed: #{event.previous_mode} -> #{event.mode}"
    if event.to_raw?
      # Re-entering TUI mode
    elsif event.from_raw?
      # Leaving TUI mode
    end
  end
end

Constructors

new(mode : Terminal::Mode, previous_mode : Terminal::Mode | Nil = nil)
Source

Instance methods

changed?

Returns true if the mode actually changed.

Returns false if:

  • Previous mode is nil (first mode assignment, not a change)
  • Previous mode equals current mode
Source
from_raw?

Returns true if transitioning from raw mode.

Source
from_user_interactive?

Returns true if transitioning from a user-interactive mode.

Source
mode

The new terminal mode.

Source
previous_mode

The previous terminal mode (nil if this is the first mode change).

Source
to_raw?

Returns true if transitioning to raw mode.

Source
to_user_interactive?

Returns true if transitioning to a user-interactive mode.

User-interactive modes have canonical input or echo enabled, where the terminal driver handles input rather than the application.

Source