sfeed_curses

[fork] sfeed (atom feed) reader
git clone https://hhvn.uk/sfeed_curses
git clone git://hhvn.uk/sfeed_curses
Log | Files | Refs | README | LICENSE

minicurses.h (1134B)


      1 #include <sys/ioctl.h>
      2 
      3 const char *clr_eol = "\x1b[K";
      4 const char *clear_screen = "\x1b[H\x1b[2J";
      5 const char *cursor_address = "\x1b[%d;%dH";
      6 const char *cursor_normal = "\x1b[?25h"; /* DECTCEM (in)Visible cursor */
      7 const char *cursor_invisible = "\x1b[?25l"; /* DECTCEM (in)Visible cursor */
      8 const char *eat_newline_glitch = (void *)1;
      9 const char *enter_ca_mode = "\x1b[?1049h"; /* smcup */
     10 const char *exit_ca_mode = "\x1b[?1049l"; /* rmcup */
     11 const char *save_cursor = "\x1b""7";
     12 const char *restore_cursor = "\x1b""8";
     13 const char *exit_attribute_mode = "\x1b[0m";
     14 const char *enter_bold_mode = "\x1b[1m";
     15 const char *enter_dim_mode = "\x1b[2m";
     16 const char *enter_reverse_mode = "\x1b[7m";
     17 
     18 int lines = 79;
     19 int columns = 24;
     20 
     21 int
     22 setupterm(char *term, int fildes, int *errret)
     23 {
     24 	struct winsize winsz;
     25 
     26 	if (ioctl(0, TIOCGWINSZ, &winsz) == -1)
     27 		return -1; /* ERR */
     28 	columns = winsz.ws_col;
     29 	lines = winsz.ws_row;
     30 
     31 	return 0; /* OK */
     32 }
     33 
     34 char *
     35 tparm(const char *s, int p1, int p2, ...)
     36 {
     37 	static char buf[32];
     38 
     39 	if (s == cursor_address) {
     40 		snprintf(buf, sizeof(buf), s, p1 + 1, p2 + 1);
     41 		return buf;
     42 	}
     43 
     44 	return (char *)s;
     45 }