home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XDEV_117.ZIP / XEDHELP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-10  |  3.3 KB  |  176 lines

  1. /* XEdHelp.C File */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <dos.h>
  7. #include <conio.h>
  8. #include "twindow.h"
  9. #include "keys.h"
  10.  
  11.  
  12. extern char path[99];
  13. extern char msgareasfile[133];
  14. extern char fileareasfile[133];
  15. extern char msgareasfilebackup[133];
  16. extern char fileareasfilebackup[133];
  17.  
  18.  
  19. extern char * pascal stripcr(char *);
  20. extern long ftell();
  21. extern char *fgets();
  22.  
  23. #define MAXHELPS 100
  24. #define HBG WHITE
  25. #define HFG BLACK
  26. #define HINT DIM
  27.  
  28. #define TRUE  1
  29. #define FALSE 0
  30.  
  31. static struct helps {
  32.   char hname[9];
  33.   int h,w;
  34.   long hptr;
  35. } hps [MAXHELPS+1];
  36.  
  37. static int hp=0;
  38. static int ch=0;
  39. static int hx,hy;
  40. FILE *helpfp=NULL;
  41. void help();
  42. char helpname[132];
  43. void pascal getline(char *lineh);
  44.  
  45. /* Load the HELP! definition file */
  46.  
  47. void pascal load_help (char *hn) {
  48.  
  49.   extern void (*helpfunc)();
  50.   extern int helpkey;
  51.   char lineh[256];
  52.  
  53.   if (strcmp(helpname,hn)==0)
  54.     return;
  55.   helpfunc=help;
  56.   helpkey=F1;
  57.   hp=0;
  58.   strcpy(helpname,hn);
  59.   if((helpfp=fopen(helpname,"r"))==NULL)
  60.     return;
  61.   getline(lineh);
  62.   while(1) {
  63.     if(hp==MAXHELPS)
  64.       break;
  65.     if (strncmp(lineh,"<end>",5)==0)
  66.       break;
  67.     if (*lineh != '<')
  68.       continue;
  69.     if(!strcmp(lineh,"<defaults!>\n")) {
  70.         getline(lineh);
  71.         stripcr(lineh);
  72.         strncpy(path,lineh,98);
  73.         path[97]=0;
  74.         if(path[strlen(path)-1]!='\\') strcat(path,"\\");
  75.         getline(lineh);
  76.         stripcr(lineh);
  77.         strncpy(msgareasfile,lineh,133);
  78.         msgareasfile[132]=0;
  79.         getline(lineh);
  80.         stripcr(lineh);
  81.         strncpy(msgareasfilebackup,lineh,133);
  82.         msgareasfilebackup[132]=0;
  83.         getline(lineh);
  84.         stripcr(lineh);
  85.         strncpy(fileareasfile,lineh,133);
  86.         fileareasfile[132]=0;
  87.         getline(lineh);
  88.         stripcr(lineh);
  89.         strncpy(fileareasfilebackup,lineh,133);
  90.         fileareasfilebackup[132]=0;
  91.         getline(lineh);
  92.         continue;
  93.     }
  94.     hps[hp].h=3;
  95.     hps[hp].w=18;
  96.     strncpy(hps[hp].hname,lineh+1,8);
  97.     hps[hp].hptr=ftell(helpfp);
  98.     getline(lineh);
  99.     while (*lineh!='<') {
  100.       hps[hp].h++;
  101.       hps[hp].w=max(hps[hp].w,strlen(lineh)+2);
  102.       getline(lineh);
  103.     }
  104.     hp++;
  105.   }
  106. }
  107.  
  108. /* Get a line of text from the help file */
  109.  
  110. static void pascal getline(char *lineh) {
  111.  
  112.   if(fgets(lineh,256,helpfp)==NULL)
  113.     strcpy(lineh,"<end>");
  114. }
  115.  
  116. /* Set the current active help screen */
  117.  
  118. void pascal set_help(char *s,int x,int y) {
  119.  
  120.   for (ch=0;ch<hp;ch++)
  121.     if (strncmp(s,hps[ch].hname,8)==0)
  122.       break;
  123.   hx=x;
  124.   hy=y;
  125. }
  126.  
  127. /* Display the current help window */
  128.  
  129. void help() {
  130.  
  131.   char ln[80];
  132.   int i,xx,yy;
  133.   WINDOW *wnd;
  134.   extern int helpkey;
  135.   extern unsigned char usemouse;
  136.  
  137.   if (hp && ch !=hp) {
  138.     curr_cursor(&xx,&yy);
  139.     cursor(0,25);
  140.     wnd=establish_window(hx,hy,hps[ch].h,hps[ch].w);
  141.     set_title(wnd," Help! ");
  142.     set_colors(wnd,ALL,HBG,HFG,HINT);
  143.     display_window(wnd);
  144.     fseek(helpfp,hps[ch].hptr,0);
  145.     for(i=0;i<hps[ch].h-3;i++) {
  146.       getline(ln);
  147.       wprintf(wnd,ln);
  148.     }
  149.     wprintf(wnd," <<Continue>>");
  150.     while (!kbhit()) {
  151.         if(usemouse) {
  152.  
  153.             union REGS rg;
  154.             int temp=0;
  155.  
  156.             rg.x.ax=5;
  157.             rg.x.bx=0;
  158.             int86(0x33,&rg,&rg);
  159.             temp+=rg.x.bx;
  160.             rg.x.ax=5;
  161.             rg.x.bx=1;
  162.             int86(0x33,&rg,&rg);
  163.             temp+=rg.x.bx;
  164.             rg.x.ax=5;
  165.             rg.x.bx=2;
  166.             int86(0x33,&rg,&rg);
  167.             temp+=rg.x.bx;
  168.             if(temp) break;
  169.         }
  170.     }
  171.     delete_window(wnd);
  172.     cursor(xx,yy);
  173.   }
  174. }
  175.  
  176.