Implement peeking previous position in WinBoard
[xboard.git] / winboard / winboard.c
index 0abb7e6..a34b9cd 100644 (file)
@@ -253,7 +253,8 @@ int dialogItems[][41        ] = {
 { ABOUTBOX, IDOK, OPT_MESS, 400 }, \r
 { DLG_TimeControl, IDC_Babble, OPT_TCUseMoves, OPT_TCUseInc, OPT_TCUseFixed, \r
   OPT_TCtext1, OPT_TCtext2, OPT_TCitext1, OPT_TCitext2, OPT_TCftext, GPB_Factors,   IDC_Factor1, IDC_Factor2, IDOK, IDCANCEL }, \r
-{ DLG_LoadOptions, OPT_Autostep, OPT_AStext1, IDOK, IDCANCEL },\r
+{ DLG_LoadOptions, OPT_Autostep, OPT_AStext1, OPT_Exact, OPT_Subset, OPT_Struct, OPT_Material, OPT_Range, OPT_Difference,\r
+  OPT_elo1t, OPT_elo2t, OPT_datet, OPT_Stretch, OPT_Stretcht, OPT_Reversed, OPT_SearchMode, OPT_Mirror, OPT_thresholds, IDOK, IDCANCEL }, \r
 { DLG_SaveOptions, OPT_Autosave, OPT_AVPrompt, OPT_AVToFile, OPT_AVBrowse,\r
   801, OPT_PGN, OPT_Old, OPT_OutOfBookInfo, IDOK, IDCANCEL }, \r
 { 1536, 1090, IDC_Directories, 1089, 1091, IDOK, IDCANCEL, 1038, IDC_IndexNr, 1037 }, \r
@@ -333,7 +334,7 @@ int dialogItems[][41        ] = {
 { 0 }\r
 };\r
 \r
-static char languageBuf[50000], *foreign[1000], *english[1000], *languageFile[MSG_SIZ];\r
+static char languageBuf[70000], *foreign[1000], *english[1000], *languageFile[MSG_SIZ];\r
 static int lastChecked;\r
 static char oldLanguage[MSG_SIZ], *menuText[10][30];\r
 extern int tinyLayout;\r
@@ -387,11 +388,16 @@ T_(char *s)
 {   // return the translation of the given string\r
     // efficiency can be improved a lot...\r
     int i=0;\r
+    static char buf[MSG_SIZ];\r
 //if(appData.debugMode) fprintf(debugFP, "T_(%s)\n", s);\r
     if(!barbaric) return s;\r
     if(!s) return ""; // sanity\r
     while(english[i]) {\r
         if(!strcmp(s, english[i])) return foreign[i];\r
+       if(english[i][0] == '%' && strstr(s, english[i]+1) == s) { // allow translation of strings with variable ending\r
+           snprintf(buf, MSG_SIZ, "%s%s", foreign[i], s + strlen(english[i]+1)); // keep unmatched portion\r
+           return buf;\r
+       }\r
         i++;\r
     }\r
     return s;\r
@@ -731,7 +737,8 @@ void ThawUI()
 #define JAWS_INIT\r
 #define JAWS_ARGS\r
 #define JAWS_ALT_INTERCEPT\r
-#define JAWS_KB_NAVIGATION\r
+#define JAWS_KBUP_NAVIGATION\r
+#define JAWS_KBDOWN_NAVIGATION\r
 #define JAWS_MENU_ITEMS\r
 #define JAWS_SILENCE\r
 #define JAWS_REPLAY\r
@@ -4139,9 +4146,9 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
   switch (message) {\r
   case WM_LBUTTONDOWN:\r
       if (PtInRect((LPRECT) &whiteRect, pt)) {\r
-        ClockClick(flipClock);\r
+        ClockClick(flipClock); break;\r
       } else if (PtInRect((LPRECT) &blackRect, pt)) {\r
-       ClockClick(!flipClock);\r
+       ClockClick(!flipClock); break;\r
       }\r
       dragInfo.start.x = dragInfo.start.y = -1;\r
       dragInfo.from = dragInfo.start;\r
@@ -4221,9 +4228,9 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
     if(y == -2) {\r
       /* [HGM] right mouse button in clock area edit-game mode ups clock */\r
       if (PtInRect((LPRECT) &whiteRect, pt)) {\r
-          if (gameMode == EditGame || GetKeyState(VK_SHIFT) < 0) AdjustClock(flipClock, 1);\r
+          if (GetKeyState(VK_SHIFT) < 0) AdjustClock(flipClock, 1);\r
       } else if (PtInRect((LPRECT) &blackRect, pt)) {\r
-          if (gameMode == EditGame || GetKeyState(VK_SHIFT) < 0) AdjustClock(!flipClock, 1);\r
+          if (GetKeyState(VK_SHIFT) < 0) AdjustClock(!flipClock, 1);\r
       }\r
       break;\r
     }\r
@@ -4567,6 +4574,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
   char fileTitle[MSG_SIZ];\r
   char buf[MSG_SIZ];\r
   static SnapData sd;\r
+  static int peek=0;\r
 \r
   switch (message) {\r
 \r
@@ -4594,7 +4602,23 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
     MouseEvent(hwnd, message, wParam, lParam);\r
     break;\r
 \r
-  JAWS_KB_NAVIGATION\r
+  case WM_KEYUP:\r
+    if((char)wParam == '\b') {\r
+      ForwardEvent(); peek = 0;\r
+    }\r
+\r
+    JAWS_KBUP_NAVIGATION\r
+\r
+    break;\r
+\r
+  case WM_KEYDOWN:\r
+    if((char)wParam == '\b') {\r
+      if(!peek) BackwardEvent(), peek = 1;\r
+    }\r
+\r
+    JAWS_KBDOWN_NAVIGATION\r
+\r
+    break;\r
 \r
   case WM_CHAR:\r
     \r
@@ -4924,7 +4948,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
       } else {\r
        if (!appData.showThinking) ToggleShowThinking();\r
        AnalyzeFileEvent();\r
-       LoadGameDialog(hwnd, _("Analyze Game from File"));\r
+//     LoadGameDialog(hwnd, _("Analyze Game from File"));\r
        AnalysisPeriodicEvent(1);\r
       }\r
       break;\r
@@ -5062,6 +5086,11 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
       SetFocus(hwndMain);\r
       break;\r
 \r
+    case OPT_GameListNext: // [HGM] forward these two accelerators to Game List\r
+    case OPT_GameListPrev:\r
+      if(gameListDialog) SendMessage(gameListDialog, WM_COMMAND, wmId, 0);\r
+      break;\r
+\r
     case IDM_Revert:\r
       RevertEvent(FALSE);\r
       break;\r
@@ -8852,6 +8881,37 @@ IDLE_PRIORITY_CLASS         0x00000040
         return 0x00000040;\r
 }\r
 \r
+void RunCommand(char *cmdLine)\r
+{\r
+  /* Now create the child process. */\r
+  STARTUPINFO siStartInfo;\r
+  PROCESS_INFORMATION piProcInfo;\r
+\r
+  siStartInfo.cb = sizeof(STARTUPINFO);\r
+  siStartInfo.lpReserved = NULL;\r
+  siStartInfo.lpDesktop = NULL;\r
+  siStartInfo.lpTitle = NULL;\r
+  siStartInfo.dwFlags = STARTF_USESTDHANDLES;\r
+  siStartInfo.cbReserved2 = 0;\r
+  siStartInfo.lpReserved2 = NULL;\r
+  siStartInfo.hStdInput = NULL;\r
+  siStartInfo.hStdOutput = NULL;\r
+  siStartInfo.hStdError = NULL;\r
+\r
+  CreateProcess(NULL,\r
+               cmdLine,           /* command line */\r
+               NULL,      /* process security attributes */\r
+               NULL,      /* primary thread security attrs */\r
+               TRUE,      /* handles are inherited */\r
+               DETACHED_PROCESS|CREATE_NEW_PROCESS_GROUP,\r
+               NULL,      /* use parent's environment */\r
+               NULL,\r
+               &siStartInfo, /* STARTUPINFO pointer */\r
+               &piProcInfo); /* receives PROCESS_INFORMATION */\r
+\r
+  CloseHandle(piProcInfo.hThread);\r
+}\r
+\r
 /* Start a child process running the given program.\r
    The process's standard output can be read from "from", and its\r
    standard input can be written to "to".\r
@@ -9587,6 +9647,12 @@ OutputToProcess(ProcRef pr, char *message, int count, int *outError)
   return outCount;\r
 }\r
 \r
+void\r
+DoSleep(int n)\r
+{\r
+    if(n != 0) Sleep(n);\r
+}\r
+\r
 int\r
 OutputToProcessDelayed(ProcRef pr, char *message, int count, int *outError,\r
                       long msdelay)\r
@@ -9828,16 +9894,6 @@ Tween(start, mid, finish, factor, frames, nFrames)
 }\r
 \r
 void\r
-HistorySet( char movelist[][2*MOVE_LEN], int first, int last, int current )\r
-{\r
-    MoveHistorySet( movelist, first, last, current, pvInfoList );\r
-\r
-    EvalGraphSet( first, last, current, pvInfoList );\r
-\r
-    MakeEngineOutputTitle();\r
-}\r
-\r
-void\r
 SettingsPopUp(ChessProgramState *cps)\r
 {     // [HGM] wrapper needed because handles must not be passed through back-end\r
       EngineOptionsPopup(savedHwnd, cps);\r