XKeymacs for 64bit Windows
Revision | 3f468d8e8144ce2a64a399c0482c204957327127 (tree) |
---|---|
Time | 2011-05-28 16:58:28 |
Author | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
Support recent versions of Microsoft Visual Studio.
Fix a bug where M-v doesn't work at first time on Visual Studio
2010. Fix a bug where C-g releases the control key on recent
versions of Visual Studio. Support the incremental search on them.
@@ -330,6 +330,8 @@ void CCommands::Kdu(BYTE bVk1, BYTE bVk2, BYTE bVk3, BYTE bVk4) | ||
330 | 330 | ReleaseKey(VK_CONTROL); |
331 | 331 | } |
332 | 332 | if (bIsAltDown) { |
333 | + if (CUtils::IsVisualStudio2010()) | |
334 | + CXkeymacsDll::SetHookAltRelease(); // Ignore Alt release | |
333 | 335 | ReleaseKey(VK_MENU); |
334 | 336 | } |
335 | 337 | if (bIsShiftDown) { |
@@ -1463,9 +1465,14 @@ DWORD CCommands::DeactivateMark() | ||
1463 | 1465 | AdKduAu('E', 'I'); |
1464 | 1466 | return ERROR_SUCCESS; // i.e. return 0; |
1465 | 1467 | } |
1466 | - if (CUtils::IsVisualStudioDotNet()) { // Ctrl + Click select a word on Visual Studio .NET | |
1467 | - ReleaseKey(VK_CONTROL); | |
1468 | - return ClickCaret(); | |
1468 | + if (CUtils::IsVisualStudio()) { // Ctrl + Click select a word on Visual Studio .NET | |
1469 | + BOOL bIsCtrlDown = CXkeymacsDll::IsDown(VK_CONTROL, FALSE); | |
1470 | + if (bIsCtrlDown) | |
1471 | + ReleaseKey(VK_CONTROL); | |
1472 | + DWORD res = ClickCaret(); | |
1473 | + if (bIsCtrlDown) | |
1474 | + DepressKey(VK_CONTROL); | |
1475 | + return res; | |
1469 | 1476 | } |
1470 | 1477 | |
1471 | 1478 | return ClickCaret(); |
@@ -1478,7 +1485,7 @@ int CCommands::FindFile() | ||
1478 | 1485 | if (CUtils::IsFlash() |
1479 | 1486 | || CUtils::IsSleipnir()) { |
1480 | 1487 | CdKduCu('O'); |
1481 | - } else if (CUtils::IsVisualStudioDotNet()) { | |
1488 | + } else if (CUtils::IsVisualStudio()) { | |
1482 | 1489 | AdKduAu('F', 'O', 'F'); |
1483 | 1490 | } else { |
1484 | 1491 | AdKduAu('F', 'O'); |
@@ -2463,7 +2470,7 @@ void CCommands::OpenFindDialog() | ||
2463 | 2470 | AdKduAu('S', VK_RETURN); |
2464 | 2471 | } else if (CUtils::IsNami2000()) { |
2465 | 2472 | AdKduAu('D', 'F'); |
2466 | - } else if (CUtils::IsVisualStudioDotNet()) { | |
2473 | + } else if (CUtils::IsVisualStudio()) { | |
2467 | 2474 | AdKduAu('E', 'F', 'F'); |
2468 | 2475 | } else if (CUtils::IsDirector()) { |
2469 | 2476 | AdKduAu('E', 'F', 'T'); |
@@ -2536,7 +2543,7 @@ int CCommands::Search(SEARCH_DIRECTION direction) | ||
2536 | 2543 | } |
2537 | 2544 | |
2538 | 2545 | if (CUtils::IsVisualCpp() |
2539 | - || CUtils::IsVisualStudioDotNet()) { | |
2546 | + || CUtils::IsVisualStudio()) { | |
2540 | 2547 | switch (direction) { |
2541 | 2548 | case FORWARD: |
2542 | 2549 | CdKduCu('I'); |
@@ -3185,7 +3192,7 @@ BYTE CCommands::GetDirectionForwardKey() | ||
3185 | 3192 | || CUtils::IsOpenJane() |
3186 | 3193 | || CUtils::IsStoryEditor() |
3187 | 3194 | || CUtils::IsVisualBasicEditor() |
3188 | - || CUtils::IsVisualStudioDotNet() | |
3195 | + || CUtils::IsVisualStudio() | |
3189 | 3196 | || CUtils::IsWordpad()) { |
3190 | 3197 | bDirectionForward = 0; |
3191 | 3198 | } else if (CUtils::IsLotusNotes() |
@@ -752,9 +752,23 @@ BOOL CUtils::IsCsh() | ||
752 | 752 | return !_tcsicmp(m_szApplicationName, _T("csh.exe")); |
753 | 753 | } |
754 | 754 | |
755 | -BOOL CUtils::IsVisualStudioDotNet() | |
755 | +BOOL CUtils::IsVisualStudio() | |
756 | 756 | { |
757 | - return !_tcsicmp(m_szApplicationName, _T("devenv.exe")); | |
757 | + if (IsVisualCpp() || CUtils::IsVisualBasic()) | |
758 | + return FALSE; | |
759 | + TCHAR szWindowText[WINDOW_TEXT_LENGTH] = _T(""); | |
760 | + GetWindowText(GetForegroundWindow(), szWindowText, sizeof(szWindowText)); | |
761 | + return _tcsstr(szWindowText, _T(" - Microsoft Visual ")) != NULL; | |
762 | +} | |
763 | + | |
764 | +BOOL CUtils::IsVisualStudio2010() | |
765 | +{ | |
766 | + if (IsVisualStudio()) { | |
767 | + TCHAR szWindowText[WINDOW_TEXT_LENGTH] = _T(""); | |
768 | + GetWindowText(GetForegroundWindow(), szWindowText, sizeof(szWindowText)); | |
769 | + return _tcsstr(szWindowText, _T("2010")) != NULL; | |
770 | + } | |
771 | + return FALSE; | |
758 | 772 | } |
759 | 773 | |
760 | 774 | BOOL CUtils::IsAccess() |
@@ -63,7 +63,8 @@ public: | ||
63 | 63 | static BOOL IsVisualBasic(); |
64 | 64 | static BOOL IsProject(); |
65 | 65 | static BOOL IsAccess(); |
66 | - static BOOL IsVisualStudioDotNet(); | |
66 | + static BOOL IsVisualStudio(); | |
67 | + static BOOL IsVisualStudio2010(); | |
67 | 68 | static BOOL IsCsh(); |
68 | 69 | static BOOL IsSh(); |
69 | 70 | static BOOL IsBash(); |
@@ -196,6 +196,7 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) | ||
196 | 196 | |
197 | 197 | #include "xkeymacsDll.h" |
198 | 198 | #pragma data_seg(".xkmcs") |
199 | + BOOL CXkeymacsDll::m_bHookAltRelease = FALSE; | |
199 | 200 | BOOL CXkeymacsDll::m_bEnableKeyboardHook = FALSE; |
200 | 201 | HHOOK CXkeymacsDll::m_hHookCallWnd = NULL; |
201 | 202 | HHOOK CXkeymacsDll::m_hHookCallWndRet = NULL; |
@@ -266,6 +267,11 @@ BOOL CXkeymacsDll::LoadConfig() | ||
266 | 267 | return res; |
267 | 268 | } |
268 | 269 | |
270 | +void CXkeymacsDll::SetHookAltRelease() | |
271 | +{ | |
272 | + m_bHookAltRelease = TRUE; | |
273 | +} | |
274 | + | |
269 | 275 | // set hooks |
270 | 276 | void CXkeymacsDll::SetHooks() |
271 | 277 | { |
@@ -816,21 +822,26 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
816 | 822 | } |
817 | 823 | |
818 | 824 | if (lParam & BEING_RELEASED) { |
819 | - if (nKey == VK_MENU | |
820 | - || nKey == VK_LWIN | |
821 | - || nKey == VK_RWIN | |
822 | - || nKey == VK_APPS | |
823 | - || nKey == VK_LMENU | |
824 | - || nKey == VK_RMENU) { | |
825 | - for (int i = 0; i < MAX_COMMAND_TYPE; ++i) { | |
826 | - if (Commands[m_Config.nCommandID[m_nApplicationID][i][nKey]].fCommand | |
827 | - && (Commands[m_Config.nCommandID[m_nApplicationID][i][nKey]].fCommand != CCommands::MetaAlt | |
828 | - || nKey != VK_MENU && nKey != VK_LMENU && nKey != VK_RMENU)) { | |
825 | + BOOL bAlt = FALSE; | |
826 | + switch (nKey) { | |
827 | + case VK_MENU: | |
828 | + case VK_LMENU: | |
829 | + case VK_RMENU: | |
830 | + bAlt = TRUE; | |
831 | + if (m_bHookAltRelease) { | |
832 | + m_bHookAltRelease = FALSE; | |
833 | + goto HOOK; | |
834 | + } | |
835 | + // pass through | |
836 | + case VK_LWIN: | |
837 | + case VK_RWIN: | |
838 | + case VK_APPS: | |
839 | + for (int i = 0; i < MAX_COMMAND_TYPE; i++) { | |
840 | + int (*func)() = Commands[m_Config.nCommandID[m_nApplicationID][i][nKey]].fCommand; | |
841 | + if (func && !(bAlt && func == CCommands::MetaAlt)) | |
829 | 842 | goto HOOK; |
830 | - } | |
831 | 843 | } |
832 | 844 | } |
833 | - | |
834 | 845 | if (nOneShotModifier[nKey]) { |
835 | 846 | ReleaseKey(nOneShotModifier[nKey]); |
836 | 847 | nOneShotModifier[nKey] = 0; |
@@ -840,7 +851,6 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa | ||
840 | 851 | Kdu(nKey); |
841 | 852 | } |
842 | 853 | } |
843 | - | |
844 | 854 | goto DO_NOTHING; |
845 | 855 | } |
846 | 856 |
@@ -56,6 +56,7 @@ public: | ||
56 | 56 | static BOOL SaveConfig(); |
57 | 57 | static BOOL LoadConfig(); |
58 | 58 | static void SetM_xTip(const TCHAR *const szPath); |
59 | + static void SetHookAltRelease(); | |
59 | 60 | static BOOL Get326Compatible(); |
60 | 61 | static void Set326Compatible(int nApplicationID, BOOL b326Compatible); |
61 | 62 | static void SetCursorData(HCURSOR hEnable, HCURSOR hDisableTMP, HCURSOR hDisableWOCQ, HICON hDisable, BOOL bEnable); |
@@ -101,6 +102,7 @@ public: | ||
101 | 102 | CXkeymacsDll(); |
102 | 103 | virtual ~CXkeymacsDll(); |
103 | 104 | private: |
105 | + static BOOL m_bHookAltRelease; | |
104 | 106 | static TCHAR m_M_xTip[128]; |
105 | 107 | static void InvokeM_x(const TCHAR* const szPath); |
106 | 108 | static void LogCallWndProcMessage(WPARAM wParam, LPARAM lParam); |