Class: Tuile::EventQueue::TTYSizeEvent
- Inherits:
-
Object
- Object
- Tuile::EventQueue::TTYSizeEvent
- Defined in:
- lib/tuile/event_queue.rb,
sig/tuile.rbs
Overview
TTY has been resized. Contains the current width and height of the TTY terminal.
Instance Attribute Summary collapse
-
#height ⇒ Integer
readonly
@return — terminal height in rows.
-
#width ⇒ Integer
readonly
@return — terminal width in columns.
Class Method Summary collapse
-
.create ⇒ TTYSizeEvent
@return — event with current TTY size.
Instance Method Summary collapse
-
#initialize(width:, height:) ⇒ TTYSizeEvent
constructor
@param
width. - #size ⇒ Size
Constructor Details
#initialize(width:, height:) ⇒ TTYSizeEvent
@param width
@param height
191 192 193 194 195 196 |
# File 'lib/tuile/event_queue.rb', line 191 def initialize(width:, height:) super return unless !width.is_a?(Integer) || !height.is_a?(Integer) || width.negative? || height.negative? raise ArgumentError, "TTY size must be non-negative integers, got #{width.inspect} x #{height.inspect}" end |
Instance Attribute Details
#height ⇒ Integer (readonly)
@return — terminal height in rows.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/tuile/event_queue.rb', line 188 class TTYSizeEvent < Data.define(:width, :height) # @param width [Integer] # @param height [Integer] def initialize(width:, height:) super return unless !width.is_a?(Integer) || !height.is_a?(Integer) || width.negative? || height.negative? raise ArgumentError, "TTY size must be non-negative integers, got #{width.inspect} x #{height.inspect}" end # @return [TTYSizeEvent] event with current TTY size. def self.create height, width = TTY::Screen.size TTYSizeEvent.new(width, height) end # @return [Size] def size = Size.new(width, height) end |
#width ⇒ Integer (readonly)
@return — terminal width in columns.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/tuile/event_queue.rb', line 188 class TTYSizeEvent < Data.define(:width, :height) # @param width [Integer] # @param height [Integer] def initialize(width:, height:) super return unless !width.is_a?(Integer) || !height.is_a?(Integer) || width.negative? || height.negative? raise ArgumentError, "TTY size must be non-negative integers, got #{width.inspect} x #{height.inspect}" end # @return [TTYSizeEvent] event with current TTY size. def self.create height, width = TTY::Screen.size TTYSizeEvent.new(width, height) end # @return [Size] def size = Size.new(width, height) end |
Class Method Details
.create ⇒ TTYSizeEvent
@return — event with current TTY size.
199 200 201 202 |
# File 'lib/tuile/event_queue.rb', line 199 def self.create height, width = TTY::Screen.size TTYSizeEvent.new(width, height) end |