1 /** 2 * A layout manager for ncurses. 3 */ 4 5 #ifndef TCD_UI_LAYOUT_H 6 #define TCD_UI_LAYOUT_H 7 8 #include <ncurses.h> 9 10 /** 11 * Coordinates of a box on the screen. 12 */ 13 struct coords { 14 int top, left, bottom, right, height, width; 15 }; 16 17 /** 18 * Calculate all fields of a box from the arguments. 19 */ 20 extern void set_coords(struct coords *co, int top, int left, int bottom, int right); 21 22 /** 23 * Draw a horizontal line with tee endpoints. 24 */ 25 extern void mvwhsplit(WINDOW *win, int y, int x, int len); 26 #define mvhsplit(m_y, m_x, m_len) \ 27 mvwhsplit(stdscr, m_y, m_x, m_len) 28 29 /** 30 * Draw a vertical line with tee endpoints. 31 */ 32 extern void mvwvsplit(WINDOW *win, int y, int x, int len); 33 #define mvvsplit(m_y, m_x, m_len) \ 34 mvwvsplit(stdscr, m_y, m_x, m_len) 35 36 /** 37 * Draw a (possibly long) string in a window. If the string is too long 38 * to fit, the last three characters are replaced with "...". 39 */ 40 extern void mvwaddlstr(WINDOW *win, int y, int x, const char *s, int maxlen); 41 #define mvaddlstr(m_y, m_x, m_s, m_maxlen) \ 42 mvwaddlstr(stdscr, m_y, m_x, m_s, m_maxlen) 43 44 /** 45 * Show a nice input box for the user. 46 * Returns 0 on success, -1 on error. 47 */ 48 extern int input_box(char *buf, size_t bufsize, const char *title); 49 50 #endif 51