int EventToSquare P((int x, int limit));
void DrawSquare P((int row, int column, ChessSquare piece, int do_flash));
void EventProc P((Widget widget, caddr_t unused, XEvent *event));
+void MoveTypeInProc P((Widget widget, caddr_t unused, XEvent *event));
void HandleUserMove P((Widget w, XEvent *event,
String *prms, Cardinal *nprms));
void AnimateUserMove P((Widget w, XEvent * event,
void AdjuWhiteProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void AdjuBlackProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
void AdjuDrawProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms));
+void TypeInProc 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));
{ "AdjuWhiteProc", AdjuWhiteProc },
{ "AdjuBlackProc", AdjuBlackProc },
{ "AdjuDrawProc", AdjuDrawProc },
+ { "TypeInProc", TypeInProc },
{ "EnterKeyProc", EnterKeyProc },
{ "UpKeyProc", UpKeyProc },
{ "DownKeyProc", DownKeyProc },
XtAddEventHandler(boardWidget, ExposureMask|PointerMotionMask, False,
(XtEventHandler) EventProc, NULL);
/* end why */
+ XtAddEventHandler(formWidget, KeyPressMask, False,
+ (XtEventHandler) MoveTypeInProc, NULL);
/* [AS] Restore layout */
if( wpMoveHistory.visible ) {
XtOverrideTranslations(boxOptions[0].handle, XtParseTranslationTable(ICSInputTranslations));
}
+void TypeInProc(w, event, prms, nprms)
+ Widget w;
+ XEvent *event;
+ String *prms;
+ Cardinal *nprms;
+{
+ Widget edit;
+ int j, fromX, fromY, toX, toY;
+ Arg args[16];
+ String val;
+ char *move, promoChar;
+ ChessMove moveType;
+
+ if(prms[0][0] == '0') PopDown(0); // escape hit
+ edit = boxOptions[0].handle;
+ j = 0;
+ XtSetArg(args[j], XtNstring, &val); j++;
+ XtGetValues(edit, args, j);
+ move = val;
+ { int n; Board board;\r
+ // [HGM] FENedit\r
+ if(gameMode == EditPosition && ParseFEN(board, &n, move) ) {\r
+ EditPositionPasteFEN(move);\r
+ PopDown(0);\r
+ return;\r
+ }\r
+ // [HGM] movenum: allow move number to be typed in any mode\r
+ if(sscanf(move, "%d", &n) == 1 && n != 0 ) {\r
+ ToNrEvent(2*n-1);\r
+ PopDown(0);\r
+ return;\r
+ }\r
+ }\r
+ if (gameMode != EditGame && currentMove != forwardMostMove && \r
+ gameMode != Training) {\r
+ DisplayMoveError(_("Displayed move is not current"));\r
+ } else {\r
+ int ok = ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove, \r
+ &moveType, &fromX, &fromY, &toX, &toY, &promoChar);\r
+ if(!ok && move[0] >= 'a') { move[0] += 'A' - 'a'; ok = 2; } // [HGM] try also capitalized\r
+ if (ok==1 || ok && ParseOneMove(move, gameMode == EditPosition ? blackPlaysFirst : currentMove, \r
+ &moveType, &fromX, &fromY, &toX, &toY, &promoChar)) {\r
+ UserMoveEvent(fromX, fromY, toX, toY, promoChar); \r
+ } else {\r
+ DisplayMoveError(_("Could not parse move"));\r
+ }\r
+ }\r
+ PopDown(0);\r
+}
+
+char moveTypeInTranslations[] =
+ "<Key>Return: TypeInProc(1) \n"
+ "<Key>Escape: TypeInProc(0) \n";
+
+void MoveTypeInPopup(char firstchar)
+{
+ static char buf[2];
+ if ((gameMode == BeginningOfGame && !appData.icsActive) || \r
+ gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack ||\r
+ gameMode == AnalyzeMode || gameMode == EditGame || \r
+ gameMode == EditPosition || gameMode == IcsExamining ||\r
+ gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack ||\r
+ isdigit(firstchar) && // [HGM] movenum: allow typing in of move nr in 'passive' modes\r
+ ( gameMode == AnalyzeFile || gameMode == PlayFromGameFile ||\r
+ gameMode == IcsObserving || gameMode == TwoMachinesPlay ) ||\r
+ gameMode == Training) {\r
+ buf[0]= firstchar; icsText = buf;
+ if(GenericPopUp(boxOptions, _("Type a move"), 0))
+ XtOverrideTranslations(boxOptions[0].handle, XtParseTranslationTable(moveTypeInTranslations));
+ }
+}
+
+void MoveTypeInProc(Widget widget, caddr_t unused, XEvent *event)
+{
+ char buf[10], keys[32];
+ KeySym sym;
+ KeyCode metaL, metaR;
+ int n = XLookupString(&(event->xkey), buf, 10, &sym, NULL);
+ XQueryKeymap(xDisplay,keys);
+ metaL = XKeysymToKeycode(xDisplay, XK_Meta_L);
+ metaR = XKeysymToKeycode(xDisplay, XK_Meta_R);
+//{int i; for(i=0;i<32;i++)printf("%02x",keys[i]);printf("\n");}
+ if ( n == 1 && *buf > 32 && !(keys[metaL>>3]&1<<(metaL&7)) && !(keys[metaR>>3]&1<<(metaR&7))) // printable, no alt
+ MoveTypeInPopup(*buf);
+
+}
+
void
SettingsPopUp(ChessProgramState *cps)
{