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);
62 if ((curses = usecurses)) {
71 scrollok(stdscr, TRUE);
72 getmaxyx(stdscr, screenheight, screenwidth);
74 char *LINES = getenv("LINES");
76 screenheight = atoi(LINES);
84 void clearscreen(void) {
85 /* Somehow we need to clear the screen */
87 extern void clrscr(void);
94 // proutn("\033[2J"); /* Hope for an ANSI display */
95 /* much more in that old-TTY spirit to just throw linefeeds */
97 for (i = 0; i < screenheight; i++)
103 void pause_game(int i) {
105 char buf[BUFSIZ], *prompt;
113 prompt = "[ANOUNCEMENT ARRIVING...]";
115 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
119 prompt = "[CONTINUE?]";
121 prompt = "[PRESS ENTER TO CONTINUE]";
126 waddch(stdscr, '\n');
127 waddstr(stdscr, prompt);
128 wgetnstr(stdscr, buf, sizeof(buf));
134 fgets(buf, sizeof(buf), stdin);
156 if (y == screenheight-1)
159 waddch(stdscr, '\n');
162 if (linecount >= screenheight)
168 while (i-- > 0) proutn("\n\r");
171 static void vproutn(char *fmt, va_list ap) {
172 char *strbuf, *p, *s;
173 vasprintf(&strbuf, fmt, ap);
175 if ((curwnd==4)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
176 if (strchr(strbuf,'\n')){
177 p=strchr(strbuf,'\n');
179 cprintf("%s",strbuf);
186 if ((curwnd==4)&&(wherey()>wnds[curwnd].wndbottom-wnds[curwnd].wndtop+1))
189 if (strchr(s,'\n') || strchr(s,'\r')) clreol();
195 void proutn(char *fmt, ...) {
200 vw_printw(stdscr, fmt, ap);
210 void prout(char *fmt, ...) {
215 vw_printw(stdscr, fmt, ap);
226 void proutc(char *line) {
227 line[strlen(line)-1] = '\0';
230 waddstr(stdscr, line);
240 static void prchr(char *s){
247 static void vprouts(char *fmt, va_list ap) {
249 vasprintf(&s, fmt, ap);
258 void prouts(char *fmt, ...) {
261 char *s, buf[BUFSIZ];
265 vsprintf(buf, fmt, ap);
268 for (s = buf; *s; s++) {
269 endTime = clock() + CLOCKS_PER_SEC*0.05;
270 while (clock() < endTime) continue;
289 void getline(char *line, int max) {
291 void cgetline(char *line, int max) {
295 wgetnstr(stdscr, line, max);
300 memmove(line,&line[2],max-3);
303 fgets(line, max, stdin);
304 line[strlen(line)-1] = '\0';
308 void commandhook(char *cmd, int before) {