libvt100

A library for heling in console programming.
git clone git://r-36.net/libvt100
Log | Files | Refs | README | LICENSE

vt100.h (2406B)


      1 /*
      2  * Copy me if you can.
      3  * by 20h
      4  */
      5 
      6 #ifndef __LIBVT100_H__
      7 #define __LIBVT100_H__
      8 
      9 #include <unistd.h>
     10 #include <termios.h>
     11 
     12 typedef struct term_t term_t;
     13 typedef struct termwin_t termwin_t;
     14 struct termwin_t {
     15 	int r, c, rows, cols;
     16 	int dr, dc, drows, dcols;
     17 	int cr, cc;
     18 
     19 	int scrollc1, scrollc2, scroll;
     20 
     21 	term_t *term;
     22 
     23 	termwin_t *next;
     24 	termwin_t *prev;
     25 };
     26 
     27 struct term_t {
     28 	int rows, cols;
     29 
     30 	struct termios tioin, tioout;
     31 
     32 	int n;
     33 	termwin_t *first;
     34 	termwin_t *last;
     35 };
     36 
     37 termwin_t *termwin_new(term_t *term, int r, int c, int rows, int cols);
     38 void termwin_free(term_t *term, termwin_t *win);
     39 
     40 term_t *term_new(void);
     41 void term_free(term_t *term);
     42 
     43 void term_setpos(int row, int col);
     44 void term_up(int rows);
     45 void term_down(int rows);
     46 void term_forward(int cols);
     47 void term_backward(int cols);
     48 void term_erasepos(int row, int col);
     49 void term_eraserow(int row);
     50 void term_erasescreen(void);
     51 void term_backspace(void);
     52 
     53 void term_setscrolling(int start, int end);
     54 void term_scrollup(int times);
     55 void term_scrolldown(int times);
     56 
     57 void term_showcursor(void);
     58 void term_hidecursor(void);
     59 void term_blinkcursor(void);
     60 void term_staticursor(void);
     61 
     62 void term_reset(term_t *term);
     63 void term_init(term_t *term);
     64 
     65 void term_error(term_t *term, char *fmt, ...);
     66 void term_printf(int row, int col, char *fmt, ...);
     67 
     68 void term_drawline(term_t *term, int r0, int c0, int r1, int c1, char sym);
     69 void term_drawrectangle(term_t *term, int r0, int c0, int r1, int c1,
     70 		char hline, char vline, char uredge, char uledge,
     71 		char lredge, char lledge);
     72 void term_fillrectangle(term_t *term, int r0, int c0, int r1, int c1,
     73 		char fill);
     74 
     75 void termwin_setpos(termwin_t *win, int row, int col);
     76 int temwin_inwindow(termwin_t *win, int row, int col);
     77 void termwin_up(termwin_t *win, int rows);
     78 void termwin_down(termwin_t *win, int rows);
     79 void termwin_forward(termwin_t *win, int cols);
     80 void termwin_backward(termwin_t *win, int cols);
     81 void termwin_erasepos(termwin_t *win, int row, int col);
     82 void termwin_eraserow(termwin_t *win, int row);
     83 void termwin_erasewin(termwin_t *win);
     84 void termwin_backspace(termwin_t *win);
     85 
     86 void termwin_setscrolling(termwin_t *win, int start, int end);
     87 void termwin_scrollup(termwin_t *win, int times);
     88 void termwin_scrolldown(termwin_t *win, int times);
     89 
     90 void termwin_error(termwin_t *win, char *fmt, ...);
     91 void termwin_printf(termwin_t *win, int row, int col, char *fmt, ...);
     92 
     93 #endif
     94