X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=dialogs.c;h=3279a5f4e74f9afa10b99a6495cc699c119fc042;hb=960cb2c18e20efe428653f8832e488aac93a6603;hp=5eb368761cee93d46239f152a3eb846d9bc76d5e;hpb=d52a42f3f58c509d66ea3ce1bfa22866cc86bb54;p=xboard.git diff --git a/dialogs.c b/dialogs.c index 5eb3687..3279a5f 100644 --- a/dialogs.c +++ b/dialogs.c @@ -2426,6 +2426,59 @@ DisplayTitle (char *text) SetWindowTitle(text, title, icon); } +static char * +ReadLine (FILE *f) +{ + static char buf[MSG_SIZ]; + int i = 0, c; + while((c = fgetc(f)) != '\n') { if(c == EOF) return NULL; buf[i++] = c; } + buf[i] = NULLCHAR; + return buf; +} + +void +GetHelpText (FILE *f, char *name) +{ + char *line, buf[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] == ' ' || isalpha(buf[len]) || isdigit(buf[len]); len++); + buf[len] = NULLCHAR; + while(buf[--len] == ' ') buf[len] = NULLCHAR; + 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(!*line) { *p++ = '\n'; *p++ = '\n'; q = p; continue; } + if(*line == '.') continue; + *p++ = ' '; cnt++; + while(*line) { + if(*line < ' ') { line++; continue;} + if(*line == ' ' && p - q > 80) *line = '\n', q = p; + *p++ = *line++; + } + if(p - text > 9900) break; + } + *p = NULLCHAR; + DisplayNote(text); + return; + } + } + snprintf(text, MSG_SIZ, "No help on '%s'\n", buf+3); + DisplayNote(text); +} + +void +DisplayHelp (char *name) +{ + char *manFile = DATADIR "/../../man/man6/xboard.6"; + FILE *f = fopen(manFile, "r"); + if(f) { + GetHelpText(f, name); + fclose(f); + } +} + #define PAUSE_BUTTON "P" #define PIECE_MENU_SIZE 18 static String pieceMenuStrings[2][PIECE_MENU_SIZE+1] = {