Sha256: 2964611e32dcb500056efb16dd8e6171d6375b6ef8d8305a6f8a1e8d1e80f744
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
require "winsize.so" require "winsize/version" module Winsize class Winsize attr_accessor :rows, :columns, :horizontal_pixels, :vertical_pixels 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) [rows, columns][index] end def to_ioctl [rows, columns, horizontal_pixels, vertical_pixels].pack("SSSS") end end module IOExtensions # TIOCGWINSZ & TIOCSWINSZ are defined in ext/winsize.c def winsize size = "" ioctl(TIOCGWINSZ, size) Winsize.new(*size.unpack("SSSS")) end def winsize=(size) size = Winsize.new(*size) unless size.respond_to?(:to_ioctl) size = size.to_ioctl ioctl(TIOCSWINSZ, size) end end end class IO include Winsize::IOExtensions end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
winsize-1.0.1 | lib/winsize.rb |