/*
* dialogs.c -- platform-independent code for dialogs of XBoard
*
- * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
+ * Copyright 2000, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
* ------------------------------------------------------------------------
*
* GNU XBoard is free software: you can redistribute it and/or modify
{ 0, 0, 0, NULL, NULL, NULL, NULL, Label, NULL },
{ 200, T_VSCRL | T_FILL | T_WRAP | T_TOP, 200, NULL, (void*) &tagsText, NULL, (char **) &TagsClick, TextBox, "", &appData.tagsFont },
{ 0, 0, 100, NULL, (void*) &NewMove, NULL, NULL, Button, N_("add next move") },
-{ 0,SAME_ROW,100,NULL, (void*) &changeTags, NULL, NULL, Button, N_("save changes") },
+{ 0,SAME_ROW,100,NULL, (void*) &changeTags, NULL, NULL, Button, N_("commit changes") },
{ 0,SAME_ROW, 0, NULL, (void*) &NewTagsCallback, "", NULL, EndMark , "" }
};
}
void
-NewTagsPopup (char *text, char *msg)
+NewTagsPopup (char *text, char *msg, char *ttl)
{
- char *title = bookUp ? _("Edit book") : _("Tags");
+ char *title = bookUp ? _("Edit book") : ttl;
tagsOptions[2].type = bookUp ? Button : Skip;
tagsOptions[3].min = bookUp ? SAME_ROW : 0;
void
TagsPopUp (char *tags, char *msg)
{
- NewTagsPopup(tags, cmailMsgLoaded ? msg : NULL);
+ NewTagsPopup(tags, cmailMsgLoaded ? msg : NULL, _("Tags"));
}
void
EditTagsPopUp (char *tags, char **dest)
{ // wrapper to preserve old name used in back-end
resPtr = dest;
- NewTagsPopup(tags, NULL);
+ NewTagsPopup(tags, NULL, _("Tags"));
+}
+
+void
+EditEnginePopUp (char *tags, char **dest)
+{ // wrapper to preserve old name used in back-end
+ TagsPopDown();
+ resPtr = dest;
+ NewTagsPopup(tags, NULL, _("Registered Engines"));
}
void
//------------------------------------------------------ Time Control -----------------------------------
static int TcOK P((int n));
-int tmpMoves, tmpTc, tmpInc, tmpOdds1, tmpOdds2, tcType;
+int tmpMoves, tmpTc, tmpInc, tmpOdds1, tmpOdds2, tcType, by60;
static void SetTcType P((int n));
{ 0, 0, 0, NULL, (void*) &SetTcType, NULL, NULL, Button, N_("classical") },
{ 0,SAME_ROW,0,NULL, (void*) &SetTcType, NULL, NULL, Button, N_("incremental") },
{ 0,SAME_ROW,0,NULL, (void*) &SetTcType, NULL, NULL, Button, N_("fixed max") },
+{ 0, 0, 0, NULL, (void*) &by60, "", NULL, CheckBox, N_("Divide entered times by 60") },
{ 0, 0, 200, NULL, (void*) &tmpMoves, NULL, NULL, Spin, N_("Moves per session:") },
{ 0, 0,10000, NULL, (void*) &tmpTc, NULL, NULL, Spin, N_("Initial time (min):") },
{ 0, 0, 10000, NULL, (void*) &tmpInc, NULL, NULL, Spin, N_("Increment or max (sec/move):") },
static int
TcOK (int n)
{
- char *tc;
+ char *tc, buf[MSG_SIZ];
if(tcType == 0 && tmpMoves <= 0) return 0;
if(tcType == 2 && tmpInc <= 0) return 0;
- GetWidgetText(&tcOptions[4], &tc); // get original text, in case it is min:sec
+ GetWidgetText(&tcOptions[5], &tc); // get original text, in case it is min:sec
+ if(by60) snprintf(buf, MSG_SIZ, "%d:%02d", tmpTc/60, tmpTc%60), tc=buf;
searchTime = 0;
switch(tcType) {
case 0:
case 1:
if(!ParseTimeControl(tc, tmpInc, 0)) return 0;
ASSIGN(appData.timeControl, tc);
- appData.timeIncrement = tmpInc;
+ appData.timeIncrement = (by60 ? tmpInc/60. : tmpInc);
break;
case 2:
- searchTime = tmpInc;
+ searchTime = (by60 ? tmpInc/60 : tmpInc);
}
appData.firstTimeOdds = first.timeOdds = tmpOdds1;
appData.secondTimeOdds = second.timeOdds = tmpOdds2;
{
switch(tcType = n) {
case 0:
- SetWidgetText(&tcOptions[3], Value(tmpMoves), TransientDlg);
- SetWidgetText(&tcOptions[4], Value(tmpTc), TransientDlg);
- SetWidgetText(&tcOptions[5], _("Unused"), TransientDlg);
+ SetWidgetText(&tcOptions[4], Value(tmpMoves), TransientDlg);
+ SetWidgetText(&tcOptions[5], Value(tmpTc), TransientDlg);
+ SetWidgetText(&tcOptions[6], _("Unused"), TransientDlg);
break;
case 1:
- SetWidgetText(&tcOptions[3], _("Unused"), TransientDlg);
- SetWidgetText(&tcOptions[4], Value(tmpTc), TransientDlg);
- SetWidgetText(&tcOptions[5], Value(tmpInc), TransientDlg);
+ SetWidgetText(&tcOptions[4], _("Unused"), TransientDlg);
+ SetWidgetText(&tcOptions[5], Value(tmpTc), TransientDlg);
+ SetWidgetText(&tcOptions[6], Value(tmpInc), TransientDlg);
break;
case 2:
- SetWidgetText(&tcOptions[3], _("Unused"), TransientDlg);
SetWidgetText(&tcOptions[4], _("Unused"), TransientDlg);
- SetWidgetText(&tcOptions[5], Value(tmpInc), TransientDlg);
+ SetWidgetText(&tcOptions[5], _("Unused"), TransientDlg);
+ SetWidgetText(&tcOptions[6], Value(tmpInc), TransientDlg);
}
}
tmpInc = appData.timeIncrement; if(tmpInc < 0) tmpInc = 0;
tmpOdds1 = tmpOdds2 = 1; tcType = 0;
tmpTc = atoi(appData.timeControl);
+ by60 = 0;
GenericPopUp(tcOptions, _("Time Control"), TransientDlg, BoardWindow, MODAL, 0);
SetTcType(searchTime ? 2 : appData.timeIncrement < 0 ? 0 : 1);
}
{
errorUp = True;
errorOptions[1].name = label;
- if(dialogError = shellUp[MasterDlg])
- GenericPopUp(errorOptions+1, title, FatalDlg, MasterDlg, MODAL, 0); // pop up as daughter of the transient dialog
+ if(dialogError = shellUp[TransientDlg])
+ GenericPopUp(errorOptions+1, title, FatalDlg, TransientDlg, MODAL, 0); // pop up as daughter of the transient dialog
+ else if(dialogError = shellUp[MasterDlg])
+ GenericPopUp(errorOptions+1, title, FatalDlg, MasterDlg, MODAL, 0); // pop up as daughter of the master dialog
else
GenericPopUp(errorOptions+modal, title, modal ? FatalDlg: ErrorDlg, BoardWindow, modal, 0); // kludge: option start address indicates modality
}
{
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], 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] = {