Created
October 1, 2017 19:28
-
-
Save goyox86/06a36d1193d3f4a6c66944262d949e62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if defined TIOCGWINSZ | |
typedef struct winsize rb_console_size_t; | |
#define getwinsize(fd, buf) (ioctl((fd), TIOCGWINSZ, (buf)) == 0) | |
#define setwinsize(fd, buf) (ioctl((fd), TIOCSWINSZ, (buf)) == 0) | |
#define winsize_row(buf) (buf)->ws_row | |
#define winsize_col(buf) (buf)->ws_col | |
#elif defined _WIN32 | |
typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t; | |
#define getwinsize(fd, buf) ( \ | |
GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), (buf)) || \ | |
SET_LAST_ERROR) | |
#define winsize_row(buf) ((buf)->srWindow.Bottom - (buf)->srWindow.Top + 1) | |
#define winsize_col(buf) (buf)->dwSize.X | |
#endif | |
#if defined TIOCGWINSZ || defined _WIN32 | |
#define USE_CONSOLE_GETSIZE 1 | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment