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
#define HISTORY_SIZE 64
static char *history[HISTORY_SIZE];
static int histIn = 0, histP = 0;
+static Boolean noEcho;
static void
SaveInHistory (char *cmd)
{
+ if(noEcho) return; // do not save password!
if (history[histIn] != NULL) {
free(history[histIn]);
history[histIn] = NULL;
} else PopUpMoveDialog(*buf);
}
+void
+EchoOn ()
+{
+ if(!noEcho) return;
+ system("stty echo");
+ WidgetEcho(&chatOptions[CHAT_IN], 1);
+ noEcho = False;
+}
+
+void
+EchoOff ()
+{
+ system("stty -echo");
+ WidgetEcho(&chatOptions[CHAT_IN], 0);
+ noEcho = True;
+}
+
//--------------------------------- Game-List options dialog ------------------------------------------
char *strings[LPUSERGLT_SIZE];
if (errorExitStatus != -1) ExitEvent(errorExitStatus);
}
-static int
+int
ErrorOK (int n)
{
dialogError = errorUp = False;
{
char buf[MSG_SIZ];
+ if(status == 666) { // ignore this error when ICS Console window is up
+ if(shellUp[ChatDlg]) return;
+ status = 0;
+ }
+
errorExitStatus = status;
if (error == 0) {
fprintf(stderr, "%s: %s\n", programName, message);
}
if(mainOptions[W_BOARD].handle) {
if (appData.popupExitMessage) {
+ if(appData.icsActive) SendToICS("logout\n"); // [HGM] make sure no new games will be started
ErrorPopUp(status ? _("Fatal Error") : _("Exiting"), message, TRUE);
} else {
ExitEvent(status);
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], 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) && strncmp(line, ".SS ", 4))) {
+ 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;
+ ErrorPopUp(title, text, FALSE);
+ return;
+ }
+ }
+ snprintf(text, MSG_SIZ, "No help on '%s'\n", buf+3);
+ DisplayNote(text);
+}
+
+void
+DisplayHelp (char *name)
+{
+ static char *xboardMan;
+ char buf[MSG_SIZ], tidy[MSG_SIZ];
+ FILE *f;
+ if(!xboardMan) {
+ xboardMan = BufferCommandOutput("man -w xboard", MSG_SIZ); // obtain path to XBoard's man file
+ if(xboardMan) xboardMan[strlen(xboardMan)-1] = NULLCHAR; // strip off traling linefeed
+ }
+ 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", xboardMan);
+ 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);
+ }
+}
+
#define PAUSE_BUTTON "P"
#define PIECE_MENU_SIZE 18
static String pieceMenuStrings[2][PIECE_MENU_SIZE+1] = {
".trn",
".bin",
".wav",
+".png",
".ini",
".log",
"",