int chatCount;\r
extern char chatPartner[MAX_CHAT][MSG_SIZ];\r
HANDLE chatHandle[MAX_CHAT];\r
+static WNDPROC chatInputWindowProc;\r
\r
void SendToICS P((char *s));\r
void ChatPopUp P((char *s));\r
extern int opponentKibitzes;\r
\r
/* Imports from winboard.c */\r
+VOID SaveInHistory(char *cmd);\r
+char *PrevInHistory(char *cmd);\r
+char *NextInHistory();\r
extern HWND ChatDialog;\r
\r
extern HINSTANCE hInst;\r
SendMessage( hMemo, EM_SCROLLCARET, 0, 0);\r
}\r
\r
+LRESULT CALLBACK\r
+InterceptArrowKeys(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)\r
+{\r
+ char buf[MSG_SIZ];\r
+ char *p;\r
+ CHARRANGE sel;\r
+\r
+ switch (message) {\r
+ case WM_KEYDOWN: // cloned from ConsoleInputSubClass()\r
+ switch (wParam) {\r
+ case VK_UP:\r
+ GetWindowText(hwnd, buf, MSG_SIZ);\r
+ p = PrevInHistory(buf);\r
+ if (p != NULL) {\r
+ SetWindowText(hwnd, p);\r
+ sel.cpMin = 999999;\r
+ sel.cpMax = 999999;\r
+ SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel);\r
+ return 0;\r
+ }\r
+ break;\r
+ case VK_DOWN:\r
+ p = NextInHistory();\r
+ if (p != NULL) {\r
+ SetWindowText(hwnd, p);\r
+ sel.cpMin = 999999;\r
+ sel.cpMax = 999999;\r
+ SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel);\r
+ return 0;\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ return (*chatInputWindowProc)(hwnd, message, wParam, lParam);\r
+}\r
+\r
// This seems pure front end\r
LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )\r
{\r
wMask = (WORD) SendMessage(hMemo, EM_GETEVENTMASK, 0, 0L);\r
SendMessage(hMemo, EM_SETEVENTMASK, 0, wMask | ENM_LINK);\r
SendMessage(hMemo, EM_AUTOURLDETECT, TRUE, 0L);\r
+ chatInputWindowProc = (WNDPROC) // cloned from ConsoleWndProc(). Assume they all share same proc.\r
+ SetWindowLong(GetDlgItem(hDlg, OPT_ChatInput), GWL_WNDPROC, (LONG) InterceptArrowKeys);\r
return FALSE;\r
\r
case WM_NOTIFY:\r
GetDlgItemText(hDlg, OPT_ChatInput, mess, MSG_SIZ);\r
SetDlgItemText(hDlg, OPT_ChatInput, "");\r
// from here on it could be back-end\r
+ SaveInHistory(mess);\r
if(!strcmp("WHISPER", chatPartner[partner]))\r
sprintf(buf, "whisper %s\n", mess); // WHISPER box uses "whisper" to send\r
else {\r