int values[MAX_OPTIONS];
ChessProgramState *currentCps;
+char dataDir[MSG_SIZ] = DATADIR, manDir[MSG_SIZ] = MANDIR;
//----------------------------Generic dialog --------------------------------------------
if(tagsText) free(tagsText); tagsText = strdup(text);
tagsOptions[0].name = msg;
MarkMenu("View.Tags", TagsDlg);
- GenericPopUp(tagsOptions, title, TagsDlg, BoardWindow, NONMODAL, appData.topLevel);
+ GenericPopUp(tagsOptions + (msg == NULL), title, TagsDlg, BoardWindow, NONMODAL, appData.topLevel);
}
void
if (errorExitStatus != -1) ExitEvent(errorExitStatus);
}
-static int
+int
ErrorOK (int n)
{
dialogError = errorUp = False;
void
GetHelpText (FILE *f, char *name)
{
- char *line, buf[MSG_SIZ], text[10000], *p = text, *q = text;
+ char *line, buf[MSG_SIZ], title[MSG_SIZ], text[10000], *p = text, *q = text;
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++);
buf[len] = NULLCHAR;
while(buf[--len] == ' ') buf[len] = NULLCHAR;
+ snprintf(title, MSG_SIZ, "Help on '%s'", buf+3);
while((line = ReadLine(f))) {
- if(!strncmp(line, buf, len) && (strncmp(line, ".SS ", 4) || strncmp(line+4, buf+3, len-3))) {
- while((line = ReadLine(f)) && (cnt == 0 || strncmp(line, ".B ", 3))) {
+ if(!strncmp(line, buf, len) || !strncmp(line, ".SS ", 4) && !strncmp(line+4, buf+3, len-3)) {
+ while((line = ReadLine(f)) && (cnt == 0 || strncmp(line, ".B ", 3) && strncmp(line, ".SS ", 4))) {
if(!*line) { *p++ = '\n'; *p++ = '\n'; q = p; continue; }
if(*line == '.') continue;
*p++ = ' '; cnt++;
if(p - text > 9900) break;
}
*p = NULLCHAR;
- ErrorPopUp("Help", text, FALSE);
+ ErrorPopUp(title, text, FALSE);
return;
}
}
void
DisplayHelp (char *name)
{
- char *manFile = DATADIR "/../../man/man6/xboard.6";
- FILE *f = fopen(manFile, "r");
+ char buf[MSG_SIZ], tidy[MSG_SIZ];
+ FILE *f;
+ if(currentCps) {
+ TidyProgramName(currentCps == &first ? appData.firstChessProgram : appData.secondChessProgram, "localhost", tidy);
+ snprintf(buf, MSG_SIZ, "/usr/local/share/man/man6/%s.6", tidy);
+ } else snprintf(buf, MSG_SIZ, "%s/man6/xboard.6", manDir);
+ f = fopen(buf, "r");
+ if(!f && currentCps) { // engine manual could be in two places
+ snprintf(buf, MSG_SIZ, "/usr/share/man/man6/%s.6", tidy);
+ f = fopen(buf, "r");
+ }
if(f) {
GetHelpText(f, name);
fclose(f);