tuikit.h (1786B)
1 /* tuikit.h - piezas de la TUI (ncurses) comunes a los juegos: colores opacos, 2 * texto utf-8, cajas, un lienzo de pixeles en medios bloques, formularios e input. */ 3 #ifndef COMUN_TUIKIT_H 4 #define COMUN_TUIKIT_H 5 #define _XOPEN_SOURCE_EXTENDED 1 6 #include <ncurses.h> 7 #include "gfx.h" 8 #include "form.h" 9 10 /* Colores propios opacos: nunca se usa el fondo de la terminal (transparencias, 11 * temas claros...), asi se lee igual en cualquier lado. */ 12 #define TK_FG 252 13 #define TK_BG 235 14 #define TK_DEF (-1) 15 16 void tk_open(void); 17 void tk_close(void); 18 short tk_xterm(Color c); /* RGB565 -> indice xterm-256 */ 19 void tk_att(short fg, short bg, attr_t a); /* TK_DEF: colores de la interfaz */ 20 void tk_attc(Color fg, Color bg, attr_t a); 21 int tk_put(int y, int x, const char *s, int max); /* hasta max columnas; devuelve columnas */ 22 int tk_ulen(const char *s); 23 void tk_fill(int y, int x, int w, const char *ch); 24 void tk_box(int y, int x, int h, int w, const char *title, Color accent); 25 void tk_section(int y, int x, int w, const char *title); 26 void tk_clear(void); /* borra con el fondo opaco */ 27 28 /* Lienzo de w x h celdas = w x 2h pixeles (cada celda: '▀' con frente arriba y fondo abajo). */ 29 Surface *tk_pix_begin(int w, int h); 30 void tk_pix_blit(int y0, int x0); 31 /* texto sobre el lienzo, en la celda del pixel (px, py) */ 32 void tk_pix_text(int y0, int x0, int px, int py, const char *s, Color fg, Color bg, attr_t a); 33 34 /* Formulario centrado; tk_form_logo (opcional) dibuja el logo arriba. */ 35 extern void (*tk_form_logo)(int cols); 36 void tk_draw_form(const Form *form, HitList *hits); 37 38 /* Espera input (y actividad en fds). 1 = hay evento en ev. */ 39 int tk_wait(int timeout_ms, const int *fds, int nfds, InEvent *ev); 40 41 #endif