Sha256: 5ac18b58a9496634c3a67c2bb5c06d1eb71c36ef151a11e279c8b56e0b84fef8
Contents?: true
Size: 894 Bytes
Versions: 1
Compression:
Stored size: 894 Bytes
Contents
class Winsize require "winsize.so" require "winsize/version" attr_accessor :rows, :columns, :horizontal_pixels, :vertical_pixels alias cols columns def initialize(rows, columns, horizontal_pixels = 0, vertical_pixels = 0) @rows, @columns, @horizontal_pixels, @vertical_pixels = rows, columns, horizontal_pixels, vertical_pixels end def [](index) to_ary[index] end def to_ary [rows, columns, horizontal_pixels, vertical_pixels] end def to_ioctl [rows, columns, horizontal_pixels, vertical_pixels].pack("SSSS") end module IOExtension def winsize size = "" ioctl(TIOCGWINSZ, size) Winsize.new(*size.unpack("SSSS")) end def winsize=(size) size = size.respond_to?(:to_ioctl) ? size.to_ioctl : Winsize.new(*size).to_ioctl ioctl(TIOCSWINSZ, size) end end end class IO include Winsize::IOExtension end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
winsize-2.0.0 | lib/winsize.rb |