diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-05-07 19:29:46 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2024-05-07 19:56:24 +0200 |
commit | a22b5c8e14105b9617c8b2000f6353b011d1d0f9 (patch) | |
tree | c8d38e3c8ac49c5533aa3420074f303d132a2f02 | |
parent | 9a526bb260ae70b3f63652b48436dd0e7d3d5bb0 (diff) | |
download | luasystem-a22b5c8e14105b9617c8b2000f6353b011d1d0f9.zip |
chore(keypressed): remove function keypressed
easier to handle this on the Lua side
-rw-r--r-- | src/term.c | 28 |
1 files changed, 0 insertions, 28 deletions
@@ -738,34 +738,7 @@ static int lst_readkey(lua_State *L) { #endif } -/*** -Checks if a key has been pressed without reading it. -On Posix, `io.stdin` must be set to non-blocking mode using `setnonblock` -before calling this function. Otherwise it will block. - -@function keypressed -@treturn boolean true if a key has been pressed, nil if not. -*/ -static int lst_keypressed(lua_State *L) { -#ifdef _WIN32 - if (kbhit()) { - lua_pushboolean(L, 1); - return 1; - } - return 0; -#else - char ch; - if (read(STDIN_FILENO, &ch, 1) > 0) { - // key was read, push back to stdin - ungetc(ch, stdin); - lua_pushboolean(L, 1); - return 1; - } - return 0; - -#endif -} /*------------------------------------------------------------------------- * Retrieve terminal size @@ -821,7 +794,6 @@ static luaL_Reg func[] = { { "getnonblock", lst_setnonblock }, { "setnonblock", lst_setnonblock }, { "readkey", lst_readkey }, - { "keypressed", lst_keypressed }, { "termsize", lst_termsize }, { NULL, NULL } }; |