X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=dialogs.c;h=189a869f82200511aed478cde4c9943a2cee48bf;hb=894916fe72347000731f92313b9c2230fd837247;hp=30b2ad517a36a66bd150323331849e6573244678;hpb=c118cf9cee0e6d5a3f78c8b409100948a3a22a16;p=xboard.git diff --git a/dialogs.c b/dialogs.c index 30b2ad5..189a869 100644 --- a/dialogs.c +++ b/dialogs.c @@ -66,7 +66,7 @@ extern char *getenv(); int values[MAX_OPTIONS]; ChessProgramState *currentCps; -char dataDir[MSG_SIZ] = DATADIR, manDir[MSG_SIZ] = MANDIR; +char manDir[MSG_SIZ] = MANDIR; //----------------------------Generic dialog -------------------------------------------- @@ -2447,6 +2447,7 @@ DisplayTitle (char *text) } char *textPtr; +char *texEscapes[] = { "s-1", "s0", "&", "*(L", "*(R", NULL }; int GetNext(FILE *f) @@ -2472,7 +2473,7 @@ GetHelpText (FILE *f, char *name) int len, cnt = 0; snprintf(buf, MSG_SIZ, ".B %s", name); len = strlen(buf); - for(len=1; buf[len] == ' ' || buf[len] == '-' || isalpha(buf[len]) || isdigit(buf[len]); len++); + for(len=3; buf[len] && buf[len] != '(' && buf[len] != ':' && buf[len] != '.' && buf[len] != '?'; len++); buf[len] = NULLCHAR; while(buf[--len] == ' ') buf[len] = NULLCHAR; snprintf(title, MSG_SIZ, "Help on '%s'", buf+3); @@ -2485,6 +2486,18 @@ GetHelpText (FILE *f, char *name) *p++ = ' '; cnt++; while(*line) { if(*line < ' ') { line++; continue;} + if(*line == '\\') { + char **esc; + line++; + for(esc = texEscapes; *esc; esc++) { + len = strlen(*esc); + if(!strncmp(*esc, line, len)) { + line += len; + break; + } + } + continue; + } if(*line == ' ' && p - q > 80) *line = '\n', q = p; *p++ = *line++; } @@ -2503,7 +2516,7 @@ void DisplayHelp (char *name) { static char *xboardMan, *manText[2], tidy[MSG_SIZ], engMan[MSG_SIZ]; - char buf[MSG_SIZ], *eng; + char buf[MSG_SIZ], adapter[MSG_SIZ], *eng; int n = 0; FILE *f; if(!xboardMan) { @@ -2512,7 +2525,13 @@ DisplayHelp (char *name) } if(currentCps) { // for engine options we have to look in engine manual snprintf(buf, MSG_SIZ, "man -w "); // get (tidied) engine name in buf + TidyProgramName(currentCps->program, "localhost", adapter); // name of binary we are actually running TidyProgramName(currentCps == &first ? appData.firstChessProgram : appData.secondChessProgram, "localhost", buf+7); + if(strcmp(buf+7, adapter) && StrCaseStr(name, adapter) == name) { // option starts with name of apparent proxy for engine + safeStrCpy(buf+7, adapter, MSG_SIZ-7); // use adapter manual + name += strlen(adapter); // strip adapter name of option + while(*name == ' ') name++; + } if(strcmp(buf, tidy)) { // is different engine from last time FREE(manText[1]); manText[1] = NULL; // so any currently held text is worthless safeStrCpy(tidy, buf, MSG_SIZ); // remember current engine @@ -2524,6 +2543,8 @@ DisplayHelp (char *name) } else snprintf(buf, MSG_SIZ, "%s", xboardMan); // use xboard man f = fopen(buf, "r"); if(f) { + char *msg = "Right-clicking menu item or dialog text pops up help on it"; + ASSIGN(appData.suppress, msg); if(strstr(buf, ".gz")) { // man file is gzipped if(!manText[n]) { // unzipped text not buffered yet snprintf(tidy, MSG_SIZ, "gunzip -c %s", buf);