|
|
tterm.h - iomenu - interactive terminal-based selection menu |
|
|
 |
git clone git://bitreich.org/iomenu git://hg6vgqziawt5s4dj.onion/iomenu (git://bitreich.org) |
|
|
 |
Log |
|
|
 |
Files |
|
|
 |
Refs |
|
|
 |
Tags |
|
|
 |
README |
|
|
 |
LICENSE |
|
|
|
--- |
|
|
|
tterm.h (964B) |
|
|
|
--- |
|
|
|
1 #ifndef TERM_H |
|
|
|
2 #define TERM_H |
|
|
|
3 |
|
|
|
4 #include <stdint.h> |
|
|
|
5 #include <stdio.h> |
|
|
|
6 #include <sys/ioctl.h> |
|
|
|
7 #include <termios.h> |
|
|
|
8 #include <unistd.h> |
|
|
|
9 |
|
|
|
10 #define TERM_KEY_CTRL(c) ((c) & ~0x40) |
|
|
|
11 #define TERM_KEY_ALT(c) (0x100 + (c)) |
|
|
|
12 #define TERM_KEY_CSI(c, i) (0x100 + (c) * 0x100 + (i)) |
|
|
|
13 |
|
|
|
14 enum term_key { |
|
|
|
15 TERM_KEY_ESC = 0x1b, |
|
|
|
16 TERM_KEY_DELETE = 127, |
|
|
|
17 TERM_KEY_BACKSPACE = TERM_KEY_CTRL('H'), |
|
|
|
18 TERM_KEY_TAB = TERM_KEY_CTRL('I'), |
|
|
|
19 TERM_KEY_ENTER = TERM_KEY_CTRL('J'), |
|
|
|
20 TERM_KEY_ARROW_UP = TERM_KEY_CSI('A', 0), |
|
|
|
21 TERM_KEY_ARROW_DOWN = TERM_KEY_CSI('B', 0), |
|
|
|
22 TERM_KEY_PAGE_UP = TERM_KEY_CSI('~', 5), |
|
|
|
23 TERM_KEY_PAGE_DOWN = TERM_KEY_CSI('~', 6), |
|
|
|
24 }; |
|
|
|
25 |
|
|
|
26 struct term { |
|
|
|
27 struct winsize winsize; |
|
|
|
28 struct termios old_termios; |
|
|
|
29 }; |
|
|
|
30 |
|
|
|
31 /** src/term.c **/ |
|
|
|
32 struct term term; |
|
|
|
33 int term_width_at_pos(uint32_t codepoint, int pos); |
|
|
|
34 int term_at_width(char const *s, int width, int pos); |
|
|
|
35 int term_raw_on(int fd); |
|
|
|
36 int term_raw_off(int fd); |
|
|
|
37 int term_get_key(FILE *fp); |
|
|
|
38 |
|
|
|
39 #endif |
|