Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek shellext: added function to get current directory in keyboard handler

Changeset 0b8f7055dad4

Parent cf4b87c14212

by David Golub

Changes to 3 files · Browse files at 0b8f7055dad4 Showing diff from parent cf4b87c14212 Diff from another changeset...

 
17
18
19
 
20
21
22
 
75
76
77
 
 
78
79
80
 
131
132
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
135
136
 
17
18
19
20
21
22
23
 
76
77
78
79
80
81
82
83
 
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
@@ -17,6 +17,7 @@
 #include "THgShell_h.h"    #include "TortoiseHgKeyboard.h" +#include "TortoiseUtils.h"    // Each Windows Explorer window is launched in a separate thread. Therefore, use thread  // local storage so that each thread can have its own hook. @@ -75,6 +76,8 @@
  {   CAtlList<CString> listFiles;   g_pObject->GetSelectedFiles(listFiles); + CString strFolder; + g_pObject->GetFolder(strFolder);   }   }   } @@ -131,6 +134,27 @@
  return true;  }   +#define FILE_PREFIX "file:///" +#define FILE_PREFIX_LENGTH (sizeof(FILE_PREFIX) / sizeof(TCHAR) - 1) + +bool CTortoiseHgKeyboard::GetFolder(CString& strFolder) +{ + // Get the URL of the current location. + CComQIPtr<IWebBrowser2> spWB = m_spUnkSite; + if (spWB == NULL) return false; + BSTR bstrURL; + if (FAILED(spWB->get_LocationURL(&bstrURL))) return false; + strFolder = bstrURL; + ::SysFreeString(bstrURL); + + // Check if it's a file URL and extract the path. + if (StartsWith(strFolder, FILE_PREFIX)) + { + strFolder = strFolder.Mid(FILE_PREFIX_LENGTH); + } + return true; +} +  CTortoiseHgKeyboard::CTortoiseHgKeyboard() :   m_hHook(NULL)  {
 
39
40
41
 
42
43
44
 
39
40
41
42
43
44
45
@@ -39,6 +39,7 @@
 private:   bool GetActiveShellView(IShellView** ppSV);   bool GetSelectedFiles(CAtlList<CString>& listFiles); + bool GetFolder(CString& strFolder);     static LRESULT CALLBACK HookProc(int code, WPARAM wParam, LPARAM lParam);  };
 
26
27
28
 
29
 
26
27
28
29
30
@@ -26,4 +26,5 @@
 #include <atlcom.h>  #include <atlstr.h>  #include <atlcoll.h> +#include <atlutil.h>  #include <shlobj.h>