1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Ctrl+Left/Right/Back work better on Raw Site Settings dialog

Source commit: 818144f12f28cd6ae1094e60f588c639bc851202
This commit is contained in:
Martin Prikryl
2019-12-18 17:53:59 +00:00
parent 73efbd0daf
commit eaa96d43f3
2 changed files with 49 additions and 33 deletions

View File

@@ -1437,6 +1437,9 @@ public:
bool __fastcall Execute(TSessionData * Data);
protected:
DYNAMIC void __fastcall DoShow();
private:
TMemo * SettingsMemo;
@@ -1464,6 +1467,12 @@ __fastcall TSiteRawDialog::TSiteRawDialog() :
AddDialogButton(AddButton);
}
//---------------------------------------------------------------------------
void __fastcall TSiteRawDialog::DoShow()
{
TCustomDialog::DoShow();
InstallPathWordBreakProc(SettingsMemo);
}
//---------------------------------------------------------------------------
bool __fastcall TSiteRawDialog::Execute(TSessionData * Data)
{
std::unique_ptr<TSessionData> FactoryDefaults(new TSessionData(L""));

View File

@@ -1414,7 +1414,7 @@ TAutoSwitch __fastcall CheckBoxAutoSwitchSave(TCheckBox * CheckBox)
}
}
//---------------------------------------------------------------------------
static const wchar_t PathWordDelimiters[] = L"\\/ ;,.";
static const wchar_t PathWordDelimiters[] = L"\\/ ;,.\r\n=";
//---------------------------------------------------------------------------
static bool IsPathWordDelimiter(wchar_t Ch)
{
@@ -1483,39 +1483,50 @@ int CALLBACK PathWordBreakProc(wchar_t * Ch, int Current, int Len, int Code)
return Result;
}
//---------------------------------------------------------------------------
static void __fastcall PathEditKeyPress(void * /*Data*/, TObject * Sender, char & Key)
static void __fastcall PathWordBreakEditWindowProc(void * Data, TMessage & Message)
{
// Ctrl+Backspace
// Have to use OnKeyPress as the Ctrl+Backspace is handled in WM_CHAR as any other char,
// so we have to swallow it here to prevent it getting inserted to the text
if (Key == '\x7F')
TCustomEdit * Edit = static_cast<TCustomEdit *>(Data);
if (Message.Msg == WM_CHAR)
{
Key = '\0';
TCustomEdit * Edit = dynamic_cast<TCustomEdit *>(Sender);
TCustomComboBox * ComboBox = dynamic_cast<TCustomComboBox *>(Sender);
TWinControl * WinControl = DebugNotNull(dynamic_cast<TWinControl *>(Sender));
if (((Edit != NULL) && (Edit->SelLength == 0)) ||
((ComboBox != NULL) && (ComboBox->SelLength == 0)))
// Ctrl+Backspace
// Ctrl+Backspace is handled in WM_CHAR as any other char,
// so we have to swallow it here to prevent it getting inserted to the text
TWMChar & CharMessage = *reinterpret_cast<TWMChar *>(&Message);
if (CharMessage.CharCode == '\x7F')
{
// See TCustomMaskEdit.SetCursor
TKeyboardState KeyState;
GetKeyboardState(KeyState);
TKeyboardState NewKeyState;
memset(NewKeyState, 0, sizeof(NewKeyState));
NewKeyState[VK_CONTROL] = 0x81;
NewKeyState[VK_SHIFT] = 0x81;
SetKeyboardState(NewKeyState);
TCustomComboBox * ComboBox = static_cast<TCustomComboBox *>(Data);
TWinControl * WinControl = static_cast<TWinControl *>(Data);
SendMessage(WinControl->Handle, WM_KEYDOWN, VK_LEFT, 1);
NewKeyState[VK_SHIFT] = 0;
NewKeyState[VK_CONTROL] = 0;
SetKeyboardState(NewKeyState);
if (((Edit != NULL) && (Edit->SelLength == 0)) ||
((ComboBox != NULL) && (ComboBox->SelLength == 0)))
{
// See TCustomMaskEdit.SetCursor
TKeyboardState KeyState;
GetKeyboardState(KeyState);
TKeyboardState NewKeyState;
memset(NewKeyState, 0, sizeof(NewKeyState));
NewKeyState[VK_CONTROL] = 0x81;
NewKeyState[VK_SHIFT] = 0x81;
SetKeyboardState(NewKeyState);
SendMessage(WinControl->Handle, WM_KEYDOWN, VK_DELETE, 1);
SetKeyboardState(KeyState);
SendMessage(Edit->Handle, WM_KEYDOWN, VK_LEFT, 1);
NewKeyState[VK_SHIFT] = 0;
NewKeyState[VK_CONTROL] = 0;
SetKeyboardState(NewKeyState);
SendMessage(Edit->Handle, WM_KEYDOWN, VK_DELETE, 1);
SetKeyboardState(KeyState);
}
Message.Result = 1;
}
else
{
ControlWndProc(Edit)(Message);
}
}
else
{
ControlWndProc(Edit)(Message);
}
}
//---------------------------------------------------------------------------
@@ -1544,11 +1555,7 @@ void __fastcall InstallPathWordBreakProc(TWinControl * Control)
}
SendMessage(Wnd, EM_SETWORDBREAKPROC, 0, (LPARAM)(EDITWORDBREAKPROC)PathWordBreakProc);
TPublicWinControl * PublicWinControl = static_cast<TPublicWinControl *>(Control);
if (DebugAlwaysTrue(PublicWinControl->OnKeyDown == NULL))
{
PublicWinControl->OnKeyPress = MakeMethod<TKeyPressEvent>(NULL, PathEditKeyPress);
}
Control->WindowProc = MakeMethod<TWndMethod>(Control, PathWordBreakEditWindowProc);
}
//---------------------------------------------------------------------------
static void __fastcall RemoveHiddenControlsFromOrder(TControl ** ControlsOrder, int & Count)