Category : Files from Magazines
Archive   : DDJSRC.ZIP
Filename : HELP.C

 
Output of file : HELP.C contained in archive : DDJSRC.ZIP
/* --------- help.c ----------- */

#include
#include
#include
#include
#include "window.h"
#include "menu.h"
#include "entry.h"
#include "help.h"

#define MAXHELPS 25

static struct helps {
char hname [9];
int h, w;
long hptr;
} hps [MAXHELPS+1];

extern FIELD *fld;
extern MENU *mn;

static int hp = 0;
static FILE *helpfp;
static char hline [80];
char *help_window;

/* ----------- load the HELP! definition file ------------ */
void load_help(char *hn)
{
extern void (*helpfunc)(void);
extern int helpkey;
char *cp;

helpfunc = display_help;
helpkey = F1;
hp = 0;
if ((helpfp = fopen(hn, "r")) == NULL)
return;
if ((fgets(hline, 80, helpfp)) == NULL)
return;
while (1) {
if (hp == MAXHELPS)
break;
if (strncmp(hline, "", 5) == 0)
break;
if (*hline != '<')
continue;
hps[hp].h = 2;
hps[hp].w = 23;
strncpy(hps[hp].hname, hline+1, 8);
hps[hp].hname[8] = '\0';
cp = strchr(hps[hp].hname, '>');
if (cp)
*cp = '\0';
hps[hp].hptr = ftell(helpfp);
if (fgets(hline, 80, helpfp) == NULL)
strcpy(hline, "");
while (hline[0] != '<') {
hps[hp].h++;
hps[hp].w = max(hps[hp].w, strlen(hline)+2);
if (fgets(hline, 80, helpfp) == NULL)
strcpy(hline, "");
}
hp++;
}
}

/* ---------- display the current help window ----------- */
void display_help()
{
int hx, hy, i, xx, yy, ch;
extern int helpkey, hsel;
char *save_help;
static int inhelp = 0;
extern struct wn wkw;

if (inhelp)
return;
inhelp++;
save_help = help_window;
if (fld != NULL)
help_window = fld->fhelp;
else if (mn != NULL)
help_window = (mn+hsel-1)->mshelp [wkw.wy-1];
if (help_window != NULL) {
for (ch = 0; ch < hp; ch++)
if (strcmp(help_window, hps[ch].hname) == 0)
break;
if (ch < hp) {
xx = wherex();
yy = wherey();
hidecursor();
hx = ((80-hps[ch].w) / 2)+1;
hy = ((25-hps[ch].h) / 2)+1;
establish_window(hx, hy,
hx+hps[ch].w-1, hy+hps[ch].h,
HELPFG, HELPBG, TRUE);
fseek(helpfp, hps[ch].hptr, 0);
for (i = 0; i < hps[ch].h-2; i++) {
gotoxy(2,2+i);
fgets(hline, 80, helpfp);
cprintf(hline);
}
gotoxy(2,2+i);
cprintf(" [Any key to return]");
hidecursor();
getkey();
delete_window();
if (mn == NULL || fld != NULL) {
textcolor(FIELDFG);
textbackground(FIELDBG);
gotoxy(xx, yy);
}
}
}
help_window = save_help;
--inhelp;
}


  3 Responses to “Category : Files from Magazines
Archive   : DDJSRC.ZIP
Filename : HELP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/