1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */ 2 3 #ifndef _COMM_H_ 4 5 #define _COMM_H_ 6 typedef struct Window { 7 int top; 8 int bottom; 9 int left; 10 int right; 11 int framed; 12 struct Window *parent; 13 } window_t; 14 15 typedef enum decor { DC_NORMAL, DC_CHOOSED, DC_POINTED } decor_t; 16 17 enum { 18 KEY_UP = 256, /* char max +1 */ 19 KEY_DOWN, 20 KEY_RIGHT, 21 KEY_LEFT, 22 KEY_ESC, 23 KEY_DEL, 24 KEY_BS 25 }; 26 /* 27 * control terminal 28 */ 29 void set_cursor_pos(window_t *window, int x, int y); 30 31 int read_one(void); 32 void flush_stdout(void); 33 34 /* alternate screen */ 35 void set_altscr(void); 36 void unset_altscr(void); 37 38 void set_keypad(void); 39 void unset_keypad(void); 40 41 void set_fg_color(int colorid); 42 void set_fg_color_default(void); 43 void set_bg_color(int colorid); 44 45 void cursor_show(void); 46 void cursor_hide(void); 47 48 void dec_char(void); 49 void normal_char(void); 50 51 int term_size(int *w, int *h); 52 53 char *mlterm_get_color_param(const char *key); 54 char *mlterm_get_font_param(const char *file, const char *key); 55 char *mlterm_get_param(const char *key); 56 void mlterm_set_color_param(const char *key, char *value); 57 void mlterm_set_font_param(const char *file, const char *key, char *value); 58 void mlterm_set_param(const char *key, char *value); 59 void mlterm_set_value(const char *key, int value); 60 void mlterm_exec(const char *cmd); 61 62 /* 63 * text window management 64 */ 65 window_t *window_new(int left, int top, int right, int bottom, int framed, window_t *parent); 66 void window_addstr(window_t *window, int x, int y, const char *str); 67 void window_clear(window_t *window); 68 void window_free(window_t *window); 69 int window_width(window_t *window); 70 71 /* 72 * termios (for unbuffered I/O) 73 */ 74 int termios_init(void); 75 int termios_final(void); 76 77 /* 78 * convenience functions 79 */ 80 void display_colorcube(window_t *window, int x, int y, int colorid); 81 void display_str(window_t *window, int x, int y, const char *src, decor_t flag); 82 void display_numeric(window_t *window, int x, int y, int value, const char *unit, decor_t flag); 83 int colorid_from_name(char *name); 84 const char *colorname_from_id(int colorid); 85 86 int string_edit(window_t *window, char *src, char **result); 87 int color_select(window_t *edit, int initial); 88 #endif 89