struct Termisu::Event::ModeChange

Overview

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

Defined in:

termisu/event/mode_change.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(mode : Terminal::Mode, previous_mode : Terminal::Mode | Nil = nil) #

[View source]

Instance Method Detail

def changed? : Bool #

Returns true if the mode actually changed.

Returns false if:

  • Previous mode is nil (first change)
  • Previous mode equals current mode

[View source]
def from_raw? : Bool #

Returns true if transitioning from raw mode.


[View source]
def from_user_interactive? : Bool #

Returns true if transitioning from a user-interactive mode.


[View source]
def mode : Terminal::Mode #

The new terminal mode.


[View source]
def previous_mode : Terminal::Mode | Nil #

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


[View source]
def to_raw? : Bool #

Returns true if transitioning to raw mode.


[View source]
def to_user_interactive? : Bool #

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.


[View source]