| 1 | #ifndef UI_H |
| 2 | #define UI_H |
| 3 | |
| 4 | #include <ncurses.h> |
| 5 | #include <stdbool.h> |
| 6 | #include <stddef.h> |
| 7 | |
| 8 | #include "dir.h" |
| 9 | #include "main.h" |
| 10 | |
| 11 | #define CTRL(k) ((k) & 0x1F) |
| 12 | |
| 13 | #define KEY_DEL 127 |
| 14 | #define KEY_ESC 27 |
| 15 | |
| 16 | #define UP_KEYS \ |
| 17 | case KEY_UP: \ |
| 18 | case CTRL('P'): \ |
| 19 | case 'k' |
| 20 | |
| 21 | #define DOWN_KEYS \ |
| 22 | case KEY_DOWN: \ |
| 23 | case CTRL('N'): \ |
| 24 | case 'j' |
| 25 | |
| 26 | #define LEFT_KEYS \ |
| 27 | case KEY_LEFT: \ |
| 28 | case CTRL('B'): \ |
| 29 | case 'h' |
| 30 | |
| 31 | #define RIGHT_KEYS \ |
| 32 | case KEY_RIGHT: \ |
| 33 | case CTRL('F'): \ |
| 34 | case 'l' |
| 35 | |
| 36 | enum ui_color { |
| 37 | COLOR_FILE = 1, |
| 38 | COLOR_DIR, |
| 39 | COLOR_FIFO, |
| 40 | COLOR_LINK, |
| 41 | COLOR_BLOCK, |
| 42 | COLOR_CHAR, |
| 43 | COLOR_SOCKET, |
| 44 | COLOR_UNKNOWN, |
| 45 | COLOR_EXEC, |
| 46 | |
| 47 | RED, |
| 48 | YELLOW, |
| 49 | MAGENTA, |
| 50 | WHITE, |
| 51 | |
| 52 | }; |
| 53 | |
| 54 | // basically an array of strings (last entry is NULL) |
| 55 | typedef const char * const prompt_opts_t[]; |
| 56 | |
| 57 | void ui_init(void); |
| 58 | void ui_deinit(void); |
| 59 | void ui_reinit(void); |
| 60 | void ui_set_title(const char * title, const char * home); |
| 61 | void ui_status_info(const char * status); |
| 62 | void ui_status_error(const char * status); |
| 63 | void ui_erase(void); |
| 64 | void ui_refresh(void); |
| 65 | void ui_print_dir(const dir_t * dir, size_t cursor); |
| 66 | void ui_print_cursor(size_t cursor, size_t total, enum prog_mode mode, size_t total_marked); |
| 67 | void ui_resize(void); |
| 68 | const char * ui_readline(const char * prompt); |
| 69 | const char * ui_prompt(const char * prompt, prompt_opts_t opts); |
| 70 | bool ui_prompt_deletion(const dirent_t * de, size_t total_marked); |
| 71 | bool ui_prompt_paste(size_t total_marked); |
| 72 | |
| 73 | #endif /* UI_H */ |
| 74 | |