Changeset 06929a in git for Singular


Ignore:
Timestamp:
Apr 22, 2003, 7:19:49 PM (21 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c5facdfddea2addfd91babd8b9019161dea4b695')
Children:
fd7acf827c4e50c346b4d461584b5e601fdf170f
Parents:
1bc15419b6d0aab65be2263582c648990bbcdb58
Message:
*hannes: help.cnf


git-svn-id: file:///usr/local/Singular/svn/trunk@6687 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/fehelp.cc

    r1bc154 r06929a  
    3939typedef  heEntry_s * heEntry;
    4040
    41 typedef void (*heBrowserHelpProc)(heEntry hentry);
    42 typedef BOOLEAN (*heBrowserInitProc)(int warn);
     41typedef void (*heBrowserHelpProc)(heEntry hentry, int br);
     42typedef BOOLEAN (*heBrowserInitProc)(int warn, int br);
    4343
    4444typedef struct
     
    4747  heBrowserInitProc init_proc;
    4848  heBrowserHelpProc help_proc;
     49  char* required;
     50  char* action;
    4951} heBrowser_s;
    5052typedef heBrowser_s * heBrowser;
     
    6466
    6567// browser functions
    66 static BOOLEAN heInfoInit(int);    static void heInfoHelp(heEntry hentry);
    67 #if ! defined(macintosh)
    68 static BOOLEAN heNetscapeInit(int);static void heNetscapeHelp(heEntry hentry);
    69 static BOOLEAN heXinfoInit(int);   static void heXinfoHelp(heEntry hentry);
    70 static BOOLEAN heTkinfoInit(int);  static void heTkinfoHelp(heEntry hentry);
    71 #endif
    72 static BOOLEAN heBuiltinInit(int); static void heBuiltinHelp(heEntry hentry);
    73 static BOOLEAN heDummyInit(int);   static void heDummyHelp(heEntry hentry);
    74 static BOOLEAN heEmacsInit(int);   static void heEmacsHelp(heEntry hentry);
     68static BOOLEAN heGenInit(int,int);    static void heGenHelp(heEntry hentry,int);
     69                                      static void heBuiltinHelp(heEntry hentry,int);
     70static BOOLEAN heDummyInit(int,int);   static void heDummyHelp(heEntry hentry,int);
     71static BOOLEAN heEmacsInit(int,int);   static void heEmacsHelp(heEntry hentry,int);
    7572
    7673#ifdef ix86_Win
    77 static void heHtmlHelp(heEntry hentry);
    78 static void heWinHelp(heEntry hentry);
     74static void heHtmlHelp(heEntry hentry,int);
     75static void heWinHelp(heEntry hentry,int);
    7976#include "sing_win.h"
    8077#endif
    8178
    8279static heBrowser heCurrentHelpBrowser = NULL;
     80static int heCurrentHelpBrowserIndex= -1;
    8381
    8482
     
    8987 *****************************************************************/
    9088// order is improtant -- first possible help is choosen
     89#if 1
     90static heBrowser_s *heHelpBrowsers=NULL;
     91#else
    9192static heBrowser_s heHelpBrowsers[] =
    9293{
    9394#ifdef ix86_Win
    94   { "html",     heDummyInit,    heHtmlHelp},
    95   { "winhlp",   heDummyInit,    heWinHelp},
     95//  { "html",     heDummyInit,    heHtmlHelp, NULL, NULL},
     96//  { "winhlp",   heDummyInit,    heWinHelp, NULL, NULL},
    9697#endif
    97 #if ! defined(macintosh)
    98   { "netscape", heNetscapeInit, heNetscapeHelp},
    99   { "tkinfo",   heTkinfoInit,   heTkinfoHelp},
    100   { "xinfo",    heXinfoInit,    heXinfoHelp},
     98  { "mozilla",  heGenInit,      heGenHelp, "xDhE:mozilla:", "(mozilla -remote \"openURL(%h)\")||(mozilla %h)"},
     99  { "netscape", heGenInit,      heGenHelp, "xDhE:netscape:", "(netscape -remote \"openURL(%h)\")||(netscape %h)"},
     100  { "tkinfo",   heGenInit,      heGenHelp, "xDiE:tkinfo:", "tkinfo '(%i)%n' &"},
     101  { "xinfo",    heGenInit,      heGenHelp, "xDiE:xterm:E:info:", "xterm -e info -f %i --node='%n' &"},
     102  { "mac",      heGenInit,      heGenHelp,  "xhE:open:","open %h" },
     103  { "machtml",  heGenInit,      heGenHelp,  "xE:open:","open %H" },
     104  { "info",     heGenInit,      heGenHelp, "xiE:info:", "info -f %i --node='%n' &"},
     105  { "builtin",  heGenInit,      heBuiltinHelp, "i", NULL},
     106  { "dummy",    heDummyInit,    heDummyHelp, NULL, NULL},
     107  { "emacs",    heEmacsInit,    heEmacsHelp, NULL, NULL},
     108  { NULL, NULL, NULL, NULL, NULL} // must be the last record
     109};
    101110#endif
    102   { "info",     heInfoInit,     heInfoHelp},
    103   { "builtin",  heBuiltinInit,  heBuiltinHelp},
    104   { "dummy",    heDummyInit,    heDummyHelp},
    105   { "emacs",    heEmacsInit,    heEmacsHelp},
    106   { NULL, NULL, NULL} // must be the last record
    107 };
    108111
    109112/*****************************************************************
     
    117120  if (str == NULL) {heBrowserHelp(NULL); return;}
    118121
    119   BOOLEAN key_is_regexp = (strchr(str, '*') != NULL);
    120 #ifdef HAVE_NS
    121   if (!key_is_regexp)
    122   {
    123     // test for help mod::p;
    124     char *cc=strstr(str,"::");
    125     if ((cc!=NULL) && (cc!=str))
    126     {
    127       char *cc=strstr(str,"::");
    128       *cc='\0';
    129       cc+=2;
    130       idhdl pack=basePack->idroot->get(str,0);
    131       if (IDTYP(pack)==PACKAGE_CMD)
    132       {
    133         package save=currPack;
    134         currPack=IDPACKAGE(pack);
    135         BOOLEAN r=heOnlineHelp(cc);
    136         currPack=save;
    137         if (r) return;
    138         else
    139         {
    140           cc-=2; *cc=':';
    141         }
    142       }
    143     }
    144   }
    145 #endif
    146122  if (strlen(str) > MAX_HE_ENTRY_LENGTH - 2)  // need room for extra **
    147123    str[MAX_HE_ENTRY_LENGTH - 3] = '\0';
    148124
     125  BOOLEAN key_is_regexp = (strchr(str, '*') != NULL);
    149126  heEntry_s hentry;
    150127  char* idxfile = feResource('x' /*"IdxFile"*/);
     
    216193  heBrowserHelp(&hentry);
    217194}
     195static void feBrowserFile()
     196{
     197  FILE *f=feFopen("help.cnf","r",NULL,TRUE);
     198  int br=0;
     199  if (f!=NULL)
     200  {
     201    char buf[512];
     202    while (fgets( buf, sizeof(buf), f))
     203    {
     204      if ((buf[0]!='#') && (buf[0]>' ')) br++;
     205    }
     206    fseek(f,0,SEEK_SET);
     207    // for the 4(!) default browsers
     208    heHelpBrowsers=(heBrowser_s*)omAlloc0((br+4)*sizeof(heBrowser_s));
     209    br=0;
     210    while (fgets( buf, sizeof(buf), f))
     211    {
     212      if ((buf[0]!='#') && (buf[0]>' '))
     213      {
     214        char *name=strtok(buf,"!");
     215        char *req=strtok(NULL,"!");
     216        char *cmd=strtok(NULL,"!");
     217        while ((cmd[0]!='\0') && (cmd[strlen(cmd)-1]<=' '))
     218          cmd[strlen(cmd)-1]='\0';
     219        //Print("name %d >>%s<<\n\treq:>>%s<<\n\tcmd:>>%s<<\n",br,name,req,cmd);
     220        heHelpBrowsers[br].browser=(char *)omStrDup(name);
     221        heHelpBrowsers[br].init_proc=heGenInit;
     222        heHelpBrowsers[br].help_proc=heGenHelp;
     223        heHelpBrowsers[br].required=omStrDup(req);
     224        heHelpBrowsers[br].action=omStrDup(cmd);
     225        br++;
     226      }
     227    }
     228    fclose(f);
     229  }
     230  else
     231  {
     232    // for the 4(!) default browsers
     233    heHelpBrowsers=(heBrowser_s*)omAlloc0(4*sizeof(heBrowser_s));
     234  }
     235  heHelpBrowsers[br].browser="builtin";
     236  heHelpBrowsers[br].init_proc=heGenInit;
     237  heHelpBrowsers[br].help_proc=heBuiltinHelp;
     238  heHelpBrowsers[br].required="i";
     239  //heHelpBrowsers[br].action=NULL;
     240  br++;
     241  heHelpBrowsers[br].browser="dummy";
     242  heHelpBrowsers[br].init_proc=heDummyInit;
     243  heHelpBrowsers[br].help_proc=heDummyHelp;
     244  //heHelpBrowsers[br].required=NULL;
     245  //heHelpBrowsers[br].action=NULL;
     246  br++;
     247  heHelpBrowsers[br].browser="emacs";
     248  heHelpBrowsers[br].init_proc=heEmacsInit;
     249  heHelpBrowsers[br].help_proc=heEmacsHelp;
     250  //heHelpBrowsers[br].required=NULL;
     251  //heHelpBrowsers[br].action=NULL;
     252  //br++;
     253  //heHelpBrowsers[br].browser=NULL;
     254  //heHelpBrowsers[br].init_proc=NULL;
     255  //heHelpBrowsers[br].help_proc=NULL;
     256  //heHelpBrowsers[br].required=NULL;
     257  //heHelpBrowsers[br].action=NULL;
     258}
    218259
    219260char* feHelpBrowser(char* which, int warn)
     
    222263
    223264  // if no argument, choose first available help browser
     265  if (heHelpBrowsers==NULL) feBrowserFile();
    224266  if (which == NULL || *which == '\0')
    225267  {
     
    236278      {
    237279        if (strcmp(heHelpBrowsers[i].browser, "emacs") == 0 &&
    238             (heHelpBrowsers[i].init_proc(0)))
     280            (heHelpBrowsers[i].init_proc(0,i)))
    239281        {
    240282          heCurrentHelpBrowser = &(heHelpBrowsers[i]);
     283          heCurrentHelpBrowserIndex=i;
    241284          goto Finish;
    242285        }
     
    248291    while (heHelpBrowsers[i].browser != NULL)
    249292    {
    250       if (heHelpBrowsers[i].init_proc(0))
     293      if (heHelpBrowsers[i].init_proc(0,i))
    251294      {
    252295        heCurrentHelpBrowser = &(heHelpBrowsers[i]);
     296        heCurrentHelpBrowserIndex=i;
    253297        goto Finish;
    254298      }
     
    271315  {
    272316    // see whether we can init it
    273     if (heHelpBrowsers[i].init_proc(warn))
     317    if (heHelpBrowsers[i].init_proc(warn,i))
    274318    {
    275319      heCurrentHelpBrowser = &(heHelpBrowsers[i]);
     320      heCurrentHelpBrowserIndex=i;
    276321      goto Finish;
    277322    }
     
    301346             heCurrentHelpBrowser->browser) != 0)
    302347  {
    303       omfree(feOptSpec[FE_OPT_BROWSER].value);
    304    feOptSpec[FE_OPT_BROWSER].value
     348    omfree(feOptSpec[FE_OPT_BROWSER].value);
     349    feOptSpec[FE_OPT_BROWSER].value
    305350     = (void*) omStrDup(heCurrentHelpBrowser->browser);
    306351  }
     
    314359
    315360  i = 0;
     361  if (heHelpBrowsers==NULL) feBrowserFile();
    316362  while (heHelpBrowsers[i].browser != NULL)
    317363  {
    318     if (heHelpBrowsers[i].init_proc(warn))
     364    if (heHelpBrowsers[i].init_proc(warn,i))
    319365      StringAppend("%s, ", heHelpBrowsers[i].browser);
    320366    i++;
     
    569615static BOOLEAN heOnlineHelp(char* s)
    570616{
    571   idhdl h=IDROOT->get(s,myynest);
     617#ifdef HAVE_NAMESPACES
     618  idhdl h, ns;
     619  iiname2hdl(s, &ns, &h);
     620#else /* HAVE_NAMESPACES */
     621  idhdl h=idroot->get(s,myynest);
     622#endif /* HAVE_NAMESPACES */
    572623
    573624  // try help for a procedure
    574625  if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
    575626  {
    576     procinfo *p=IDPROC(h);
    577 #ifdef HAVE_NS
    578     if (p->language==LANG_SINGULAR)
    579 #endif
    580     {
    581       char *lib=iiGetLibName(p /*IDPROC(h)*/);
    582       if((lib!=NULL)&&(*lib!='\0'))
    583       {
    584         Print("// proc %s from lib %s\n",s,lib);
    585         s=iiGetLibProcBuffer(p /*IDPROC(h)*/, 0);
    586         if (s!=NULL)
    587         {
    588           PrintS(s);
    589           omFree((ADDRESS)s);
    590         }
    591         return TRUE;
    592      }
    593     }
    594 #ifdef HAVE_NS
    595     else if (p->language==LANG_C)
    596     {
    597       Print("// c-proc %s\n",s);
     627    char *lib=iiGetLibName(IDPROC(h));
     628    if((lib!=NULL)&&(*lib!='\0'))
     629    {
     630      Print("// proc %s from lib %s\n",s,lib);
     631      s=iiGetLibProcBuffer(IDPROC(h), 0);
     632      if (s!=NULL)
     633      {
     634        PrintS(s);
     635        omFree((ADDRESS)s);
     636      }
    598637      return TRUE;
    599638    }
    600 #endif
    601639    return FALSE;
    602640  }
     
    632670
    633671    yylpin = fp;
    634 #ifdef HAVE_NS
     672#ifdef HAVE_NAMESPACES
    635673    yylplex(str, libnamebuf, &lib_style, IDROOT, FALSE, GET_INFO);
    636 #else /* HAVE_NS */
     674#else /* HAVE_NAMESPACES */
    637675    yylplex(str, libnamebuf, &lib_style, GET_INFO);
    638 #endif /* HAVE_NS */
     676#endif /* HAVE_NAMESPACES */
    639677    reinit_yylp();
    640678    if(lib_style == OLD_LIBSTYLE)
     
    682720{
    683721  if (key == NULL || *key == '\0') return 0;
    684   idhdl h=IDROOT->get(key,myynest);
     722#ifdef HAVE_NAMESPACES
     723  idhdl h, ns;
     724  iiname2hdl(key, &ns, &h);
     725#else /* HAVE_NAMESPACES */
     726  idhdl h=idroot->get(key,myynest);
     727#endif /* HAVE_NAMESPACES */
    685728  if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
    686729  {
     
    723766    while (heHelpBrowsers[i].browser != NULL)
    724767    {
    725       if (heHelpBrowsers[i].init_proc(0))
     768      if (heHelpBrowsers[i].init_proc(0,i))
    726769        StringAppend("\"%s\", ", heHelpBrowsers[i].browser);
    727770      i++;
     
    735778  }
    736779
    737   heCurrentHelpBrowser->help_proc(hentry);
     780  heCurrentHelpBrowser->help_proc(hentry, heCurrentHelpBrowserIndex);
    738781  feHelpCalled = TRUE;
    739782}
    740783
    741784#define MAX_SYSCMD_LEN MAXPATHLEN*2
    742 // browser functions
    743 static BOOLEAN heInfoInit(int warn)
    744 {
    745   if (feResource('i', warn) == NULL)
    746   {
    747     if (warn) WarnS("'info' help browser not available: no InfoFile");
    748     return FALSE;
    749   }
    750   if (feResource('I') == NULL)
    751   {
    752     if (warn)
    753       WarnS("'info' help browser not available: no 'info' program found");
    754     return FALSE;
     785static BOOLEAN heGenInit(int warn, int br)
     786{
     787  if (heHelpBrowsers[br].required==NULL) return TRUE;
     788  char *p=heHelpBrowsers[br].required;
     789  while (*p>'\0')
     790  {
     791    switch (*p)
     792    {
     793      case '#': break;
     794      case ' ': break;
     795      case 'i': /* singular.hlp */
     796      case 'x': /* singular.idx */
     797      case 'h': /* html dir */
     798               if (feResource(*p, warn) == NULL)
     799               {
     800                 if (warn) Warn("ressource `%c` not found",*p);
     801                 return FALSE;
     802               }
     803               break;
     804      case 'D': /* DISPLAY */
     805               if (getenv("DISPLAY") == NULL)
     806               {
     807                 if (warn) WarnS("ressource `D` not found");
     808                 return FALSE;
     809               }
     810               break;
     811      case 'E': /* executable: E:xterm: */
     812               {
     813                 char name[128];
     814                 char exec[128];
     815                 memset(name,0,128);
     816                 int i=0;
     817                 p++;
     818                 while (((*p==':')||(*p<=' ')) && (*p!='\0')) p++;
     819                 while((i<127) && (*p>' ') && (*p!=':'))
     820                 {
     821                   name[i]=*p; p++; i++;
     822                 }
     823                 if (i==0) return FALSE;
     824                 if (omFindExec(name,exec)==NULL)
     825                 {
     826                   if (warn) Warn("executable `%s` not found",name);
     827                   return FALSE;
     828                 }
     829               }
     830               break;
     831      default: Warn("unknown char %c",*p);
     832               break;
     833    }
     834    p++;
    755835  }
    756836  return TRUE;
    757837}
    758 static void heInfoHelp(heEntry hentry)
    759 {
    760   char sys[MAX_SYSCMD_LEN];
    761 
    762   if (hentry != NULL && *(hentry->key) != '\0')
    763   {
    764     if (*(hentry->node) != '\0')
    765       sprintf(sys, "%s -f %s --node='%s'",
    766               feResource('I'), feResource('i'), hentry->node);
    767     else
    768       sprintf(sys, "%s -f %s Index '%s'",
    769               feResource('I'), feResource('i'), hentry->key);
    770   }
    771   else
    772     sprintf(sys, "%s -f %s --node=Top", feResource('I'), feResource('i'));
    773   system(sys);
    774 }
    775 
    776 #if ! defined(macintosh)
    777 static BOOLEAN heNetscapeInit(int warn)
    778 {
    779   if (feResource('N' /*"netscape"*/, warn) == NULL)
    780   {
    781     if (warn) WarnS("'netscape' help browser not available: no 'netscape' program found");
    782     return FALSE;
    783   }
    784 #ifndef ix86_Win
    785   if (getenv("DISPLAY") == NULL)
    786   {
    787     if (warn) WarnS("'netscape' help browser not available:");
    788     if (warn) WarnS("Environment variable DISPLAY not set");
    789     return FALSE;
    790   }
    791 #endif
    792 
    793   if (feResource('h' /*"HtmlDir"*/, (feOptValue(FE_OPT_ALLOW_NET)? 0 : warn))
    794       == NULL)
    795   {
    796     if (warn) WarnS("No local HtmlDir found.");
    797     if (feOptValue(FE_OPT_ALLOW_NET))
    798     {
    799       if (warn) Warn("Using URL '%s' instead.", feResource('u' /*"ManualUrl"*/, warn));
    800     }
    801     else
    802       return FALSE;
    803   }
    804   return TRUE;
    805 }
    806 
    807 static void heNetscapeHelp(heEntry hentry)
     838
     839static void heGenHelp(heEntry hentry, int br)
    808840{
    809841  char sys[MAX_SYSCMD_LEN];
    810842  char url[MAXPATHLEN];
    811   char* htmldir = feResource('h' /*"HtmlDir"*/);
    812   char* urltype;
    813 
    814   if (htmldir == NULL)
    815   {
    816     urltype = "";
    817     htmldir = feResource('u' /*"ManualUrl"*/);
    818   }
    819   else
    820   {
    821     urltype = "file:";
    822   }
    823 
    824   if (hentry != NULL && *(hentry->url) != '\0')
    825   {
    826     sprintf(url, "%s%s/%s", urltype, htmldir, hentry->url);
    827   }
    828   else
    829   {
    830     sprintf(url, "%s%s/index.htm", urltype, htmldir);
    831   }
    832 #ifndef ix86_Win
    833   sprintf(sys, "%s --remote 'OpenUrl(%s)' > /dev/null 2>&1",
    834 #else
    835   sprintf(sys, "%s %s",
    836 #endif
    837           feResource('N' /*"netscape"*/), url);
    838 
    839   // --remote exits with status != 0 if netscaep isn't already running
    840   if (system(sys) != 0)
    841   {
    842     sprintf(sys, "%s %s &", feResource('N' /*"netscape"*/), url);
    843     system(sys);
    844   }
    845   else
    846   {
    847     if (! feHelpCalled)
    848     {
    849       Warn("Help is displayed in already running 'netscape'.");
    850     }
    851   }
     843  char *p=heHelpBrowsers[br].action;
     844  if (p==NULL) {PrintS("no action ?\n"); return;}
     845  memset(sys,0,MAX_SYSCMD_LEN);
     846  int i=0;
     847  while ((*p>'\0')&& (i<MAX_SYSCMD_LEN))
     848  {
     849    if ((*p)=='%')
     850    {
     851      p++;
     852      switch (*p)
     853      {
     854        case 'f': /* local html:file */
     855        case 'h': /* local html:URL */
     856        case 'H': /* www html */
     857                 {
     858                   char temp[256];
     859                   char *htmldir = feResource('h' /*"HtmlDir"*/);
     860                   if ((*p=='h')&&(htmldir!=NULL))
     861                     strcat(sys,"file://localhost");
     862                   else if ((*p=='H')||(htmldir==NULL))
     863                     htmldir = feResource('u' /* %H -> "ManualUrl"*/);
     864                     /* always defined */
     865                   if (hentry != NULL && *(hentry->url) != '\0')
     866                   #ifdef HAVE_VSNPRINTF
     867                     snprintf(temp,256,"%s/%s", htmldir, hentry->url);
     868                   else
     869                     snprintf(temp,256,"%s/index.htm", htmldir);
     870                   #else
     871                     sprintf(temp,"%s/%s", htmldir, hentry->url);
     872                   else
     873                     sprintf(temp,"%s/index.htm", htmldir);
     874                   #endif
     875                   strcat(sys,temp);
     876                   if ((*p)=='f')
     877                   { // remove #SEC
     878                     char *pp=strchr(sys,'#');
     879                     if (pp!=NULL)
     880                     {
     881                       *pp='\0';
     882                       i=strlen(sys);
     883                       memset(pp,0,MAX_SYSCMD_LEN-i);
     884                     } 
     885                   }
     886                   i=strlen(sys);
     887                   break;
     888                 }
     889        case 'i': /* singular.hlp */
     890                 {
     891                   char *i_res=feResource('i');
     892                   if (i_res!=NULL) strcat(sys,i_res);
     893                   else
     894                   {
     895                     WarnS("singular.hlp not found");
     896                     return;
     897                   }
     898                   i=strlen(sys);
     899                   break;
     900                 }
     901        case 'n': /* info node */
     902                 {
     903                   char temp[256];
     904                   if ((hentry!=NULL) && (*(hentry->node) != '\0'))
     905                     sprintf(temp,"%s",hentry->node);
     906                   //else if ((hentry!=NULL) && (hentry->key!=NULL))
     907                   //  sprintf(temp,"Index '%s'",hentry->key);
     908                   else
     909                     sprintf(temp,"Top");
     910                   strcat(sys,temp);
     911                   i=strlen(sys);
     912                   break;
     913                 }
     914        default: break;
     915      }
     916      p++;
     917    }
     918    else
     919    {
     920      sys[i]=*p;
     921      p++;i++;
     922    }
     923  }
     924  Print("running `%s`\n",sys);
     925  system(sys);
    852926}
    853927
     
    884958#endif
    885959
    886 static BOOLEAN heXinfoInit(int warn)
    887 {
    888 #ifndef ix86_Win
    889   if (getenv("DISPLAY") == NULL)
    890   {
    891     if (warn) WarnS("'xinfo' help browser not available:");
    892     if (warn) WarnS("Environment variable DISPLAY not set");
    893     return FALSE;
    894   }
    895 #endif
    896   if (feResource('i', warn) == NULL)
    897   {
    898     if (warn) WarnS("'xinfo' help browser not available: no InfoFile");
    899     return FALSE;
    900   }
    901   if (feResource('I', warn) == NULL)
    902   {
    903     if (warn) WarnS("'xinfo' help browser not available: no 'info' program found");
    904     return FALSE;
    905   }
    906   if (feResource('X', warn) == NULL)
    907   {
    908     if (warn) WarnS("'xinfo' help browser not available: no 'xterm' program found");
    909     return FALSE;
    910   }
     960static BOOLEAN heDummyInit(int warn, int br)
     961{
    911962  return TRUE;
    912963}
    913 static void heXinfoHelp(heEntry hentry)
    914 {
    915   char sys[MAX_SYSCMD_LEN];
    916 
    917 #ifdef ix86_Win
    918 #define EXTRA_XTERM_ARGS "+vb -sb -fb Courier-bold-12 -tn linux -cr Red3"
    919 #else
    920 #define EXTRA_XTERM_ARGS ""
    921 #endif
    922 
    923   if (hentry != NULL && *(hentry->key) != '\0')
    924   {
    925     if (*(hentry->node) != '\0')
    926       sprintf(sys, "%s %s -e %s -f %s --node='%s' &",
    927               feResource('X'), EXTRA_XTERM_ARGS,
    928               feResource('I'), feResource('i'), hentry->node);
    929     else
    930       sprintf(sys, "%s %s -e %s -f %s Index '%s' &",
    931               feResource('X'), EXTRA_XTERM_ARGS,
    932               feResource('I'), feResource('i'), hentry->key);
    933   }
    934   else
    935     sprintf(sys, "%s %s -e %s -f %s --node=Top &",
    936             feResource('X'), EXTRA_XTERM_ARGS,
    937             feResource('I'), feResource('i'));
    938   system(sys);
    939 }
    940 
    941 static BOOLEAN heTkinfoInit(int warn)
    942 {
    943 #ifndef ix86_Win
    944   if (getenv("DISPLAY") == NULL)
    945   {
    946     if (warn) WarnS("'tkinfo' help browser not available:");
    947     if (warn) WarnS("Environment variable DISPLAY not set");
    948     return FALSE;
    949   }
    950 #endif
    951   if (feResource('i', warn) == NULL)
    952   {
    953     if (warn) WarnS("'tkinfo' help browser not available: no InfoFile");
    954     return FALSE;
    955   }
    956   if (feResource('T', warn) == NULL)
    957   {
    958     if (warn) WarnS("'tkinfo' help browser not available: no 'tkinfo' program found");
    959     return FALSE;
    960   }
     964static void heDummyHelp(heEntry hentry, int br)
     965{
     966  Werror("No functioning help browser available.");
     967}
     968
     969static BOOLEAN heEmacsInit(int warn, int br)
     970{
    961971  return TRUE;
    962972}
    963 static void heTkinfoHelp(heEntry hentry)
    964 {
    965   char sys[MAX_SYSCMD_LEN];
    966   if (hentry != NULL && *(hentry->node) != '\0')
    967   {
    968     sprintf(sys, "%s '(%s)%s' &",
    969             feResource('T'), feResource('i'), hentry->node);
    970   }
    971   else
    972   {
    973     sprintf(sys, "%s %s &",
    974             feResource('T'), feResource('i'));
    975   }
    976   system(sys);
    977 }
    978 #endif // ! defined(macintosh)
    979 
    980 static BOOLEAN heDummyInit(int warn)
    981 {
    982   return TRUE;
    983 }
    984 static void heDummyHelp(heEntry hentry)
    985 {
    986   Werror("No functioning help browser available.");
    987 }
    988 
    989 static BOOLEAN heEmacsInit(int warn)
    990 {
    991   return TRUE;
    992 }
    993 static void heEmacsHelp(heEntry hentry)
     973static void heEmacsHelp(heEntry hentry, int br)
    994974{
    995975  WarnS("Your help command could not be executed. Use");
     
    999979  Warn("information on Singular running under Emacs, type C-h m.");
    1000980}
    1001 static BOOLEAN heBuiltinInit(int warn)
    1002 {
    1003   if (feResource('i', warn) == NULL)
    1004   {
    1005     if (warn) WarnS("'builtin' help browser not available: no InfoFile");
    1006     return FALSE;
    1007   }
    1008   return TRUE;
    1009 }
    1010981static int singular_manual(char *str);
    1011 static void heBuiltinHelp(heEntry hentry)
     982static void heBuiltinHelp(heEntry hentry, int br)
    1012983{
    1013984  char* node = omStrDup(hentry != NULL && *(hentry->node) != '\0' ?
     
    10301001#define MAX_LINES      21
    10311002
    1032 #ifdef macintosh
    1033 static char tolow(char p)
    1034 #else
    10351003static inline char tolow(char p)
    1036 #endif
    10371004{
    10381005  if (('A'<=p)&&(p<='Z')) return p | 040;
     
    10571024    if(lines++> MAX_LINES)
    10581025    {
    1059 #ifdef macintosh
    1060       printf("\n Press <RETURN> to continue or x and <RETURN> to exit help.\n");
    1061 #else
    10621026      printf("\n Press <RETURN> to continue or x to exit help.\n");
    1063 #endif
    10641027      fflush(stdout);
    10651028      *close = (char)getchar();
     
    10741037  if(*close!='x')
    10751038  {
    1076 #ifdef macintosh
    1077     printf("\nEnd of part. Press <RETURN> to continue or x and <RETURN> to exit help.\n");
    1078 #else
    10791039    printf("\nEnd of part. Press <RETURN> to continue or x to exit help.\n");
    1080 #endif
    10811040    fflush(stdout);
    10821041    *close = (char)getchar();
Note: See TracChangeset for help on using the changeset viewer.