1 /* vi: set tabstop=4 : */ 2 3 #include <curses.h> 4 #include <stdio.h> 5 6 #include "bog.h" 7 8 help() 9 { 10 int eof, i; 11 FILE *fp; 12 WINDOW *win; 13 char buf[BUFSIZ]; 14 extern int ncols, nlines; 15 16 if ((fp = fopen(HELPFILE, "r")) == (FILE *) NULL) 17 return(-1); 18 win = newwin(0, 0, 0, 0); 19 clearok(win, 1); 20 21 eof = 0; 22 if (ungetc(getc(fp), fp) == EOF) { 23 wprintw(win, "There doesn't seem to be any help."); 24 eof = 1; /* Nothing there... */ 25 } 26 27 while (!eof) { 28 for (i = 0; i < nlines - 3; i++) { 29 if (fgets(buf, sizeof(buf), fp) == (char *) NULL) { 30 eof = 1; 31 break; 32 } 33 if (buf[0] == '.' && buf[1] == '\n') 34 break; 35 wprintw(win, "%s", buf); 36 } 37 if (eof || ungetc(getc(fp), fp) == EOF) { 38 eof = 1; 39 break; 40 } 41 wmove(win, nlines - 1, 0); 42 wprintw(win, "Type <space> to continue, anything else to quit..."); 43 wrefresh(win); 44 if ((inputch() & 0177) != ' ') 45 break; 46 wclear(win); 47 } 48 49 fclose(fp); 50 if (eof) { 51 extern char *version; 52 53 wprintw(win, "%s", version); 54 wmove(win, nlines - 1, 0); 55 wprintw(win, "Hit any key to continue..."); 56 wrefresh(win); 57 inputch(); 58 } 59 delwin(win); 60 clearok(stdscr, 1); 61 refresh(); 62 return(0); 63 } 64 65