}
void
+TypeInEvent(char firstChar)
+{
+ 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) PopUpMoveDialog(firstChar);
+}
+
+void
+TypeInDoneEvent(char *move)
+{
+ Board board;
+ int n, fromX, fromY, toX, toY;
+ char promoChar;
+ ChessMove moveType;\r
+
+ // [HGM] FENedit\r
+ if(gameMode == EditPosition && ParseFEN(board, &n, move) ) {\r
+ EditPositionPasteFEN(move);\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
+ return;\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
+
+void
DisplayMove(moveNumber)
int moveNumber;
{
void AnalyzeModeEvent P((void));
void AnalyzeFileEvent P((void));
void MatchEvent P((int mode));
+void TypeInEvent P((char first));
+void TypeInDoneEvent P((char *move));
void InitPosition P((int redraw));
void NewSettingEvent P((int option, int *feature, char *command, int value));
int WaitForSecond P((DelayedEventCallback x));
void DrawSeekBackground P(( int left, int top, int right, int bottom ));
void DrawSeekText P((char *buf, int x, int y));
void DrawSeekDot P((int x, int y, int color));
+void PopUpMoveDialog P((char first));
void RingBell P((void));
void PlayIcsWinSound P((void));
StartupDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
VOID APIENTRY MenuPopup(HWND hwnd, POINT pt, HMENU hmenu, UINT def);\r
void ParseIcsTextMenu(char *icsTextMenuString);\r
-VOID PopUpMoveDialog(char firstchar);\r
VOID PopUpNameDialog(char firstchar);\r
VOID UpdateSampleText(HWND hDlg, int id, MyColorizeAttribs *mca);\r
\r
SendMessage(h, WM_CHAR, wParam, lParam);\r
return TRUE;\r
} else if (isalpha((char)wParam) || isdigit((char)wParam)){\r
- PopUpMoveDialog((char)wParam);\r
+ TypeInEvent((char)wParam);\r
}\r
break;\r
}\r
SendMessage(h, message, wParam, lParam);\r
} else if(lParam != KF_REPEAT) {\r
if (isalpha((char)wParam) || isdigit((char)wParam)) {\r
- PopUpMoveDialog((char)wParam);\r
+ TypeInEvent((char)wParam);\r
} else if((char)wParam == 003) CopyGameToClipboard();\r
else if((char)wParam == 026) PasteGameOrFENFromClipboard();\r
}\r
break;\r
\r
case IDM_TypeInMove:\r
- PopUpMoveDialog('\000');\r
+ TypeInEvent('\000');\r
break;\r
\r
case IDM_TypeInName:\r
{\r
char move[MSG_SIZ];\r
HWND hInput;\r
- ChessMove moveType;\r
- int fromX, fromY, toX, toY;\r
- char promoChar;\r
\r
switch (message) {\r
case WM_INITDIALOG:\r
case IDOK:
\r
shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status\r
- GetDlgItemText(hDlg, OPT_Move, move, sizeof(move));\r
- { int n; Board board;\r
- // [HGM] FENedit\r
- if(gameMode == EditPosition && ParseFEN(board, &n, move) ) {\r
- EditPositionPasteFEN(move);\r
- EndDialog(hDlg, TRUE);\r
- return TRUE;\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
- EndDialog(hDlg, TRUE);\r
- return TRUE;\r
- }\r
- }\r
- if (gameMode != EditGame && currentMove != forwardMostMove && \r
- gameMode != Training) {\r
- DisplayMoveError(_("Displayed move is not current"));\r
- } else {\r
-// GetDlgItemText(hDlg, OPT_Move, move, sizeof(move)); // moved upstream\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
+ GetDlgItemText(hDlg, OPT_Move, move, sizeof(move));
+ TypeInDoneEvent(move);\r
EndDialog(hDlg, TRUE);\r
return TRUE;\r
case IDCANCEL:\r
PopUpMoveDialog(char firstchar)\r
{\r
FARPROC lpProc;\r
- \r
- 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
+\r
lpProc = MakeProcInstance((FARPROC)TypeInMoveDialog, hInst);\r
DialogBoxParam(hInst, MAKEINTRESOURCE(DLG_TypeInMove),\r
hwndMain, (DLGPROC)lpProc, (LPARAM)firstchar);\r
FreeProcInstance(lpProc);\r
- }\r
}\r
\r
/*---------------------------------------------------------------------------*\\r
String *prms;
Cardinal *nprms;
{
- Widget edit;
- int j, fromX, fromY, toX, toY;
- Arg args[16];
+ Arg args[2];
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
+ if(prms[0][0] == '1') {
+ XtSetArg(args[0], XtNstring, &val);
+ XtGetValues(boxOptions[0].handle, args, 1);
+ TypeInDoneEvent((char*)val);
+ }
+ PopDown(0);\r
}
char moveTypeInTranslations[] =
"<Key>Return: TypeInProc(1) \n"
"<Key>Escape: TypeInProc(0) \n";
-void MoveTypeInPopup(char firstchar)
+void PopUpMoveDialog(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));
- }
+ 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)
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);
+ PopUpMoveDialog(*buf);
}