• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

XKeymacs for 64bit Windows


Commit MetaInfo

Revision3f468d8e8144ce2a64a399c0482c204957327127 (tree)
Time2011-05-28 16:58:28
AuthorKazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Log Message

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.

Change Summary

Incremental Difference

--- a/xkeymacsdll/Commands.cpp
+++ b/xkeymacsdll/Commands.cpp
@@ -330,6 +330,8 @@ void CCommands::Kdu(BYTE bVk1, BYTE bVk2, BYTE bVk3, BYTE bVk4)
330330 ReleaseKey(VK_CONTROL);
331331 }
332332 if (bIsAltDown) {
333+ if (CUtils::IsVisualStudio2010())
334+ CXkeymacsDll::SetHookAltRelease(); // Ignore Alt release
333335 ReleaseKey(VK_MENU);
334336 }
335337 if (bIsShiftDown) {
@@ -1463,9 +1465,14 @@ DWORD CCommands::DeactivateMark()
14631465 AdKduAu('E', 'I');
14641466 return ERROR_SUCCESS; // i.e. return 0;
14651467 }
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;
14691476 }
14701477
14711478 return ClickCaret();
@@ -1478,7 +1485,7 @@ int CCommands::FindFile()
14781485 if (CUtils::IsFlash()
14791486 || CUtils::IsSleipnir()) {
14801487 CdKduCu('O');
1481- } else if (CUtils::IsVisualStudioDotNet()) {
1488+ } else if (CUtils::IsVisualStudio()) {
14821489 AdKduAu('F', 'O', 'F');
14831490 } else {
14841491 AdKduAu('F', 'O');
@@ -2463,7 +2470,7 @@ void CCommands::OpenFindDialog()
24632470 AdKduAu('S', VK_RETURN);
24642471 } else if (CUtils::IsNami2000()) {
24652472 AdKduAu('D', 'F');
2466- } else if (CUtils::IsVisualStudioDotNet()) {
2473+ } else if (CUtils::IsVisualStudio()) {
24672474 AdKduAu('E', 'F', 'F');
24682475 } else if (CUtils::IsDirector()) {
24692476 AdKduAu('E', 'F', 'T');
@@ -2536,7 +2543,7 @@ int CCommands::Search(SEARCH_DIRECTION direction)
25362543 }
25372544
25382545 if (CUtils::IsVisualCpp()
2539- || CUtils::IsVisualStudioDotNet()) {
2546+ || CUtils::IsVisualStudio()) {
25402547 switch (direction) {
25412548 case FORWARD:
25422549 CdKduCu('I');
@@ -3185,7 +3192,7 @@ BYTE CCommands::GetDirectionForwardKey()
31853192 || CUtils::IsOpenJane()
31863193 || CUtils::IsStoryEditor()
31873194 || CUtils::IsVisualBasicEditor()
3188- || CUtils::IsVisualStudioDotNet()
3195+ || CUtils::IsVisualStudio()
31893196 || CUtils::IsWordpad()) {
31903197 bDirectionForward = 0;
31913198 } else if (CUtils::IsLotusNotes()
--- a/xkeymacsdll/Utils.cpp
+++ b/xkeymacsdll/Utils.cpp
@@ -752,9 +752,23 @@ BOOL CUtils::IsCsh()
752752 return !_tcsicmp(m_szApplicationName, _T("csh.exe"));
753753 }
754754
755-BOOL CUtils::IsVisualStudioDotNet()
755+BOOL CUtils::IsVisualStudio()
756756 {
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;
758772 }
759773
760774 BOOL CUtils::IsAccess()
--- a/xkeymacsdll/Utils.h
+++ b/xkeymacsdll/Utils.h
@@ -63,7 +63,8 @@ public:
6363 static BOOL IsVisualBasic();
6464 static BOOL IsProject();
6565 static BOOL IsAccess();
66- static BOOL IsVisualStudioDotNet();
66+ static BOOL IsVisualStudio();
67+ static BOOL IsVisualStudio2010();
6768 static BOOL IsCsh();
6869 static BOOL IsSh();
6970 static BOOL IsBash();
--- a/xkeymacsdll/xkeymacsdll.cpp
+++ b/xkeymacsdll/xkeymacsdll.cpp
@@ -196,6 +196,7 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
196196
197197 #include "xkeymacsDll.h"
198198 #pragma data_seg(".xkmcs")
199+ BOOL CXkeymacsDll::m_bHookAltRelease = FALSE;
199200 BOOL CXkeymacsDll::m_bEnableKeyboardHook = FALSE;
200201 HHOOK CXkeymacsDll::m_hHookCallWnd = NULL;
201202 HHOOK CXkeymacsDll::m_hHookCallWndRet = NULL;
@@ -266,6 +267,11 @@ BOOL CXkeymacsDll::LoadConfig()
266267 return res;
267268 }
268269
270+void CXkeymacsDll::SetHookAltRelease()
271+{
272+ m_bHookAltRelease = TRUE;
273+}
274+
269275 // set hooks
270276 void CXkeymacsDll::SetHooks()
271277 {
@@ -816,21 +822,26 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa
816822 }
817823
818824 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))
829842 goto HOOK;
830- }
831843 }
832844 }
833-
834845 if (nOneShotModifier[nKey]) {
835846 ReleaseKey(nOneShotModifier[nKey]);
836847 nOneShotModifier[nKey] = 0;
@@ -840,7 +851,6 @@ LRESULT CALLBACK CXkeymacsDll::KeyboardProc(int nCode, WPARAM wParam, LPARAM lPa
840851 Kdu(nKey);
841852 }
842853 }
843-
844854 goto DO_NOTHING;
845855 }
846856
--- a/xkeymacsdll/xkeymacsdll.h
+++ b/xkeymacsdll/xkeymacsdll.h
@@ -56,6 +56,7 @@ public:
5656 static BOOL SaveConfig();
5757 static BOOL LoadConfig();
5858 static void SetM_xTip(const TCHAR *const szPath);
59+ static void SetHookAltRelease();
5960 static BOOL Get326Compatible();
6061 static void Set326Compatible(int nApplicationID, BOOL b326Compatible);
6162 static void SetCursorData(HCURSOR hEnable, HCURSOR hDisableTMP, HCURSOR hDisableWOCQ, HICON hDisable, BOOL bEnable);
@@ -101,6 +102,7 @@ public:
101102 CXkeymacsDll();
102103 virtual ~CXkeymacsDll();
103104 private:
105+ static BOOL m_bHookAltRelease;
104106 static TCHAR m_M_xTip[128];
105107 static void InvokeM_x(const TCHAR* const szPath);
106108 static void LogCallWndProcMessage(WPARAM wParam, LPARAM lParam);