xref: /openbsd-src/games/hunt/hunt/display.c (revision 0f16a76c9ff92a8803c9ee2c38201263b3b08a45)
1 /*	$OpenBSD: display.c,v 1.8 2016/01/07 21:37:53 mestre Exp $	*/
2 
3 /*
4  * Display abstraction.
5  * David Leonard <d@openbsd.org>, 1999. Public domain.
6  */
7 
8 #include <curses.h>
9 
10 void
display_open(void)11 display_open(void)
12 {
13         initscr();
14         (void) noecho();
15         (void) cbreak();
16 }
17 
18 void
display_beep(void)19 display_beep(void)
20 {
21 	beep();
22 }
23 
24 void
display_refresh(void)25 display_refresh(void)
26 {
27 	refresh();
28 }
29 
30 void
display_clear_eol(void)31 display_clear_eol(void)
32 {
33 	clrtoeol();
34 }
35 
36 void
display_put_ch(char c)37 display_put_ch(char c)
38 {
39 	addch(c);
40 }
41 
42 void
display_put_str(char * s)43 display_put_str(char *s)
44 {
45 	addstr(s);
46 }
47 
48 void
display_clear_the_screen(void)49 display_clear_the_screen(void)
50 {
51         clear();
52         move(0, 0);
53         display_refresh();
54 }
55 
56 void
display_move(int y,int x)57 display_move(int y, int x)
58 {
59 	move(y, x);
60 }
61 
62 void
display_getyx(int * yp,int * xp)63 display_getyx(int *yp, int *xp)
64 {
65 	getyx(stdscr, *yp, *xp);
66 }
67 
68 void
display_end(void)69 display_end(void)
70 {
71 	endwin();
72 }
73 
74 char
display_atyx(int y,int x)75 display_atyx(int y, int x)
76 {
77 	int oy, ox;
78 	char c;
79 
80 	display_getyx(&oy, &ox);
81 	c = mvwinch(stdscr, y, x) & 0x7f;
82 	display_move(oy, ox);
83 	return (c);
84 }
85 
86 void
display_redraw_screen(void)87 display_redraw_screen(void)
88 {
89 	clearok(stdscr, TRUE);
90 	touchwin(stdscr);
91 }
92 
93 int
display_iserasechar(char ch)94 display_iserasechar(char ch)
95 {
96 	return ch == erasechar();
97 }
98 
99 int
display_iskillchar(char ch)100 display_iskillchar(char ch)
101 {
102 	return ch == killchar();
103 }
104