1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
// PanelKey.cpp
#include "StdAfx.h"
#include "Panel.h"
#include "HelpUtils.h"
#include "../../PropID.h"
#include "App.h"
using namespace NWindows;
// #define kHelpTopic "FM/index.htm"
struct CVKeyPropIDPair
{
WORD VKey;
PROPID PropID;
};
static const CVKeyPropIDPair g_VKeyPropIDPairs[] =
{
{ VK_F3, kpidName },
{ VK_F4, kpidExtension },
{ VK_F5, kpidMTime },
{ VK_F6, kpidSize },
{ VK_F7, kpidNoProperty }
};
static int FindVKeyPropIDPair(WORD vKey)
{
for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_VKeyPropIDPairs); i++)
if (g_VKeyPropIDPairs[i].VKey == vKey)
return (int)i;
return -1;
}
bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
{
if (keyDownInfo->wVKey == VK_TAB && keyDownInfo->hdr.hwndFrom == _listView)
{
_panelCallback->OnTab();
return false;
}
const bool alt = IsKeyDown(VK_MENU);
const bool ctrl = IsKeyDown(VK_CONTROL);
// const bool leftCtrl = IsKeyDown(VK_LCONTROL);
const bool rightCtrl = IsKeyDown(VK_RCONTROL);
const bool shift = IsKeyDown(VK_SHIFT);
result = 0;
if (keyDownInfo->wVKey >= '0' &&
keyDownInfo->wVKey <= '9' &&
(rightCtrl || alt))
{
const unsigned index = (unsigned)(keyDownInfo->wVKey - '0');
if (shift)
{
SetBookmark(index);
return true;
}
else
{
OpenBookmark(index);
return true;
}
}
if ((keyDownInfo->wVKey == VK_F2 ||
keyDownInfo->wVKey == VK_F1)
&& alt && !ctrl && !shift)
{
_panelCallback->SetFocusToPath(keyDownInfo->wVKey == VK_F1 ? 0 : 1);
return true;
}
if ((keyDownInfo->wVKey == VK_F9) && !alt && !ctrl && !shift)
{
g_App.SwitchOnOffOnePanel();
}
if (keyDownInfo->wVKey >= VK_F3 && keyDownInfo->wVKey <= VK_F12 && ctrl)
{
const int index = FindVKeyPropIDPair(keyDownInfo->wVKey);
if (index >= 0)
SortItemsWithPropID(g_VKeyPropIDPairs[index].PropID);
}
switch (keyDownInfo->wVKey)
{
case VK_SHIFT:
{
_selectionIsDefined = false;
_prevFocusedItem = _listView.GetFocusedItem();
break;
}
/*
case VK_F1:
{
// ShowHelpWindow(NULL, kHelpTopic);
break;
}
*/
case VK_F2:
{
if (!alt && !ctrl &&!shift)
{
RenameFile();
return true;
}
break;
}
case VK_F3:
{
if (!alt && !ctrl && !shift)
{
EditItem(false);
return true;
}
break;
}
case VK_F4:
{
if (!alt && !ctrl && !shift)
{
EditItem(true);
return true;
}
if (!alt && !ctrl && shift)
{
CreateFile();
return true;
}
break;
}
case VK_F5:
{
if (!alt && !ctrl)
{
_panelCallback->OnCopy(false, shift);
return true;
}
break;
}
case VK_F6:
{
if (!alt && !ctrl)
{
_panelCallback->OnCopy(true, shift);
return true;
}
break;
}
case VK_F7:
{
if (!alt && !ctrl && !shift)
{
/* we can process F7 via menu ACCELERATOR.
But menu loading can be slow in case of UNC paths and system menu.
So we use don't use ACCELERATOR */
CreateFolder();
return true;
}
break;
}
case VK_DELETE:
{
DeleteItems(!shift);
return true;
}
case VK_INSERT:
{
if (!alt)
{
if (ctrl && !shift)
{
EditCopy();
return true;
}
if (shift && !ctrl)
{
EditPaste();
return true;
}
if (!shift && !ctrl && _mySelectMode)
{
OnInsert();
return true;
}
}
return false;
}
case VK_DOWN:
{
if (shift)
OnArrowWithShift();
return false;
}
case VK_UP:
{
if (alt)
_panelCallback->OnSetSameFolder();
else if (shift)
OnArrowWithShift();
return false;
}
case VK_RIGHT:
{
if (alt)
_panelCallback->OnSetSubFolder();
else if (shift)
OnArrowWithShift();
return false;
}
case VK_LEFT:
{
if (alt)
_panelCallback->OnSetSubFolder();
else if (shift)
OnArrowWithShift();
return false;
}
case VK_NEXT:
{
if (ctrl && !alt && !shift)
{
// EnterToFocused();
return true;
}
break;
}
case VK_ADD:
{
if (alt)
SelectByType(true);
else if (shift)
SelectAll(true);
else if (!ctrl)
SelectSpec(true);
return true;
}
case VK_SUBTRACT:
{
if (alt)
SelectByType(false);
else if (shift)
SelectAll(false);
else
SelectSpec(false);
return true;
}
/*
case VK_DELETE:
CommandDelete();
return 0;
case VK_F1:
CommandHelp();
return 0;
*/
case VK_BACK:
OpenParentFolder();
return true;
/*
case VK_DIVIDE:
case '\\':
case '/':
case VK_OEM_5:
{
// OpenRootFolder();
OpenDrivesFolder();
return true;
}
*/
case 'A':
if (ctrl)
{
SelectAll(true);
return true;
}
return false;
case 'X':
if (ctrl)
{
EditCut();
return true;
}
return false;
case 'C':
if (ctrl)
{
EditCopy();
return true;
}
return false;
case 'V':
if (ctrl)
{
EditPaste();
return true;
}
return false;
case 'N':
if (ctrl)
{
CreateFile();
return true;
}
return false;
case 'R':
if (ctrl)
{
OnReload();
return true;
}
return false;
case 'W':
if (ctrl)
{
// SendMessage();
PostMessage(g_HWND, WM_COMMAND, IDCLOSE, 0);
return true;
}
return false;
case 'Z':
if (ctrl)
{
ChangeComment();
return true;
}
return false;
case '1':
case '2':
case '3':
case '4':
if (ctrl)
{
const unsigned styleIndex = (unsigned)(keyDownInfo->wVKey - '1');
SetListViewMode(styleIndex);
return true;
}
return false;
case VK_MULTIPLY:
{
InvertSelection();
return true;
}
case VK_F12:
if (alt && !ctrl && !shift)
{
FoldersHistory();
return true;
}
}
return false;
}
|