Class: Tuile::EventQueue::TTYSizeEvent
- Inherits:
-
Object
- Object
- Tuile::EventQueue::TTYSizeEvent
- Defined in:
- lib/tuile/event_queue.rb
Overview
TTY has been resized. Contains the current width and height of the TTY terminal.
Instance Attribute Summary collapse
-
#height ⇒ Integer
readonly
Terminal height in rows.
-
#width ⇒ Integer
readonly
Terminal width in columns.
Class Method Summary collapse
-
.create ⇒ TTYSizeEvent
Event with current TTY size.
Instance Method Summary collapse
-
#initialize(width:, height:) ⇒ TTYSizeEvent
constructor
A new instance of TTYSizeEvent.
- #size ⇒ Size
Constructor Details
#initialize(width:, height:) ⇒ TTYSizeEvent
Returns a new instance of TTYSizeEvent.
118 119 120 121 122 123 |
# File 'lib/tuile/event_queue.rb', line 118 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)
Returns terminal height in rows.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/tuile/event_queue.rb', line 115 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)
Returns terminal width in columns.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/tuile/event_queue.rb', line 115 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
Returns event with current TTY size.
126 127 128 129 |
# File 'lib/tuile/event_queue.rb', line 126 def self.create height, width = TTY::Screen.size TTYSizeEvent.new(width, height) end |