Class: Tuile::EventQueue::TTYSizeEvent

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:) ⇒ TTYSizeEvent

Returns a new instance of TTYSizeEvent.

Parameters:

  • width (Integer)
  • height (Integer)

Raises:

  • (ArgumentError)


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

#heightInteger (readonly)

Returns terminal height in rows.

Returns:

  • (Integer)

    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

#widthInteger (readonly)

Returns terminal width in columns.

Returns:

  • (Integer)

    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

.createTTYSizeEvent

Returns event with current TTY size.

Returns:



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

Instance Method Details

#sizeSize

Returns:



132
# File 'lib/tuile/event_queue.rb', line 132

def size = Size.new(width, height)