示例#1
0
static int CASHook(const Manager::Key& key)
{
	if (key.IsEvent())
	{
		const KEY_EVENT_RECORD& rec=key.Event().Event.KeyEvent;
		if (rec.bKeyDown)
		{
			switch (rec.wVirtualKeyCode)
			{
				case VK_SHIFT:
				case VK_MENU:
				case VK_CONTROL:
				{
					const auto
						maskLeft=LEFT_CTRL_PRESSED|LEFT_ALT_PRESSED|SHIFT_PRESSED,
						maskRight=RIGHT_CTRL_PRESSED|RIGHT_ALT_PRESSED|SHIFT_PRESSED;
					auto state=rec.dwControlKeyState;
					auto wait=[](DWORD mask)
					{
						for (;;)
						{
							INPUT_RECORD rec;

							if (PeekInputRecord(&rec,true))
							{
								GetInputRecord(&rec,true,true);
								if ((rec.Event.KeyEvent.dwControlKeyState&mask) != mask)
									break;
							}

							Sleep(1);
						}
					};
					auto
						case1 = Global->Opt->CASRule&1 && (state&maskLeft) == maskLeft,
						case2 = Global->Opt->CASRule&2 && (state&maskRight) == maskRight;
					if (case1 || case2)
					{
						auto maskCurrent = case1?maskLeft:maskRight;
						const auto currentWindow = Global->WindowManager->GetCurrentWindow();
						if (currentWindow->CanFastHide())
						{
							int isPanelFocus=currentWindow->GetType() == windowtype_panels;

							if (isPanelFocus)
							{
								int LeftVisible=Global->CtrlObject->Cp()->LeftPanel->IsVisible();
								int RightVisible=Global->CtrlObject->Cp()->RightPanel->IsVisible();
								int CmdLineVisible=Global->CtrlObject->CmdLine()->IsVisible();
								int KeyBarVisible=Global->CtrlObject->Cp()->GetKeybar().IsVisible();
								Manager::ShowBackground();
								Global->CtrlObject->Cp()->LeftPanel->HideButKeepSaveScreen();
								Global->CtrlObject->Cp()->RightPanel->HideButKeepSaveScreen();

								switch (Global->Opt->PanelCtrlAltShiftRule)
								{
									case 0:
										if (CmdLineVisible)
											Global->CtrlObject->CmdLine()->Show();
										if (KeyBarVisible)
											Global->CtrlObject->Cp()->GetKeybar().Show();
										break;
									case 1:
										if (KeyBarVisible)
											Global->CtrlObject->Cp()->GetKeybar().Show();
										break;
								}

								wait(maskCurrent);

								if (LeftVisible)      Global->CtrlObject->Cp()->LeftPanel->Show();
								if (RightVisible)     Global->CtrlObject->Cp()->RightPanel->Show();
								if (CmdLineVisible)   Global->CtrlObject->CmdLine()->Show();
								if (KeyBarVisible)    Global->CtrlObject->Cp()->GetKeybar().Show();
							}
							else
							{
								Global->WindowManager->ImmediateHide();
								wait(maskCurrent);
							}

							Global->WindowManager->RefreshWindow();
						}

						return TRUE;
					}
					break;
				}
			}
		}
	}
	return FALSE;
}
示例#2
0
bool Search::ProcessKey(const Manager::Key& Key)
{
	auto LocalKey = Key;

	// для вставки воспользуемся макродвижком...
	if (LocalKey()==KEY_CTRLV || LocalKey()==KEY_RCTRLV || LocalKey()==KEY_SHIFTINS || LocalKey()==KEY_SHIFTNUMPAD0)
	{
		string ClipText;
		if (GetClipboardText(ClipText))
		{
			if (!ClipText.empty())
			{
				ProcessName(ClipText);
				ShowBorder();
			}
		}

		return true;
	}
	else if (LocalKey() == KEY_OP_XLAT)
	{
		m_FindEdit->Xlat();
		const auto strTempName = m_FindEdit->GetString();
		m_FindEdit->ClearString();
		ProcessName(strTempName);
		Redraw();
		return true;
	}
	else if (LocalKey() == KEY_OP_PLAINTEXT)
	{
		m_FindEdit->ProcessKey(LocalKey);
		const auto strTempName = m_FindEdit->GetString();
		m_FindEdit->ClearString();
		ProcessName(strTempName);
		Redraw();
		return true;
	}
	else
		LocalKey=_CorrectFastFindKbdLayout(Key.Event(),LocalKey());

	if (LocalKey()==KEY_ESC || LocalKey()==KEY_F10)
	{
		m_KeyToProcess=KEY_NONE;
		Close();
		return true;
	}

	// // _SVS(if (!FirstKey) SysLog(L"Panel::FastFind  Key=%s  %s",_FARKEY_ToName(Key),_INPUT_RECORD_Dump(&rec)));
	if (LocalKey()>=KEY_ALT_BASE+0x01 && LocalKey()<=KEY_ALT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_ALT_BASE));
	else if (LocalKey()>=KEY_RALT_BASE+0x01 && LocalKey()<=KEY_RALT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_RALT_BASE));

	if (LocalKey()>=KEY_ALTSHIFT_BASE+0x01 && LocalKey()<=KEY_ALTSHIFT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_ALTSHIFT_BASE));
	else if (LocalKey()>=KEY_RALTSHIFT_BASE+0x01 && LocalKey()<=KEY_RALTSHIFT_BASE+65535)
		LocalKey=lower(static_cast<WCHAR>(LocalKey()-KEY_RALTSHIFT_BASE));

	if (LocalKey()==KEY_MULTIPLY)
		LocalKey=L'*';

	switch (LocalKey())
	{
		case KEY_F1:
		{
			Hide();
			{
				Help::create(L"FastFind"sv);
			}
			Show();
			break;
		}
		case KEY_CTRLNUMENTER:   case KEY_RCTRLNUMENTER:
		case KEY_CTRLENTER:      case KEY_RCTRLENTER:
			m_Owner->FindPartName(m_FindEdit->GetString(), TRUE, 1);
			Redraw();
			break;
		case KEY_CTRLSHIFTNUMENTER:  case KEY_RCTRLSHIFTNUMENTER:
		case KEY_CTRLSHIFTENTER:     case KEY_RCTRLSHIFTENTER:
			m_Owner->FindPartName(m_FindEdit->GetString(), TRUE, -1);
			Redraw();
			break;
		case KEY_NONE:
		case KEY_IDLE:
			break;
		default:

			if ((LocalKey()<32 || LocalKey()>=65536) && LocalKey()!=KEY_BS && LocalKey()!=KEY_CTRLY && LocalKey()!=KEY_RCTRLY &&
			        LocalKey()!=KEY_CTRLBS && LocalKey()!=KEY_RCTRLBS && !IsModifKey(LocalKey()) &&
			        !(LocalKey()==KEY_CTRLINS||LocalKey()==KEY_CTRLNUMPAD0) && // KEY_RCTRLINS/NUMPAD0 passed to panels
			        !(LocalKey()==KEY_SHIFTINS||LocalKey()==KEY_SHIFTNUMPAD0) &&
			        !((LocalKey() == KEY_KILLFOCUS || LocalKey() == KEY_GOTFOCUS) && IsWindowsVistaOrGreater()) // Mantis #2903
			        )
			{
				m_KeyToProcess=LocalKey;
				Close();
				return true;
			}
			auto strLastName = m_FindEdit->GetString();
			if (m_FindEdit->ProcessKey(LocalKey))
			{
				auto strName = m_FindEdit->GetString();

				// уберем двойные '**'
				if (strName.size() > 1
				        && strName.back() == L'*'
				        && strName[strName.size()-2] == L'*')
				{
					strName.pop_back();
					m_FindEdit->SetString(strName);
				}

				/* $ 09.04.2001 SVS
				   проблемы с быстрым поиском.
				   Подробнее в 00573.ChangeDirCrash.txt
				*/
				if (starts_with(strName, L'"'))
				{
					strName.erase(0, 1);
					m_FindEdit->SetString(strName);
				}

				if (m_Owner->FindPartName(strName, FALSE, 1))
				{
					strLastName = strName;
				}
				else
				{
					if (Global->CtrlObject->Macro.IsExecuting())// && Global->CtrlObject->Macro.GetLevelState() > 0) // если вставка макросом...
					{
						//Global->CtrlObject->Macro.DropProcess(); // ... то дропнем макропроцесс
						//Global->CtrlObject->Macro.PopState();
						;
					}

					m_FindEdit->SetString(strLastName);
				}

				Redraw();
			}

			break;
	}
	return true;
}