move to debhelper compat 13, hopefully fixes cross-building
[debian/cpmtools] / term_curses.c
1 /* #includes */ /*{{{C}}}*//*{{{*/
2 #include "config.h"
3
4 #include <assert.h>
5 #include <ctype.h>
6 #ifdef NEED_NCURSES
7 #ifdef HAVE_NCURSES_NCURSES_H
8 #include <ncurses/ncurses.h>
9 #else
10 #include <ncurses.h>
11 #endif
12 #else
13 #include <curses.h>
14 #endif
15 #include <errno.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <string.h>
19
20 #include "term.h"
21 /*}}}*/
22
23 void term_init(void) /*{{{*/
24 {
25   initscr();
26   noecho();
27   raw();
28   nonl();
29   idlok(stdscr,TRUE);
30   idcok(stdscr,TRUE);
31   keypad(stdscr,TRUE);
32   clear();
33 }
34 /*}}}*/
35 void term_exit(void) /*{{{*/
36 {
37   move(LINES-1,0);
38   refresh();
39   echo();
40   noraw();
41   endwin();
42 }
43 /*}}}*/
44 void term_clear(void) /*{{{*/
45 {
46   clear();
47 }
48 /*}}}*/
49 void term_xy(int x, int y) /*{{{*/
50 {
51   move(y,x);
52 }
53 /*}}}*/
54 void term_printf(char const *fmt, ...) /*{{{*/
55 {
56   va_list ap;
57
58   va_start(ap, fmt);
59   vw_printw(stdscr, fmt, ap);
60   va_end(ap);
61 }
62 /*}}}*/
63 void term_putch(char ch) /*{{{*/
64 {
65   addch(ch);
66 }
67 /*}}}*/
68 int term_getch(void) /*{{{*/
69 {
70   return getch();
71 }
72 /*}}}*/
73 void term_reverse(int on) /*{{{*/
74 {
75   if (on) attron(A_REVERSE);
76   else attroff(A_REVERSE);
77 }
78 /*}}}*/
79 int term_lines(void) /*{{{*/
80 {
81   return LINES;
82 }
83 /*}}}*/
84 int term_cols(void) /*{{{*/
85 {
86   return COLS;
87 }
88 /*}}}*/