From 4746e4340fd479a3c7e22c3ba9b6611d3fd702de Mon Sep 17 00:00:00 2001 From: ASU Date: Mon, 18 Sep 2023 00:43:27 +0300 Subject: [PATCH 1/2] Added switch terminal input mode HotKey --- src/ConEmu/ConEmu.cpp | 12 ++++++++++++ src/ConEmu/ConEmu.h | 1 + src/ConEmu/ConEmuCtrl.cpp | 8 ++++++++ src/ConEmu/ConEmuCtrl.h | 1 + src/ConEmu/HotkeyList.cpp | 2 ++ src/ConEmu/LngDataHints.h | 1 + src/ConEmu/resource.h | 1 + 7 files changed, 26 insertions(+) diff --git a/src/ConEmu/ConEmu.cpp b/src/ConEmu/ConEmu.cpp index 4404a0bf2..890ffc776 100644 --- a/src/ConEmu/ConEmu.cpp +++ b/src/ConEmu/ConEmu.cpp @@ -2610,6 +2610,18 @@ CConEmuMain::~CConEmuMain() } #endif +void CConEmuMain::AskChangeTermMode() +{ + CVConGuard VCon; + if (GetActiveVCon(&VCon) < 0) + return; + CVirtualConsole *pVCon = VCon.VCon(); + CRealConsole *pRCon = pVCon->RCon(); + if (!pRCon) return; + + pRCon ->StartStopTermMode(tmc_TerminalType, cta_Switch); +} + void CConEmuMain::AskChangeBufferHeight() { CVConGuard VCon; diff --git a/src/ConEmu/ConEmu.h b/src/ConEmu/ConEmu.h index b457d8fd5..6c7782187 100644 --- a/src/ConEmu/ConEmu.h +++ b/src/ConEmu/ConEmu.h @@ -597,6 +597,7 @@ class CConEmuMain int ActiveConNum(); // 0-based int GetConCount(); // количество открытых консолей void AskChangeBufferHeight(); + void AskChangeTermMode(); void AskChangeAlternative(); void AttachToDialog(); void CheckFocus(LPCWSTR asFrom); diff --git a/src/ConEmu/ConEmuCtrl.cpp b/src/ConEmu/ConEmuCtrl.cpp index d07c80f47..c83c7be26 100644 --- a/src/ConEmu/ConEmuCtrl.cpp +++ b/src/ConEmu/ConEmuCtrl.cpp @@ -525,6 +525,14 @@ bool CConEmuCtrl::key_MultiBuffer(const ConEmuChord& VkState, bool TestOnly, con return true; } +// pRCon may be nullptr +bool CConEmuCtrl::key_SwitchTermMode(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon) +{ + if (TestOnly) + return true; + gpConEmu->AskChangeTermMode(); + return true; +} // pRCon may be nullptr bool CConEmuCtrl::key_DuplicateRoot(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon) { diff --git a/src/ConEmu/ConEmuCtrl.h b/src/ConEmu/ConEmuCtrl.h index 45939488f..a7bc07c08 100644 --- a/src/ConEmu/ConEmuCtrl.h +++ b/src/ConEmu/ConEmuCtrl.h @@ -106,6 +106,7 @@ class CConEmuCtrl static bool WINAPI key_MultiRecreate(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); static bool WINAPI key_AlternativeBuffer(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); static bool WINAPI key_MultiBuffer(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); + static bool WINAPI key_SwitchTermMode(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); static bool WINAPI key_DuplicateRoot(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); static bool WINAPI key_DuplicateRootAs(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); static bool WINAPI key_MultiCmd(const ConEmuChord& VkState, bool TestOnly, const ConEmuHotKey* hk, CRealConsole* pRCon); diff --git a/src/ConEmu/HotkeyList.cpp b/src/ConEmu/HotkeyList.cpp index 9050ba310..a19f9560e 100644 --- a/src/ConEmu/HotkeyList.cpp +++ b/src/ConEmu/HotkeyList.cpp @@ -311,6 +311,8 @@ int ConEmuHotKeyList::AllocateHotkeys() .SetHotKey(VK_PAUSE); Add(vkMultiBuffer, chk_User, L"Multi.Scroll", CConEmuCtrl::key_MultiBuffer) ; + Add(vkSwitchTermMode, chk_User, L"Multi.SwitchTermMode", CConEmuCtrl::key_SwitchTermMode) + ; Add(vkMultiGroup, chk_User, L"Multi.GroupInput" ).SetMacro(L"GroupInput(0)") .SetHotKey('G', VK_APPS); Add(vkMultiGroupAll, chk_User, L"Multi.GroupInputAll" ).SetMacro(L"GroupInput(3)") diff --git a/src/ConEmu/LngDataHints.h b/src/ConEmu/LngDataHints.h index 76a66631d..c4f2d845a 100644 --- a/src/ConEmu/LngDataHints.h +++ b/src/ConEmu/LngDataHints.h @@ -408,6 +408,7 @@ static LngPredefined gsDataHints[] = { { vkMoveTabRight, L"Move active tab rightward" }, { vkMultiAltCon, L"Show alternative console buffer (last command output)" }, { vkMultiBuffer, L"Switch bufferheight mode" }, + { vkSwitchTermMode, L"Switch Terminal Input Mode" }, { vkMultiClose, L"Close active console" }, { vkMultiCmd, L"Create new %s console" }, { vkMultiGroup, L"Group keyboard input for visible splits" }, diff --git a/src/ConEmu/resource.h b/src/ConEmu/resource.h index 33109306d..86cefb57a 100644 --- a/src/ConEmu/resource.h +++ b/src/ConEmu/resource.h @@ -1352,6 +1352,7 @@ #define stStartupShellGeneral 3110 #define tFarHourglass 3111 #define vkSetFocusParent 3212 +#define vkSwitchTermMode 4321 #define IDC_STATIC -1 // Next default values for new objects From c8e8fd780621d75a1cd044d245cb35c246e51c0a Mon Sep 17 00:00:00 2001 From: ASU Date: Mon, 18 Sep 2023 23:31:08 +0300 Subject: [PATCH 2/2] Added Ctrl+Shift+M default hotkey for Switch Terminal Input Mode --- src/ConEmu/HotkeyList.cpp | 4 ++-- src/ConEmu/resource.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ConEmu/HotkeyList.cpp b/src/ConEmu/HotkeyList.cpp index a19f9560e..3c68a8e5f 100644 --- a/src/ConEmu/HotkeyList.cpp +++ b/src/ConEmu/HotkeyList.cpp @@ -311,8 +311,8 @@ int ConEmuHotKeyList::AllocateHotkeys() .SetHotKey(VK_PAUSE); Add(vkMultiBuffer, chk_User, L"Multi.Scroll", CConEmuCtrl::key_MultiBuffer) ; - Add(vkSwitchTermMode, chk_User, L"Multi.SwitchTermMode", CConEmuCtrl::key_SwitchTermMode) - ; + Add(vkSwitchTermMode, chk_User, L"Multi.SwitchTermMode", CConEmuCtrl::key_SwitchTermMode) + .SetHotKey('M',VK_CONTROL,VK_SHIFT); Add(vkMultiGroup, chk_User, L"Multi.GroupInput" ).SetMacro(L"GroupInput(0)") .SetHotKey('G', VK_APPS); Add(vkMultiGroupAll, chk_User, L"Multi.GroupInputAll" ).SetMacro(L"GroupInput(3)") diff --git a/src/ConEmu/resource.h b/src/ConEmu/resource.h index 86cefb57a..b2a2c562d 100644 --- a/src/ConEmu/resource.h +++ b/src/ConEmu/resource.h @@ -1352,7 +1352,7 @@ #define stStartupShellGeneral 3110 #define tFarHourglass 3111 #define vkSetFocusParent 3212 -#define vkSwitchTermMode 4321 +#define vkSwitchTermMode 3220 #define IDC_STATIC -1 // Next default values for new objects