From a22b5c8e14105b9617c8b2000f6353b011d1d0f9 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 7 May 2024 19:29:46 +0200 Subject: chore(keypressed): remove function keypressed easier to handle this on the Lua side --- src/term.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/term.c b/src/term.c index 715ec4a..f73d23f 100644 --- a/src/term.c +++ b/src/term.c @@ -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 } }; -- cgit v1.2.3-55-g6feb