Skip to content

Instantly share code, notes, and snippets.

@lian
Created November 9, 2013 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lian/7381252 to your computer and use it in GitHub Desktop.
Save lian/7381252 to your computer and use it in GitHub Desktop.
IO#winsize
class IO
TIOCGWINSZ = 0x5413
TIOCSWINSZ = 0x5414
Winsize = Struct.new(:rows, :columns, :horizontal_pixels, :vertical_pixels)
def winsize
ioctl(TIOCGWINSZ, size=""); Winsize.new(*size.unpack("SSSS"))
end
def winsize=(winsize)
ioctl(TIOCSWINSZ, winsize.values.pack("SSSS"))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment