1 /* -*- c -*- ------------------------------------------------------------- *
3 * Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
17 char helpbasedir[HELPDIRLEN]; // name of help directory limited to HELPDIRLEN
19 void showhelp(const char *filename)
23 char line[512]; // Max length of a line
28 drawbox(0,0,nr,nc-1,HELPPAGE,0x07,HELPBOX);
30 drawhorizline(2,0,nc-1,HELPPAGE,0x07,HELPBOX,0); // dumb==0
31 if (filename == NULL) { // print file contents
32 gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
33 cswprint("Help system not initialized",0x07,HELP_LEFT_MARGIN);
37 f = fopen(filename,"r");
38 if (!f) { // No such file
39 sprintf(line, "File %s not found",filename);
40 gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
41 cswprint(line,0x07,HELP_LEFT_MARGIN);
45 // Now we have a file just print it.
46 fgets(line,sizeof line,f); // Get first line (TITLE)
47 gotoxy(1,(nc-strlen(line))/2,HELPPAGE);
50 gotoxy(HELP_BODY_ROW,HELP_LEFT_MARGIN,HELPPAGE);
51 while ( fgets(line, sizeof line, f) ) cswprint(line,0x07,HELP_LEFT_MARGIN);
55 void runhelpsystem(unsigned int helpid)
59 char filename[HELPDIRLEN+16];
62 if (dp != HELPPAGE) setdisppage(HELPPAGE);
63 if (helpbasedir[0] != 0) {
64 sprintf(filename,"%s/hlp%05d.txt",helpbasedir,helpid);
70 if (scan == ESCAPE) break;
72 if (dp != HELPPAGE) setdisppage(dp);
75 void init_help(const char *helpdir)
78 strcpy(helpbasedir,helpdir);
79 else helpbasedir[0] = 0;