home *** CD-ROM | disk | FTP | other *** search
- /* XEdHelp.C File */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <conio.h>
- #include "twindow.h"
- #include "keys.h"
-
-
- extern char path[99];
- extern char msgareasfile[133];
- extern char fileareasfile[133];
- extern char msgareasfilebackup[133];
- extern char fileareasfilebackup[133];
-
-
- extern char * pascal stripcr(char *);
- extern long ftell();
- extern char *fgets();
-
- #define MAXHELPS 100
- #define HBG WHITE
- #define HFG BLACK
- #define HINT DIM
-
- #define TRUE 1
- #define FALSE 0
-
- static struct helps {
- char hname[9];
- int h,w;
- long hptr;
- } hps [MAXHELPS+1];
-
- static int hp=0;
- static int ch=0;
- static int hx,hy;
- FILE *helpfp=NULL;
- void help();
- char helpname[132];
- void pascal getline(char *lineh);
-
- /* Load the HELP! definition file */
-
- void pascal load_help (char *hn) {
-
- extern void (*helpfunc)();
- extern int helpkey;
- char lineh[256];
-
- if (strcmp(helpname,hn)==0)
- return;
- helpfunc=help;
- helpkey=F1;
- hp=0;
- strcpy(helpname,hn);
- if((helpfp=fopen(helpname,"r"))==NULL)
- return;
- getline(lineh);
- while(1) {
- if(hp==MAXHELPS)
- break;
- if (strncmp(lineh,"<end>",5)==0)
- break;
- if (*lineh != '<')
- continue;
- if(!strcmp(lineh,"<defaults!>\n")) {
- getline(lineh);
- stripcr(lineh);
- strncpy(path,lineh,98);
- path[97]=0;
- if(path[strlen(path)-1]!='\\') strcat(path,"\\");
- getline(lineh);
- stripcr(lineh);
- strncpy(msgareasfile,lineh,133);
- msgareasfile[132]=0;
- getline(lineh);
- stripcr(lineh);
- strncpy(msgareasfilebackup,lineh,133);
- msgareasfilebackup[132]=0;
- getline(lineh);
- stripcr(lineh);
- strncpy(fileareasfile,lineh,133);
- fileareasfile[132]=0;
- getline(lineh);
- stripcr(lineh);
- strncpy(fileareasfilebackup,lineh,133);
- fileareasfilebackup[132]=0;
- getline(lineh);
- continue;
- }
- hps[hp].h=3;
- hps[hp].w=18;
- strncpy(hps[hp].hname,lineh+1,8);
- hps[hp].hptr=ftell(helpfp);
- getline(lineh);
- while (*lineh!='<') {
- hps[hp].h++;
- hps[hp].w=max(hps[hp].w,strlen(lineh)+2);
- getline(lineh);
- }
- hp++;
- }
- }
-
- /* Get a line of text from the help file */
-
- static void pascal getline(char *lineh) {
-
- if(fgets(lineh,256,helpfp)==NULL)
- strcpy(lineh,"<end>");
- }
-
- /* Set the current active help screen */
-
- void pascal set_help(char *s,int x,int y) {
-
- for (ch=0;ch<hp;ch++)
- if (strncmp(s,hps[ch].hname,8)==0)
- break;
- hx=x;
- hy=y;
- }
-
- /* Display the current help window */
-
- void help() {
-
- char ln[80];
- int i,xx,yy;
- WINDOW *wnd;
- extern int helpkey;
- extern unsigned char usemouse;
-
- if (hp && ch !=hp) {
- curr_cursor(&xx,&yy);
- cursor(0,25);
- wnd=establish_window(hx,hy,hps[ch].h,hps[ch].w);
- set_title(wnd," Help! ");
- set_colors(wnd,ALL,HBG,HFG,HINT);
- display_window(wnd);
- fseek(helpfp,hps[ch].hptr,0);
- for(i=0;i<hps[ch].h-3;i++) {
- getline(ln);
- wprintf(wnd,ln);
- }
- wprintf(wnd," <<Continue>>");
- while (!kbhit()) {
- if(usemouse) {
-
- union REGS rg;
- int temp=0;
-
- rg.x.ax=5;
- rg.x.bx=0;
- int86(0x33,&rg,&rg);
- temp+=rg.x.bx;
- rg.x.ax=5;
- rg.x.bx=1;
- int86(0x33,&rg,&rg);
- temp+=rg.x.bx;
- rg.x.ax=5;
- rg.x.bx=2;
- int86(0x33,&rg,&rg);
- temp+=rg.x.bx;
- if(temp) break;
- }
- }
- delete_window(wnd);
- cursor(xx,yy);
- }
- }
-