}
buf[buf_len] = NULLCHAR;
- next_out = leftover_len;
+ // next_out = leftover_len; // [HGM] should we set this to 0, and not print it in advance?
+ next_out = 0;
leftover_start = 0;
-
+
i = 0;
while (i < buf_len) {
/* Deal with part of the TELNET option negotiation
savingComment = TRUE;
suppressKibitz = gameMode != IcsObserving ? 2 :
(StrStr(star_match[0], gameInfo.white) == NULL) + 1;
- }
+ }
continue;
} else
- if(looking_at(buf, &i, "kibitzed to")) { // suppress the acknowledgements of our own autoKibitz
- started = STARTED_CHATTER;
- suppressKibitz = TRUE;
+ if(looking_at(buf, &i, "kibitzed to *\n") && atoi(star_match[0])) {
+ // suppress the acknowledgements of our own autoKibitz
+ SendToPlayer(star_match[0], strlen(star_match[0]));
+ looking_at(buf, &i, "*% "); // eat prompt
+ next_out = i;
}
} // [HGM] kibitz: end of patch
i++; /* skip unparsed character and loop back */
}
-
- if (started != STARTED_MOVES && started != STARTED_BOARD && !suppressKibitz && // [HGM] kibitz suppress printing in ICS interaction window
- started != STARTED_HOLDINGS && i > next_out) {
- SendToPlayer(&buf[next_out], i - next_out);
+
+ if (started != STARTED_MOVES && started != STARTED_BOARD && !suppressKibitz && // [HGM] kibitz
+ // started != STARTED_HOLDINGS && i > next_out) { // [HGM] should we compare to leftover_start in stead of i?
+ // SendToPlayer(&buf[next_out], i - next_out);
+ started != STARTED_HOLDINGS && leftover_start > next_out) {
+ SendToPlayer(&buf[next_out], leftover_start - next_out);
next_out = i;
}
- suppressKibitz = FALSE; // [HGM] kibitz: has done its duty in if-statement above
-
+
leftover_len = buf_len - leftover_start;
/* if buffer ends with something we couldn't parse,
reparse it after appending the next read */
slip a promotion popup in between. But that it always needs two
calls, to the first part, (now called UserMoveTest() ), and to
FinishMove if the first part succeeded. Calls that do not need
- to do anything in between, can call this routine the old way.
+ to do anything in between, can call this routine the old way.
*/
- ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar, FALSE);
-if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar);
- if(moveType == AmbiguousMove)
- DrawPosition(FALSE, boards[currentMove]);
- else if(moveType != ImpossibleMove && moveType != Comment)
- FinishMove(moveType, fromX, fromY, toX, toY, promoChar);
+ ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar, FALSE);
+ if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar);
+ if(moveType == AmbiguousMove)
+ DrawPosition(FALSE, boards[currentMove]);
+ else if(moveType != ImpossibleMove && moveType != Comment)
+ FinishMove(moveType, fromX, fromY, toX, toY, promoChar);
}
+ void
+ Mark(board, flags, kind, rf, ff, rt, ft, closure)
+ Board board;
+ int flags;
+ ChessMove kind;
+ int rf, ff, rt, ft;
+ VOIDSTAR closure;
+ {
+ typedef char Markers[BOARD_RANKS][BOARD_FILES];
+ Markers *m = (Markers *) closure;
+ if(rf == fromY && ff == fromX)
+ (*m)[rt][ft] = 1 + (board[rt][ft] != EmptySquare
+ || kind == WhiteCapturesEnPassant
+ || kind == BlackCapturesEnPassant);
+ else if(flags & F_MANDATORY_CAPTURE && board[rt][ft] != EmptySquare) (*m)[rt][ft] = 3;
+ }
+
+ void
+ MarkTargetSquares(int clear)
+ {
+ int x, y;
+ if(!appData.markers || !appData.highlightDragging ||
+ !appData.testLegality || gameMode == EditPosition) return;
+ if(clear) {
+ for(x=0; x<BOARD_WIDTH; x++) for(y=0; y<BOARD_HEIGHT; y++) marker[y][x] = 0;
+ } else {
+ int capt = 0;
+ GenLegal(boards[currentMove], PosFlags(currentMove), Mark, (void*) marker);
+ if(PosFlags(0) & F_MANDATORY_CAPTURE) {
+ for(x=0; x<BOARD_WIDTH; x++) for(y=0; y<BOARD_HEIGHT; y++) if(marker[y][x]>1) capt++;
+ if(capt)
+ for(x=0; x<BOARD_WIDTH; x++) for(y=0; y<BOARD_HEIGHT; y++) if(marker[y][x] == 1) marker[y][x] = 0;
+ }
+ }
+ DrawPosition(TRUE, NULL);
+ }
+
void LeftClick(ClickType clickType, int xPix, int yPix)
{
int x, y;
String *params, Cardinal *num_params));
static void PieceMenuSelect P((Widget w, ChessSquare piece, caddr_t junk));
static void DropMenuSelect P((Widget w, ChessSquare piece, caddr_t junk));
-void ReadBitmap P((Pixmap *pm, String name, unsigned char bits[],
- u_int wreq, u_int hreq));
-void CreateGrid P((void));
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 HandleUserMove P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
void AnimateUserMove P((Widget w, XEvent * event,
String * params, Cardinal * nParams));
+ void HandlePV P((Widget w, XEvent * event,
+ String * params, Cardinal * nParams));
-void WhiteClock P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
-void BlackClock P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
-void DrawPositionProc P((Widget w, XEvent *event,
- String *prms, Cardinal *nprms));
-void XDrawPosition P((Widget w, /*Boolean*/int repaint,
- Board board));
void CommentPopUp P((char *title, char *label));
void CommentPopDown P((void));
void CommentCallback P((Widget w, XtPointer client_data,
void TimeControlPopDown P(());
void NewVariantPopDown P(());
void SettingsPopDown P(());
+void SetMenuEnables P((Enables *enab));
void update_ics_width P(());
int get_term_width P(());
+ int CopyMemoProc P(());
/*
* XBoard depends on Xt R4 or higher
*/
};
XtActionsRec boardActions[] = {
- { "DrawPosition", DrawPositionProc },
- { "HandleUserMove", HandleUserMove },
+ // { "HandleUserMove", HandleUserMove },
{ "AnimateUserMove", AnimateUserMove },
+ // { "FileNameAction", FileNameAction },
+ { "HandlePV", HandlePV },
+ { "UnLoadPV", UnLoadPV },
- { "FileNameAction", FileNameAction },
{ "AskQuestionProc", AskQuestionProc },
{ "AskQuestionReplyAction", AskQuestionReplyAction },
{ "PieceMenuPopup", PieceMenuPopup },
{ "TimeControlPopDown", (XtActionProc) TimeControlPopDown },
{ "NewVariantPopDown", (XtActionProc) NewVariantPopDown },
{ "SettingsPopDown", (XtActionProc) SettingsPopDown },
+ { "CopyMemoProc", (XtActionProc) CopyMemoProc },
};
-char globalTranslations[] =
- ":<Key>R: ResignProc() \n \
- :<Key>r: ResetProc() \n \
- :<Key>g: LoadGameProc() \n \
- :<Key>N: LoadNextGameProc() \n \
- :<Key>P: LoadPrevGameProc() \n \
- :<Key>Q: QuitProc() \n \
- :<Key>F: ToEndProc() \n \
- :<Key>f: ForwardProc() \n \
- :<Key>B: ToStartProc() \n \
- :<Key>b: BackwardProc() \n \
- :<Key>p: PauseProc() \n \
- :<Key>d: DrawProc() \n \
- :<Key>t: CallFlagProc() \n \
- :<Key>i: Iconify() \n \
- :<Key>c: Iconify() \n \
- :<Key>v: FlipViewProc() \n \
- <KeyDown>Control_L: BackwardProc() \n \
- <KeyUp>Control_L: ForwardProc() \n \
- <KeyDown>Control_R: BackwardProc() \n \
- <KeyUp>Control_R: ForwardProc() \n \
- Shift<Key>1: AskQuestionProc(\"Direct command\",\
- \"Send to chess program:\",,1) \n \
- Shift<Key>2: AskQuestionProc(\"Direct command\",\
- \"Send to second chess program:\",,2) \n";
-
-char boardTranslations[] =
- "<Btn1Down>: HandleUserMove() \n \
- <Btn1Up>: HandleUserMove() \n \
- <Btn1Motion>: AnimateUserMove() \n \
- <Btn3Motion>: HandlePV() \n \
- <Btn3Up>: UnLoadPV() \n \
- Shift<Btn2Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD)\
- PieceMenuPopup(menuB) \n \
- Any<Btn2Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD) \
- PieceMenuPopup(menuW) \n \
- Shift<Btn3Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD)\
- PieceMenuPopup(menuW) \n \
- Any<Btn3Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD) \
- PieceMenuPopup(menuB) \n";
-
-char whiteTranslations[] = "<BtnDown>: WhiteClock()\n";
-char blackTranslations[] = "<BtnDown>: BlackClock()\n";
++//char globalTranslations[] =
++// ":<Key>R: ResignProc() \n \
++// :<Key>r: ResetProc() \n \
++// :<Key>g: LoadGameProc() \n \
++// :<Key>N: LoadNextGameProc() \n \
++// :<Key>P: LoadPrevGameProc() \n \
++// :<Key>Q: QuitProc() \n \
++// :<Key>F: ToEndProc() \n \
++// :<Key>f: ForwardProc() \n \
++// :<Key>B: ToStartProc() \n \
++// :<Key>b: BackwardProc() \n \
++// :<Key>p: PauseProc() \n \
++// :<Key>d: DrawProc() \n \
++// :<Key>t: CallFlagProc() \n \
++// :<Key>i: Iconify() \n \
++// :<Key>c: Iconify() \n \
++// :<Key>v: FlipViewProc() \n \
++// <KeyDown>Control_L: BackwardProc() \n \
++// <KeyUp>Control_L: ForwardProc() \n \
++// <KeyDown>Control_R: BackwardProc() \n \
++// <KeyUp>Control_R: ForwardProc() \n \
++// Shift<Key>1: AskQuestionProc(\"Direct command\",\
++// \"Send to chess program:\",,1) \n \
++// Shift<Key>2: AskQuestionProc(\"Direct command\",\
++// \"Send to second chess program:\",,2) \n";
++//
++//char boardTranslations[] =
++// "<Btn1Down>: HandleUserMove() \n \
++// <Btn1Up>: HandleUserMove() \n \
++// <Btn1Motion>: AnimateUserMove() \n \
++// <Btn3Motion>: HandlePV() \n \
++// <Btn3Up>: UnLoadPV() \n \
++// Shift<Btn2Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD)\
++// PieceMenuPopup(menuB) \n \
++// Any<Btn2Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD) \
++// PieceMenuPopup(menuW) \n \
++// Shift<Btn3Down>: XawPositionSimpleMenu(menuW) XawPositionSimpleMenu(menuD)\
++// PieceMenuPopup(menuW) \n \
++// Any<Btn3Down>: XawPositionSimpleMenu(menuB) XawPositionSimpleMenu(menuD) \
++// PieceMenuPopup(menuB) \n";
++//
++//char whiteTranslations[] = "<BtnDown>: WhiteClock()\n";
++//char blackTranslations[] = "<BtnDown>: BlackClock()\n";
char ICSInputTranslations[] =
"<Key>Return: EnterKeyProc() \n";