Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C code doesn't build on Windows #3

Open
soapdog opened this issue Dec 31, 2019 · 1 comment
Open

C code doesn't build on Windows #3

soapdog opened this issue Dec 31, 2019 · 1 comment

Comments

@soapdog
Copy link

soapdog commented Dec 31, 2019

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.

@giann
Copy link
Owner

giann commented Dec 31, 2019

Sirocco does not support Windows right now. PR is welcome when you have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants