27 static int linecount; /* for paging */
29 static int screenheight = 24, screenwidth = 80;
31 static int curses = FALSE;
33 static int curses = TRUE;
36 static void outro(int sig) {
37 /* wrap up, either normally or due to signal */
47 static void fastexit(int sig) {
53 void iostart(int usecurses) {
54 (void) signal(SIGINT, fastexit);
55 (void) signal(SIGINT, fastexit);
57 (void) signal(SIGIOT,fastexit); /* for assert(3) */
59 if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
60 (void)signal(SIGQUIT,fastexit);
63 if (curses = usecurses) {
65 if ((curses = usecurses)) {
75 scrollok(stdscr, TRUE);
76 getmaxyx(stdscr, screenheight, screenwidth);
78 char *LINES = getenv("LINES");
80 screenheight = atoi(LINES);
88 void clearscreen(void) {
89 /* Somehow we need to clear the screen */
91 extern void clrscr(void);
98 // proutn("\033[2J"); /* Hope for an ANSI display */
99 /* much more in that old-TTY spirit to just throw linefeeds */
101 for (i = 0; i < screenheight; i++)
107 void pause_game(int i) {
109 char buf[BUFSIZ], *prompt;
117 prompt = "[ANOUNCEMENT ARRIVING...]";
119 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
123 prompt = "[CONTINUE?]";
125 prompt = "[PRESS ENTER TO CONTINUE]";
130 waddch(stdscr, '\n');
131 waddstr(stdscr, prompt);
132 wgetnstr(stdscr, buf, sizeof(buf));
138 fgets(buf, sizeof(buf), stdin);
160 if (y == screenheight-1)
163 waddch(stdscr, '\n');
166 if (linecount >= screenheight)
172 while (i-- > 0) proutn("\n\r");
175 static void vproutn(char *fmt, va_list ap) {
176 char *strbuf, *p, *s;
177 vasprintf(&strbuf, fmt, ap);
179 if ((curwnd==4)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
180 if (strchr(strbuf,'\n')){
181 p=strchr(strbuf,'\n');
183 cprintf("%s",strbuf);
190 if ((curwnd==4)&&(wherey()>wnds[curwnd].wndbottom-wnds[curwnd].wndtop+1))
193 if (strchr(s,'\n') || strchr(s,'\r')) clreol();
199 void proutn(char *fmt, ...) {
204 vw_printw(stdscr, fmt, ap);
214 void prout(char *fmt, ...) {
219 vw_printw(stdscr, fmt, ap);
230 void proutc(char *line) {
231 line[strlen(line)-1] = '\0';
234 waddstr(stdscr, line);
244 static void prchr(char *s){
251 static void vprouts(char *fmt, va_list ap) {
253 vasprintf(&s, fmt, ap);
262 void prouts(char *fmt, ...) {
265 char *s, buf[BUFSIZ];
269 vsprintf(buf, fmt, ap);
272 for (s = buf; *s; s++) {
273 endTime = clock() + CLOCKS_PER_SEC*0.05;
274 while (clock() < endTime) continue;
293 void getline(char *line, int max) {
295 void cgetline(char *line, int max) {
299 wgetnstr(stdscr, line, max);
304 memmove(line,&line[2],max-3);
307 fgets(line, max, stdin);
308 line[strlen(line)-1] = '\0';
312 void commandhook(char *cmd, int before) {