class RatatuiRuby::Event::Resize
Signals a change in terminal dimensions.
The terminal window is dynamic, not static. The user changes its dimensions at will, usually breaking a fixed layout.
This event captures the new state. It delivers the updated width and height immediately after the change.
Use these dimensions to drive your layout logic. Recalculate constraints. Reallocate space. Fill the new canvas completely to maintain a responsive design.
Examples
Using predicates:
if event.resize? puts "Resized to #{event.width}x#{event.height}" end
Using pattern matching:
case event in type: :resize, width:, height: puts "Resized to #{width}x#{height}" end
Attributes
New terminal height in rows.
puts event.height # => 24
New terminal width in columns.
puts event.width # => 80
Public Class Methods
Source
# File lib/ratatui_ruby/event/resize.rb, line 57 def initialize(width:, height:) @width = width @height = height end
Creates a new Resize event.
- width
-
New width (Integer).
- height
-
New height (Integer).
Public Instance Methods
Source
# File lib/ratatui_ruby/event/resize.rb, line 74 def ==(other) return false unless other.is_a?(Resize) width == other.width && height == other.height end
Compares this event with another for equality.
Source
# File lib/ratatui_ruby/event/resize.rb, line 68 def deconstruct_keys(keys) { type: :resize, width: @width, height: @height } end
Deconstructs the event for pattern matching.
case event in type: :resize, width:, height: puts "Resized to #{width}x#{height}" end
Source
# File lib/ratatui_ruby/event/resize.rb, line 47 def resize? true end
Returns true for Resize events.
event.resize? # => true event.key? # => false event.mouse? # => false