X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwchat.c;h=3b90b2c3d8000dd838820a061baa466a800cf7f0;hb=b42a7598bf84b00ff82160234839d7b1c9f3f329;hp=b02e00e1c6c8562af871099a14889a29a43c561b;hpb=9f8e3f62352236d94f044b198a897488d404ed7e;p=xboard.git diff --git a/winboard/wchat.c b/winboard/wchat.c index b02e00e..3b90b2c 100644 --- a/winboard/wchat.c +++ b/winboard/wchat.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "common.h" #include "frontend.h" @@ -41,8 +42,10 @@ #include "wsnap.h" int chatCount; +static int onTop; extern char chatPartner[MAX_CHAT][MSG_SIZ]; HANDLE chatHandle[MAX_CHAT]; +static WNDPROC chatInputWindowProc; void SendToICS P((char *s)); void ChatPopUp P((char *s)); @@ -52,12 +55,16 @@ void ChatPopDown(); extern int opponentKibitzes; /* Imports from winboard.c */ +VOID SaveInHistory(char *cmd); +char *PrevInHistory(char *cmd); +char *NextInHistory(); extern HWND ChatDialog; extern HINSTANCE hInst; extern HWND hwndMain; extern WindowPlacement wpChat[MAX_CHAT]; +extern WindowPlacement wpConsole; extern BoardSize boardSize; @@ -132,6 +139,42 @@ static void InsertIntoMemo( HANDLE hDlg, char * text ) SendMessage( hMemo, EM_SCROLLCARET, 0, 0); } +LRESULT CALLBACK +InterceptArrowKeys(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + char buf[MSG_SIZ]; + char *p; + CHARRANGE sel; + + switch (message) { + case WM_KEYDOWN: // cloned from ConsoleInputSubClass() + switch (wParam) { + case VK_UP: + GetWindowText(hwnd, buf, MSG_SIZ); + p = PrevInHistory(buf); + if (p != NULL) { + SetWindowText(hwnd, p); + sel.cpMin = 999999; + sel.cpMax = 999999; + SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel); + return 0; + } + break; + case VK_DOWN: + p = NextInHistory(); + if (p != NULL) { + SetWindowText(hwnd, p); + sel.cpMin = 999999; + sel.cpMax = 999999; + SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM)&sel); + return 0; + } + break; + } + } + return (*chatInputWindowProc)(hwnd, message, wParam, lParam); +} + // This seems pure front end LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { @@ -139,6 +182,8 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam char buf[MSG_SIZ], mess[MSG_SIZ]; int partner = -1, i; static BOOL filterHasFocus[MAX_CHAT]; + WORD wMask; + HWND hMemo; for(i=0; ipartner), chatPartner[i]); + } else EnableWindow( GetDlgItem(hDlg, IDC_Focus1+i-(i>partner)), 1 ); + for(i=0; icode == EN_LINK) + { + ENLINK *pLink = (ENLINK*)lParam; + if (pLink->msg == WM_LBUTTONUP) + { + TEXTRANGE tr; + + tr.chrg = pLink->chrg; + tr.lpstrText = malloc(1+tr.chrg.cpMax-tr.chrg.cpMin); + SendMessage( GetDlgItem(hDlg, IDC_ChatMemo), EM_GETTEXTRANGE, 0, (LPARAM)&tr); + ShellExecute(NULL, "open", tr.lpstrText, NULL, NULL, SW_SHOW); + free(tr.lpstrText); + } + } + break; + case WM_COMMAND: /* [AS] @@ -198,12 +274,17 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam case IDC_Change: GetDlgItemText(hDlg, IDC_ChatPartner, chatPartner[partner], MSG_SIZ); + for(i=0; i= partner) i++; + onTop = i; + SetFocus(GetDlgItem(hDlg, IDC_Send)); + if(chatHandle[i]) { + int j; + for(j=0; j