Allow accessible version to recite pieces by type
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 5 Jul 2022 20:07:22 +0000 (22:07 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 5 Jul 2022 20:07:22 +0000 (22:07 +0200)
The move type-in can be used to enter a piece ID.
In this case the accessible version will read out on which squares
pieces of that colored type can be found.

winboard/jaws.c
winboard/winboard.c

index a6c1927..42c203f 100644 (file)
@@ -842,6 +842,26 @@ SayPieces(ChessSquare p)
 }\r
 \r
 VOID\r
+SayPieceType(char id)\r
+{\r
+       int f, r, nr = 0;\r
+       char buf[MSG_SIZ];\r
+       ChessSquare piece = CharToPiece(id);\r
+       if(piece == EmptySquare) {\r
+               SayString(T_("That is not a valid piece"), FALSE);\r
+               return;\r
+       }\r
+       for(r=0; r<BOARD_HEIGHT; r++) for(f=BOARD_LEFT; f<BOARD_RGHT; f++) {\r
+               if(boards[currentMove][r][f] != piece) continue;\r
+               if(!nr++) SayString(PieceToName(piece, 1), FALSE), SayString(T_("on"), FALSE);\r
+               else SayString(T_("and"), FALSE);\r
+               SayString(SquareToChar(f), FALSE);\r
+               SayString(SquareToNum(r), FALSE);\r
+       }\r
+       if(!nr) SayString(T_("There is no"), FALSE); SayString(PieceToName(piece, 1), FALSE); SayString(T_("on the board"), FALSE);\r
+}\r
+\r
+VOID\r
 SayCurrentPos()\r
 {\r
        ChessSquare currentpiece;\r
index ae89e8a..38280a2 100644 (file)
@@ -381,6 +381,7 @@ LoadLanguageFile(char *name)
               case 't': k = '\t'; break;\r
             }\r
             languageBuf[--i] = k;\r
+\r
         }\r
         i++;\r
     }\r
@@ -6775,6 +6776,9 @@ TypeInMoveDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 \r
       shiftKey = GetKeyState(VK_SHIFT) < 0; // [HGM] remember last shift status\r
       GetDlgItemText(hDlg, OPT_Move, move, sizeof(move));\r
+#ifdef JAWS\r
+      if(strlen(move) == 1 && !isdigit(*move)) SayPieceType(*move); else\r
+#endif\r
       TypeInDoneEvent(move);\r
       EndDialog(hDlg, TRUE);\r
       return TRUE;\r