From: nethack.allison Date: Tue, 19 Mar 2002 22:37:22 +0000 (+0000) Subject: (from ) X-Git-Tag: MOVE2GIT~2929 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=184ce30dad07cd0864d003242b5af76144973338;p=nethack (from ) This implements some items on the ToDo list: - H0005: Space does the same as PgDn in text, menu and 'menutext' windows if NetHack mode is on. - M0004: The cursor (caret) is hidden in text windows and menu windows. PgUp/PgDn/Up/Dn don't move the cursor, but scroll the window. --- diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index dbf5d187e..d222e0ca0 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -306,6 +306,14 @@ BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) data->done = 1; data->result = 0; return TRUE; + + case IDC_MENU_TEXT: + switch (HIWORD(wParam)) + { + case EN_SETFOCUS: + HideCaret((HWND)lParam); + return TRUE; + } } } break; @@ -1012,23 +1020,33 @@ BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch) return -2; case ' ': - /* ends menu for PICK_ONE/PICK_NONE - select item for PICK_ANY */ - if( data->how==PICK_ONE || data->how==PICK_NONE ) { - data->done = 1; - data->result = 0; - return -2; - } else if( data->how==PICK_ANY ) { - i = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED); - if( i>=0 ) { - SelectMenuItem( - hwndList, - data, - i, - NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1 - ); - } - } + if (GetNHApp()->regNetHackMode) { + /* NetHack mode: Scroll down one page */ + topIndex = ListView_GetTopIndex( hwndList ); + pageSize = ListView_GetCountPerPage( hwndList ); + i = min(topIndex+pageSize, data->menu.size-1); + ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED); + ListView_EnsureVisible(hwndList, i, FALSE); + return -2; + } else { + /* Windows mode: ends menu for PICK_ONE/PICK_NONE + select item for PICK_ANY */ + if( data->how==PICK_ONE || data->how==PICK_NONE ) { + data->done = 1; + data->result = 0; + return -2; + } else if( data->how==PICK_ANY ) { + i = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED); + if( i>=0 ) { + SelectMenuItem( + hwndList, + data, + i, + NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1 + ); + } + } + } break; default: @@ -1270,15 +1288,35 @@ LRESULT CALLBACK NHMenuListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA return 0; } /*-----------------------------------------------------------------------------*/ -/* Text control window proc - implements close on space */ +/* Text control window proc - implements scrolling without a cursor */ LRESULT CALLBACK NHMenuTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { - /* close on space */ case WM_KEYDOWN: - if( wParam==VK_SPACE ) { - PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0), 0); + switch (wParam) + { + /* close on space in Windows mode + page down on space in NetHack mode */ + case VK_SPACE: + if (GetNHApp()->regNetHackMode) + SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0); + else + PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0), 0); + return 0; + case VK_NEXT: + SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0); + return 0; + case VK_PRIOR: + SendMessage(hWnd, EM_SCROLL, SB_PAGEUP, 0); + return 0; + case VK_UP: + SendMessage(hWnd, EM_SCROLL, SB_LINEUP, 0); + return 0; + case VK_DOWN: + SendMessage(hWnd, EM_SCROLL, SB_LINEDOWN, 0); + return 0; + } break; diff --git a/win/win32/mhtext.c b/win/win32/mhtext.c index 9ef7db9ea..d54875666 100644 --- a/win/win32/mhtext.c +++ b/win/win32/mhtext.c @@ -125,6 +125,13 @@ BOOL CALLBACK NHTextWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara DestroyWindow(hWnd); SetFocus(GetNHApp()->hMainWnd); return TRUE; + case IDC_TEXT_CONTROL: + switch (HIWORD(wParam)) + { + case EN_SETFOCUS: + HideCaret((HWND)lParam); + return TRUE; + } } break; @@ -203,13 +210,32 @@ LRESULT CALLBACK NHEditHookWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA { switch(message) { - /* close on space */ case WM_KEYDOWN: - if( wParam==VK_SPACE ) { - PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0), 0); + switch (wParam) + { + /* close on space in Windows mode + page down on space in NetHack mode */ + case VK_SPACE: + if (GetNHApp()->regNetHackMode) + SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0); + else + PostMessage(GetParent(hWnd), WM_COMMAND, MAKELONG(IDOK, 0), 0); + return 0; + case VK_NEXT: + SendMessage(hWnd, EM_SCROLL, SB_PAGEDOWN, 0); + return 0; + case VK_PRIOR: + SendMessage(hWnd, EM_SCROLL, SB_PAGEUP, 0); + return 0; + case VK_UP: + SendMessage(hWnd, EM_SCROLL, SB_LINEUP, 0); + return 0; + case VK_DOWN: + SendMessage(hWnd, EM_SCROLL, SB_LINEDOWN, 0); + return 0; + } break; - } if( editControlWndProc )