Class: Tuile::EventQueue::TTYSizeEvent

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:) ⇒ TTYSizeEvent

@param width

@param height

Parameters:

  • width: (Integer)
  • height: (Integer)


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

#heightInteger (readonly)

@return — terminal height in rows.

Returns:

  • (Integer)


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

#widthInteger (readonly)

@return — terminal width in columns.

Returns:

  • (Integer)


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

.createTTYSizeEvent

@return — event with current TTY size.

Returns:



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

Instance Method Details

#sizeSize

Returns:



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

def size = Size.new(width, height)