-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
52 lines (40 loc) · 1.31 KB
/
Copy pathexample.c
File metadata and controls
52 lines (40 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define EP_IMPLEMENTATION
#include "epithet.h"
void draw(void) {
epClear();
// The last argument is the length of the string. If it is zero, the length is automatically determined.
//
// If it is not zero, the string does not need to have a NUL termination.
epDrawString(0, 0, EP_ATTR_NONE, "Press any key to continue", 0);
epFlush();
}
int main(int argc, char **argv) {
// Initialize the library.
epInit();
// Don't echo pressed keys, and send key events without buffering and waiting for the enter key.
epSetFlags(EP_NO_ECHO_BIT | EP_NO_BUFFER_BIT);
// Hide cursor.
epSetCursorVisible(false);
// Wait for the user to press any key.
uint32_t key = EP_KEY_NONE;
while(1) {
key = epGetKey();
draw();
// The first `epGetKey` call will always return `EP_KEY_RESIZE`.
if(key == EP_KEY_RESIZE) {
epDrawString(0, 1, EP_ATTR(EP_STYLE_INVERT, EP_COLOR_BLUE, EP_COLOR_NORMAL), "Resized!", 0);
epFlush();
continue;
} else {
break;
}
}
// Display the key number in red.
epDrawStringf(0, 2, EP_ATTR(EP_STYLE_NONE, EP_COLOR_RED, EP_COLOR_NORMAL), "You pressed %u", key);
epFlush();
// Deinitialize the library.
//
// This will reset the terminal as much as possible to prevent attributes, input state, etc. from leaking.
epDeinit();
return 0;
}