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 /src | |
parent | 9a526bb260ae70b3f63652b48436dd0e7d3d5bb0 (diff) | |
download | luasystem-a22b5c8e14105b9617c8b2000f6353b011d1d0f9.tar.gz luasystem-a22b5c8e14105b9617c8b2000f6353b011d1d0f9.tar.bz2 luasystem-a22b5c8e14105b9617c8b2000f6353b011d1d0f9.zip |
chore(keypressed): remove function keypressed
easier to handle this on the Lua side
Diffstat (limited to 'src')
-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) { | |||
738 | #endif | 738 | #endif |
739 | } | 739 | } |
740 | 740 | ||
741 | /*** | ||
742 | Checks if a key has been pressed without reading it. | ||
743 | On Posix, `io.stdin` must be set to non-blocking mode using `setnonblock` | ||
744 | before calling this function. Otherwise it will block. | ||
745 | |||
746 | @function keypressed | ||
747 | @treturn boolean true if a key has been pressed, nil if not. | ||
748 | */ | ||
749 | static int lst_keypressed(lua_State *L) { | ||
750 | #ifdef _WIN32 | ||
751 | if (kbhit()) { | ||
752 | lua_pushboolean(L, 1); | ||
753 | return 1; | ||
754 | } | ||
755 | return 0; | ||
756 | 741 | ||
757 | #else | ||
758 | char ch; | ||
759 | if (read(STDIN_FILENO, &ch, 1) > 0) { | ||
760 | // key was read, push back to stdin | ||
761 | ungetc(ch, stdin); | ||
762 | lua_pushboolean(L, 1); | ||
763 | return 1; | ||
764 | } | ||
765 | return 0; | ||
766 | |||
767 | #endif | ||
768 | } | ||
769 | 742 | ||
770 | /*------------------------------------------------------------------------- | 743 | /*------------------------------------------------------------------------- |
771 | * Retrieve terminal size | 744 | * Retrieve terminal size |
@@ -821,7 +794,6 @@ static luaL_Reg func[] = { | |||
821 | { "getnonblock", lst_setnonblock }, | 794 | { "getnonblock", lst_setnonblock }, |
822 | { "setnonblock", lst_setnonblock }, | 795 | { "setnonblock", lst_setnonblock }, |
823 | { "readkey", lst_readkey }, | 796 | { "readkey", lst_readkey }, |
824 | { "keypressed", lst_keypressed }, | ||
825 | { "termsize", lst_termsize }, | 797 | { "termsize", lst_termsize }, |
826 | { NULL, NULL } | 798 | { NULL, NULL } |
827 | }; | 799 | }; |