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)


131
132
133
134
135
136
# File 'lib/tuile/event_queue.rb', line 131

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.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/tuile/event_queue.rb', line 128

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.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/tuile/event_queue.rb', line 128

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:



139
140
141
142
# File 'lib/tuile/event_queue.rb', line 139

def self.create
  height, width = TTY::Screen.size
  TTYSizeEvent.new(width, height)
end

Instance Method Details

#sizeSize

Returns:



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

def size = Size.new(width, height)