void AdjuBlackProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void AdjuDrawProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void EnterKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+void UpKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+void DownKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void StopObservingProc P((Widget w, XEvent *event, String *prms,
Cardinal *nprms));
void StopExaminingProc P((Widget w, XEvent *event, String *prms,
{ "AdjuBlackProc", AdjuBlackProc },
{ "AdjuDrawProc", AdjuDrawProc },
{ "EnterKeyProc", EnterKeyProc },
+ { "UpKeyProc", UpKeyProc },
+ { "DownKeyProc", DownKeyProc },
{ "StopObservingProc", StopObservingProc },
{ "StopExaminingProc", StopExaminingProc },
{ "BackwardProc", BackwardProc },
char blackTranslations[] = "<BtnDown>: BlackClock()\n";
char ICSInputTranslations[] =
+ "<Key>Up: UpKeyProc() \n "
+ "<Key>Down: DownKeyProc() \n "
"<Key>Return: EnterKeyProc() \n";
String xboardResources[] = {
}
}
+// [HGM] code borrowed from winboard.c (which should thus go to backend.c!)
+#define HISTORY_SIZE 64\r
+static char *history[HISTORY_SIZE];\r
+int histIn = 0, histP = 0;\r
+\r
+void\r
+SaveInHistory(char *cmd)\r
+{\r
+ if (history[histIn] != NULL) {\r
+ free(history[histIn]);\r
+ history[histIn] = NULL;\r
+ }\r
+ if (*cmd == NULLCHAR) return;\r
+ history[histIn] = StrSave(cmd);\r
+ histIn = (histIn + 1) % HISTORY_SIZE;\r
+ if (history[histIn] != NULL) {\r
+ free(history[histIn]);\r
+ history[histIn] = NULL;\r
+ }\r
+ histP = histIn;\r
+}\r
+\r
+char *\r
+PrevInHistory(char *cmd)\r
+{\r
+ int newhp;\r
+ if (histP == histIn) {\r
+ if (history[histIn] != NULL) free(history[histIn]);\r
+ history[histIn] = StrSave(cmd);\r
+ }\r
+ newhp = (histP - 1 + HISTORY_SIZE) % HISTORY_SIZE;\r
+ if (newhp == histIn || history[newhp] == NULL) return NULL;\r
+ histP = newhp;\r
+ return history[histP];\r
+}\r
+\r
+char *\r
+NextInHistory()\r
+{\r
+ if (histP == histIn) return NULL;\r
+ histP = (histP + 1) % HISTORY_SIZE;\r
+ return history[histP]; \r
+}
+// end of borrowed code\r
+\r
#define Abs(n) ((n)<0 ? -(n) : (n))
/*
j = 0;
XtSetArg(args[j], XtNstring, &val); j++;
XtGetValues(edit, args, j);
+ SaveInHistory(val);
SendMultiLineToICS(val);
XtCallActionProc(edit, "select-all", NULL, NULL, 0);
XtCallActionProc(edit, "kill-selection", NULL, NULL, 0);
ICSInputSendText();
}
+void UpKeyProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{ // [HGM] input: let up-arrow recall previous line from history
+ Widget edit;
+ int j;
+ Arg args[16];
+ String val;
+ XawTextBlock t;
+
+ if (!ICSInputBoxUp) return;
+ edit = XtNameToWidget(ICSInputShell, "*form.text");
+ j = 0;
+ XtSetArg(args[j], XtNstring, &val); j++;
+ XtGetValues(edit, args, j);
+ val = PrevInHistory(val);
+ XtCallActionProc(edit, "select-all", NULL, NULL, 0);
+ XtCallActionProc(edit, "kill-selection", NULL, NULL, 0);
+ if(val) {
+ t.ptr = val; t.firstPos = 0; t.length = strlen(val); t.format = XawFmt8Bit;
+ XawTextReplace(edit, 0, 0, &t);
+ XawTextSetInsertionPoint(edit, 9999);
+ }
+}
+
+void DownKeyProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{ // [HGM] input: let down-arrow recall next line from history
+ Widget edit;
+ String val;
+ XawTextBlock t;
+
+ if (!ICSInputBoxUp) return;
+ edit = XtNameToWidget(ICSInputShell, "*form.text");
+ val = NextInHistory();
+ XtCallActionProc(edit, "select-all", NULL, NULL, 0);
+ XtCallActionProc(edit, "kill-selection", NULL, NULL, 0);
+ if(val) {
+ t.ptr = val; t.firstPos = 0; t.length = strlen(val); t.format = XawFmt8Bit;
+ XawTextReplace(edit, 0, 0, &t);
+ XawTextSetInsertionPoint(edit, 9999);
+ }
+}
+
void StopObservingProc(w, event, prms, nprms)
Widget w;
XEvent *event;