diff options
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 | }; |
