Release KSwitcher v0.6.71 with Enter snippet confirmation
This commit is contained in:
1 parent
41a1426a16
commit
3cb2eee637
11 files changed
+63
-20
No files matched your search
+6
-2
@@ -1127,6 +1127,7 @@ void App::matchSnippets(HWND fg, bool expandExact)
|
||||
if (!snippetFocus) return;
|
||||
const auto selected = snippetMatches.empty() ? matches.end() :
|
||||
std::find(matches.begin(), matches.end(), snippetMatches[snippetSelection]);
|
||||
if (selected == matches.end()) snippetNavigated = false;
|
||||
snippetSelection = selected == matches.end() ? 0 : static_cast<size_t>(selected - matches.begin());
|
||||
snippetMatches = std::move(matches);
|
||||
snippetPrefixLength = prefix.size();
|
||||
@@ -1162,6 +1163,7 @@ bool App::snippetPopupCurrent() const
|
||||
void App::hideSnippetPopup()
|
||||
{
|
||||
snippetMatches.clear();
|
||||
snippetNavigated = false;
|
||||
if (snippetPopup && IsWindowVisible(snippetPopup))
|
||||
{
|
||||
ShowWindow(snippetPopup, SW_HIDE);
|
||||
@@ -1268,15 +1270,17 @@ void App::selectSnippet(size_t row)
|
||||
}
|
||||
bool App::handleSnippetKey(DWORD vk, UINT mods)
|
||||
{
|
||||
if (mods || (vk != VK_UP && vk != VK_DOWN && vk != VK_TAB && vk != VK_ESCAPE) ||
|
||||
const bool accept = vk == VK_TAB || (vk == VK_RETURN && snippetNavigated);
|
||||
if (mods || (!accept && vk != VK_UP && vk != VK_DOWN && vk != VK_ESCAPE) ||
|
||||
!snippetPopup || !IsWindowVisible(snippetPopup) || !snippetPopupCurrent())
|
||||
return false;
|
||||
if (vk == VK_TAB) selectSnippet(snippetSelection);
|
||||
if (accept) selectSnippet(snippetSelection);
|
||||
else if (vk == VK_ESCAPE) hideSnippetPopup();
|
||||
else
|
||||
{
|
||||
const auto count = snippetMatches.size();
|
||||
snippetSelection = (snippetSelection + (vk == VK_DOWN ? 1 : count - 1)) % count;
|
||||
snippetNavigated = true;
|
||||
InvalidateRect(snippetPopup, nullptr, FALSE);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user