-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The include ioctl.h is not a part of Visual Studio C stuff. I have a patched version here that works:
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#ifdef __linux__
#include <sys/ioctl.h>
int lua_winsize(lua_State *L) {
struct winsize sz;
ioctl(0, TIOCGWINSZ, &sz);
lua_pushinteger(L, sz.ws_col);
lua_pushinteger(L, sz.ws_row);
return 2;
}
#elif _WIN32
#include <windows.h>
int lua_winsize(lua_State *L) {
CONSOLE_SCREEN_BUFFER_INFO csbi;
int columns, rows;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
lua_pushinteger(L, columns);
lua_pushinteger(L, rows);
return 2;
}
#endif
int luaopen_sirocco_winsize(lua_State *L) {
lua_pushcfunction(L, lua_winsize);
return 1;
}
Sorry for not sending a PR but downloaded the source as a zip.
iphelf
Metadata
Metadata
Assignees
Labels
No labels