add tui_poll_noprefix()
This commit is contained in:
parent
c0d29b7f1b
commit
ccfdeb6013
21
tui.c
21
tui.c
|
@ -307,6 +307,27 @@ tui_poll()
|
|||
}
|
||||
}
|
||||
|
||||
struct event
|
||||
tui_poll_noprefix()
|
||||
{
|
||||
char c;
|
||||
|
||||
/* change attributes to make the program wait for input */
|
||||
raw.c_cc[VMIN] = 1;
|
||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1)
|
||||
die("tcsetattr");
|
||||
|
||||
read(STDIN_FILENO, &c, 1);
|
||||
/* reset attributes */
|
||||
raw.c_cc[VMIN] = 0;
|
||||
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1)
|
||||
die("tcsetattr");
|
||||
|
||||
return (struct event) {
|
||||
0, c
|
||||
};
|
||||
}
|
||||
|
||||
struct event
|
||||
tui_peek()
|
||||
{
|
||||
|
|
5
tui.h
5
tui.h
|
@ -175,10 +175,15 @@ void tui_show_cursor();
|
|||
void tui_set_cursor(int, int);
|
||||
|
||||
/* tui_poll() waits for input, and returns the event it recieved.
|
||||
* tui_poll_noprefix() works the same way as tui_poll(), only it does not handle
|
||||
* prefix keys (like escape). This means it can be used wherever one does not
|
||||
* care about prefix keys or when you just want to check if the user has pressed
|
||||
* escape.
|
||||
* tui_peek() gets buffered input. The program will not stop and wait for input,
|
||||
* like tui_poll(), but buffered input will be returned.
|
||||
*/
|
||||
struct event tui_poll();
|
||||
struct event tui_poll_noprefix();
|
||||
struct event tui_peek();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue