-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscr.c
145 lines (130 loc) · 2.18 KB
/
scr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Animal - copyright HCR Corporation, Toronto, Canada, 1989
*
* author: Stacey Campbell
*/
#include <curses.h>
#include <string.h>
#include "scr.h"
#define HEAD "Animal"
static WINDOW *Header;
static WINDOW *FileMsg;
static WINDOW *QuestAns;
static WINDOW *QuestAnsBorder;
void
InitCurses(void)
{
initscr();
#ifdef BOGUS_ECHO
echo();
#endif
werase(stdscr);
#ifdef BOGUS_BOX
box(stdscr, '|', '-');
#else
box(stdscr, 0, 0);
#endif
wrefresh(stdscr);
Header = newwin(1, COLS - 2, 1, 1);
wstandout(Header);
mvwaddstr(Header, 0, (COLS - 2) / 2 - sizeof(HEAD) / 2 - 1, HEAD);
wstandend(Header);
wrefresh(Header);
FileMsg = newwin(3, COLS - 2, 2, 1);
#ifdef BOGUS_BOX
box(FileMsg, '|', '-');
#else
box(FileMsg, 0, 0);
#endif
QuestAnsBorder = newwin(LINES - 6, COLS - 2, 5, 1);
#ifdef BOGUS_BOX
box(QuestAnsBorder, '|', '-');
#else
box(QuestAnsBorder, 0, 0);
#endif
QuestAns = newwin(LINES - 8, COLS - 4, 6, 2);
wmove(QuestAns, 0, 0);
scrollok(QuestAns, TRUE);
idlok(QuestAns, TRUE);
wrefresh(FileMsg);
wrefresh(QuestAnsBorder);
wrefresh(QuestAns);
return;
}
char *
FileQuestion(char *prompt)
{
static char answer[256];
werase(FileMsg);
#ifdef BOGUS_BOX
box(FileMsg, '|', '-');
#else
box(FileMsg, 0, 0);
#endif
mvwaddstr(FileMsg, 1, 1, prompt);
waddch(FileMsg, ' ');
#ifdef BOGUS_GET
wrefresh(FileMsg);
#endif
wgetstr(FileMsg, answer);
return answer;
}
void
PutFileMsg(char *str)
{
werase(FileMsg);
#ifdef BOGUS_BOX
box(FileMsg, '|', '-');
#else
box(FileMsg, 0, 0);
#endif
mvwaddstr(FileMsg, 1, 1, str);
wrefresh(FileMsg);
}
void
EndCurses(void)
{
delwin(Header);
delwin(FileMsg);
delwin(QuestAns);
delwin(QuestAnsBorder);
endwin();
}
void
PutQuestion(char *question)
{
wprintw(QuestAns, "%s?", question);
}
void
PutFinalQuestion(char *question)
{
char buf[256];
strcpy(buf, "final guess: is it ");
strcat(buf, question);
PutQuestion(buf);
}
void
PutMsg(char *msg)
{
waddstr(QuestAns, msg);
waddch(QuestAns, '\n');
}
void
GetQuestLine(char *prompt, char *reply)
{
wprintw(QuestAns, "%s ", prompt);
#ifdef BOGUS_GET
wrefresh(QuestAns);
#endif
wgetstr(QuestAns, reply);
}
void
StartBold(void)
{
wstandout(QuestAns);
}
void
EndBold(void)
{
wstandend(QuestAns);
}