Compare commits

...

3 Commits

16 changed files with 277 additions and 44 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(KSwitcher VERSION 0.6.12 LANGUAGES CXX RC)
project(KSwitcher VERSION 0.6.15 LANGUAGES CXX RC)
if(NOT WIN32)
message(FATAL_ERROR "KSwitcher uses native Windows APIs")
endif()
+4 -1
View File
@@ -224,7 +224,10 @@ thumbnails and source labels aligned with the scaled fonts and spacing.
- Clipboard snapshot/restoration with concurrent-copy, foreground and input-version checks.
- Case cycling, Russian/Ukrainian transliteration, verified undo and repeated conversion.
- Text snippets across layouts, multiline insertion and a verified `{cursor}` position;
`{{cursor}}` inserts the literal marker. Snippets are stored as plaintext settings, as in [Typlo](https://github.com/bitcodepro/Typlo).
`{enter}` presses Enter after insertion and cursor placement (once per marker), before buffered typing resumes.
For example, `rider .{enter}` inserts `rider .` and presses Enter.
Automatic correction is suppressed during snippet expansion and for typing buffered by that expansion; the global setting is preserved.
`{{cursor}}` and `{{enter}}` insert literal markers. Snippets are stored as plaintext settings, as in [Typlo](https://github.com/bitcodepro/Typlo).
- Clipboard history for text, HTML/RTF, file lists, DIB and PNG images; plain-text paste;
full-text search, pinning, deletion, full text viewing and image previews.
- Image thumbnails and text/file icons appear directly in the history list. Only visible rows
Binary file not shown.
+8 -7
View File
@@ -1,16 +1,17 @@
# Latest Windows release
## v0.6.12 — 2026-10-30
## v0.6.15 — 2026-10-30
## Changes
- Start automatic layout correction immediately after Space and preserve subsequent typing while the correction runs.
- Accept identical corrected words shared by multiple selected languages; use the selected language order to choose the target layout. Different valid spellings remain ambiguous.
- Run the log viewer in the configurator process, separate from the resident input hooks. Clearing logs remains coordinated with the resident process.
- Keep the native four-column ListView. Resize the table with its window, anchor the footer and Close button, and make Details fill the remaining width.
- Exclude copied diagnostic rows from clipboard history.
- Preserve typing that arrives while a snippet is being expanded.
- Add `{enter}` to press Enter after insertion and cursor placement, with an Insert Enter marker button. Use `{{enter}}` for literal text.
- Suppress automatic correction during snippet expansion and buffered typing, without changing the global setting. Normal typing resumes automatic correction afterward.
- Restore the caret when snippet verification fails and record snippet failures in diagnostic logs.
Includes the earlier automatic-correction and log-viewer improvements. Existing modern releases update directly to this version without installing intermediate releases.
## Validation
Native and input regression suites, screenshot UI and updater checks, log-viewer integration, continuous-typing integration, and isolated configurator/log process checks. Manual development-build checks covered window dragging and automatic Details column width.
223 native regression checks, 472 input/UI checks, screenshot editor and notification registration checks, 45 updater checks and updater progress checks. Targeted native integration checks cover continuous snippet typing, clipboard restoration, actual Enter key events, punctuation preservation, suppression of automatic correction and its resumption afterward. The updated development build was also confirmed by the user in Notepad. The broader integration suite showed intermittent failures during earlier interactive runs; it is not claimed as fully passing.
**Upgrade:** choose Update in the tray menu. Legacy v0.3.0–v0.4.1 clients first receive the v0.4.2 compatibility bridge, then the current full release. v0.2.3 and earlier require manual installation.
For manual installation, exit KSwitcher and extract the entire ZIP into its installation folder. Keep personal `data/` and customized dictionaries.
+1 -1
View File
@@ -1 +1 @@
866de2d1d6fe121a7845760519f934bf0bd7820bbd11734a14c454b69a6bb8ad KSwitcher-win-x64.zip
04229e97b239683db7c113342f7c1e95e6f50b8fcbd1994e7b0920987766b9ab KSwitcher-win-x64.zip
+3 -3
View File
@@ -9,8 +9,8 @@ IDC_SCREENSHOT_PENCIL CURSOR "icons/lucide/pencil.cur"
1 RT_MANIFEST "app.manifest"
201 RCDATA "update.ps1"
1 VERSIONINFO
FILEVERSION 0,6,12,0
PRODUCTVERSION 0,6,12,0
FILEVERSION 0,6,15,0
PRODUCTVERSION 0,6,15,0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
BEGIN
@@ -20,7 +20,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "KSwitcher — native keyboard and clipboard utility"
VALUE "ProductName", "KSwitcher"
VALUE "FileVersion", "0.6.12"
VALUE "FileVersion", "0.6.15"
END
END
BLOCK "VarFileInfo"
+65 -20
View File
@@ -12,6 +12,11 @@ namespace ks
App *App::current = nullptr;
namespace
{
ULONG_PTR snippetReplayMarker()
{
static const char marker{};
return reinterpret_cast<ULONG_PTR>(&marker);
}
std::vector<std::pair<int, std::wstring>> shortcuts(const Settings &s)
{
std::vector<std::pair<int, std::wstring>> out{{Toggle, s.toggle},
@@ -566,7 +571,8 @@ void App::keyboard(const KBDLLHOOKSTRUCT &k, UINT mods)
return;
}
run.record(ch, fg, layout, GetTickCount64());
if (settings.autoCorrect && mods == 0 && ch == L' ' && run.keys.size() >= (size_t)settings.autoMinLength + 1 &&
if (settings.autoCorrect && !snippetTyping && k.dwExtraInfo != snippetReplayMarker() &&
mods == 0 && ch == L' ' && run.keys.size() >= (size_t)settings.autoMinLength + 1 &&
run.keys.size() <= 41 && !busy && !run.overflow)
{
for (int source = 0; source < (int)layouts.size(); ++source)
@@ -619,7 +625,18 @@ void App::keyboard(const KBDLLHOOKSTRUCT &k, UINT mods)
for (auto &trigger : variants)
if (keys.size() >= trigger.size() && keys.ends_with(trigger))
{
PostMessageW(window, SnippetMessage, (WPARAM)i, 0);
// Keep subsequent typing out of the selection/paste transaction.
typingTarget = fg;
snippetPending = (int)i;
snippetTyping = true;
busy = true;
if (!PostMessageW(window, SnippetMessage, (WPARAM)i, (LPARAM)inputVersion.load()))
{
typingTarget = nullptr;
snippetPending = -1;
snippetTyping = false;
busy = false;
}
return;
}
}
@@ -693,12 +710,13 @@ bool App::handleKeyboard(const KBDLLHOOKSTRUCT &key, bool down, UINT mods)
return true;
return false;
}
bool App::beginTypingDeferral(HWND target, uint64_t version)
bool App::beginTypingDeferral(HWND target, uint64_t version, bool snippet)
{
std::lock_guard lock(stateMutex);
if (inputVersion != version || GetForegroundWindow() != target || !modifiersReleased())
return false;
typingTarget = target;
snippetTyping = snippet;
return true;
}
void App::replayTyping()
@@ -710,7 +728,12 @@ void App::replayTyping()
target = typingTarget;
typingTarget = nullptr;
autoPending = false;
snippetPending = -1;
inputs.swap(deferredTyping);
if (snippetTyping)
for (auto &input : inputs)
input.ki.dwExtraInfo = snippetReplayMarker();
snippetTyping = false;
}
busy = false;
if (inputs.empty())
@@ -826,14 +849,19 @@ void App::transform(int command, int snippet)
L" version=" + std::to_wstring(currentVersion) +
L" repeat=" + std::to_wstring(repeatAttempts));
}
const bool preDeferred = command == AutoCorrect && autoPending;
const bool preDeferred = (command == AutoCorrect && autoPending) ||
(snippet >= 0 && snippetPending == snippet);
if (busy.exchange(true) && !preDeferred)
{
if (manual)
diagnosticEvent(L"Transform outcome id=" + std::to_wstring(attempt) + L" reason=busy", true);
return;
}
if (preDeferred) autoPending = false;
if (preDeferred)
{
autoPending = false;
snippetPending = -1;
}
Run recent;
std::optional<LastTransform> previous;
Settings config;
@@ -904,7 +932,7 @@ void App::transform(int command, int snippet)
reason != L"paste-sent-unverified" && reason != L"layout-only" &&
reason != L"unchanged-expected");
}
} audit{*this, target, version, attempt, requestedAt, manual, reason, text, result, expected, hint, to};
} audit{*this, target, version, attempt, requestedAt, manual || snippet >= 0, reason, text, result, expected, hint, to};
try
{
auto valid = [&]
@@ -940,14 +968,15 @@ void App::transform(int command, int snippet)
std::wstring predicted;
for (wchar_t key : recent.keys)
predicted += key == L' ' ? L' ' : available[hint].at(physicalLayout().code(key));
expected = predicted;
if (!autoCorrector.suggest(predicted, hint, available, config) ||
!autoCorrectionAllowed(target, config) || !valid())
return;
}
reason = L"clipboard-snapshot";
if (command == AutoCorrect)
if (command == AutoCorrect || snippet >= 0)
{
if (!beginTypingDeferral(target, version))
if (!beginTypingDeferral(target, version, snippet >= 0))
return;
reset.deferred = true;
}
@@ -979,9 +1008,12 @@ void App::transform(int command, int snippet)
autoSelected = true;
Sleep(25);
text = tx.copy();
// Some editors first select only ") ". Extend by whole-word
// boundaries, then still verify against the complete tracked run.
for (int i = 0; i < 3 && autoClosingSelection(text, config) && tx.valid(); ++i)
// Editors may split hj,bnm at the comma. Extend only a verified
// suffix of the tracked input, and still require a complete match.
for (int i = 0; i < 3 && tx.valid() &&
matchAutoInput(recent, text, available, physicalLayout(), config) < 0 &&
(autoClosingSelection(text, config) ||
(!text.empty() && text.size() < expected.size() && expected.ends_with(text))); ++i)
{
if (!chord(VK_LEFT, MOD_CONTROL | MOD_SHIFT))
break;
@@ -1039,13 +1071,11 @@ void App::transform(int command, int snippet)
tail.keys = tail.keys.substr(tail.keys.size() - sn.trigger.size());
if (!tx.select(sn.trigger.size()))
return;
autoSelected = true;
reason = L"snippet-verification-mismatch";
text = tx.copy();
if (tail.match(text, available, physicalLayout()) < 0)
{
if (tx.valid())
chord(VK_RIGHT);
return;
}
result = parseTemplate(sn.text).text;
automatic = true;
}
@@ -1158,12 +1188,22 @@ void App::transform(int command, int snippet)
if (snippet >= 0 && sent && tx.valid())
{
auto t = parseTemplate(config.snippets[snippet].text);
if (!t.suffix.empty() && tx.select(caretSteps(t.suffix)))
if (!t.suffix.empty())
{
if (!tx.select(caretSteps(t.suffix))) return;
auto suffix = tx.copy();
if (tx.valid())
chord(newlines(suffix) == newlines(t.suffix) ? VK_LEFT : VK_RIGHT);
if (!tx.valid()) return;
if (newlines(suffix) != newlines(t.suffix))
{
chord(VK_RIGHT);
return;
}
if (!chord(VK_LEFT)) return;
}
// Action markers run after insertion and cursor placement,
// before any physical typing buffered during expansion.
for (int i = 0; i < t.enters && tx.valid(); ++i)
if (!chord(VK_RETURN)) break;
}
if (to >= 0 && config.switchLayout && tx.valid() && (sent || result == text))
{
@@ -1513,15 +1553,20 @@ LRESULT CALLBACK App::windowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
case AutoCorrectMessage:
if (app->autoPending)
{
if (!app->installingUpdate && app->settings.autoCorrect && app->inputVersion.load() == (uint64_t)wp)
if (!app->installingUpdate && !app->snippetTyping && app->settings.autoCorrect && app->inputVersion.load() == (uint64_t)wp)
app->transform(AutoCorrect);
else
app->replayTyping();
}
return 0;
case SnippetMessage:
if (app->installingUpdate) return 0;
if (app->snippetPending == (int)wp)
{
if (!app->installingUpdate && app->inputVersion.load() == (uint64_t)lp)
app->transform(0, (int)wp);
else
app->replayTyping();
}
return 0;
case HistoryMessage:
if (app->historyWindow && IsWindowVisible(app->historyWindow))
+3 -1
View File
@@ -109,8 +109,10 @@ class App
HotkeyHook hotkeyHook;
HWND typingTarget{};
bool autoPending{};
int snippetPending = -1;
bool snippetTyping{};
std::vector<INPUT> deferredTyping;
bool beginTypingDeferral(HWND, uint64_t);
bool beginTypingDeferral(HWND, uint64_t, bool snippet = false);
void replayTyping();
static LRESULT CALLBACK windowProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK keyProc(int, WPARAM, LPARAM);
+5 -1
View File
@@ -152,7 +152,11 @@ std::optional<AutoSuggestion> AutoCorrector::suggest(const std::wstring &typed,
suffix.insert(suffix.begin(), word.back());
word.pop_back();
}
if (!safeAutoWord(word, settings.autoMinLength) || suffix.size() > 6 || rejected.contains(lower(word)))
// Punctuation keys can be letters in the target layout (for example ',' -> 'б').
// Validate letters and capitalization after conversion, not before it.
if (settings.autoMinLength < 1 || settings.autoMinLength > 32 ||
word.size() < (size_t)settings.autoMinLength || word.size() > 32 ||
suffix.size() > 6 || rejected.contains(lower(word)))
return {};
for (auto &never : settings.autoNever)
if (lower(never) == lower(word))
+11 -1
View File
@@ -261,7 +261,17 @@ Template parseTemplate(const std::wstring &text)
size_t cursor = std::wstring::npos;
for (size_t i = 0; i < text.size();)
{
if (text.compare(i, 10, L"{{cursor}}\0", 10) == 0)
if (text.compare(i, 9, L"{{enter}}") == 0)
{
t.text += L"{enter}";
i += 9;
}
else if (text.compare(i, 7, L"{enter}") == 0)
{
++t.enters;
i += 7;
}
else if (text.compare(i, 10, L"{{cursor}}\0", 10) == 0)
{
t.text += L"{cursor}";
i += 10;
+1
View File
@@ -34,6 +34,7 @@ struct Template
{
std::wstring text, suffix;
int cursors = 0;
int enters = 0;
};
Template parseTemplate(const std::wstring &);
struct Hotkey
+34 -4
View File
@@ -35,6 +35,7 @@ struct WindowLayout
int wheelRemainder{}, horizontalWheelRemainder{};
std::vector<std::pair<HWND, RECT>> controls; // Original 96-DPI geometry; never rescale rounded pixels.
HWND stretch{}, bottomLeft{}, bottomRight{};
bool autoOptions{};
};
WindowLayout *windowLayoutState(HWND w)
{
@@ -70,7 +71,7 @@ void arrangeWindow(HWND w)
layout->y = SetScrollInfo(w, SB_VERT, &vertical, TRUE);
}
RECT client{}; GetClientRect(w, &client);
bool expandable = layout->history || layout->stretch;
bool expandable = layout->history || layout->stretch || layout->autoOptions;
int extraWidth = expandable ? std::max(0, int(client.right) - scale(w, layout->width)) : 0;
int extraHeight = expandable ? std::max(0, int(client.bottom) - scale(w, layout->height)) : 0;
struct Move { HWND child; RECT rect; };
@@ -89,6 +90,28 @@ void arrangeWindow(HWND w)
}
if (child == layout->bottomLeft || child == layout->bottomRight)
OffsetRect(&next, child == layout->bottomRight ? extraWidth : 0, extraHeight);
if (layout->autoOptions)
{
if (r.top >= 396) OffsetRect(&next, 0, extraHeight);
if (r.top == 302 || r.top == 328 || (id >= 401 && id <= 403))
{
int column = id >= 401 && id <= 403 ? id - 401 : (r.left - 18) / 178;
int leftExtra = extraWidth * column / 3;
OffsetRect(&next, leftExtra, 0);
next.right += extraWidth * (column + 1) / 3 - leftExtra;
if (r.top == 328) next.bottom += extraHeight;
}
else if (r.top == 474 || r.top == 500)
{
bool rightColumn = r.left >= 290;
OffsetRect(&next, rightColumn ? extraWidth / 2 : 0, 0);
next.right += rightColumn ? extraWidth - extraWidth / 2 : extraWidth / 2;
}
else if (id == 406 || id == 410 || id == IDOK || id == IDCANCEL)
OffsetRect(&next, extraWidth, 0);
else if (r.right - r.left >= 500)
next.right += extraWidth;
}
RECT current{}; GetWindowRect(child, &current);
MapWindowPoints(nullptr, w, reinterpret_cast<POINT *>(&current), 2);
if (!EqualRect(&current, &next)) moves.push_back({child, next});
@@ -1073,6 +1096,7 @@ void showAutoOptions(HWND parent, SettingsView *v)
{
HWND w = makeWindow(*v->app, L"KSwitcher.AutoOptions", L"Automatic layout correction", autoOptionsProc,
560, 680);
windowLayoutState(w)->autoOptions = true;
SetWindowLongPtrW(w, GWLP_HWNDPARENT, (LONG_PTR)parent);
SetWindowLongPtrW(w, GWLP_USERDATA, (LONG_PTR) new AutoOptionsView{parent, v});
label(w, L"Offline dictionaries (only layouts in your cycle are used)", 18, 16, 525);
@@ -1113,6 +1137,11 @@ void showAutoOptions(HWND parent, SettingsView *v)
label(w, L"After editing files, click OK here, then Save in Settings to reload.", 18, 600, 525);
button(w, L"OK", IDOK, 326, 632, 100);
button(w, L"Cancel", IDCANCEL, 440, 632, 100);
RECT initial{};
GetWindowRect(w, &initial);
initial.right += scale(w, 200);
initial.bottom += scale(w, 140);
fitToMonitor(w, initial);
EnableWindow(parent, FALSE);
showRequestedWindow(w);
SetForegroundWindow(w);
@@ -1419,9 +1448,9 @@ LRESULT CALLBACK snippetProc(HWND w, UINT msg, WPARAM wp, LPARAM lp)
}
return 0;
}
if (id == 312)
if (id == 312 || id == 313)
{
SendDlgItemMessageW(w, 303, EM_REPLACESEL, TRUE, (LPARAM)L"{cursor}");
SendDlgItemMessageW(w, 303, EM_REPLACESEL, TRUE, (LPARAM)(id == 312 ? L"{cursor}" : L"{enter}"));
return 0;
}
if (id == IDOK)
@@ -1871,8 +1900,9 @@ void showSnippets(App &app)
edit(w, 302, 236, 44, 488);
label(w, L"Replacement text", 236, 82, 480);
edit(w, 303, 236, 110, 488, 270, ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL | WS_VSCROLL);
label(w, L"Use {cursor} once; {{cursor}} inserts the literal marker.", 236, 392, 488);
control(w, L"STATIC", L"{cursor}: caret; {enter}: press Enter after insertion.\nUse {{cursor}} / {{enter}} for literal markers.", 0, 0, 236, 392, 488, 36);
button(w, L"Insert cursor marker", 312, 236, 430, 190);
button(w, L"Insert Enter marker", 313, 436, 430, 190);
button(w, L"Save", IDOK, 510, 478, 100);
button(w, L"Cancel", IDCANCEL, 624, 478, 100);
fillSnippets(w, (SnippetView *)GetWindowLongPtrW(w, GWLP_USERDATA));
+1 -1
View File
@@ -2,7 +2,7 @@
#include "platform.h"
namespace ks
{
inline constexpr wchar_t AppVersion[] = L"0.6.12";
inline constexpr wchar_t AppVersion[] = L"0.6.14";
inline constexpr UINT UpdateMessage = WM_APP + 7;
inline constexpr UINT UpdateCheckIntervalMs = 6 * 60 * 60 * 1000;
inline constexpr UINT UpdateNotificationRetryMs = 5 * 60 * 1000;
+29
View File
@@ -598,6 +598,35 @@ int main(int argc, char **argv) {
auto autoOptions=FindWindowW(L"KSwitcher.AutoOptions",nullptr);
require(autoOptions!=nullptr,"auto-correction options open");
ShowWindow(autoOptions,SW_HIDE);
{
require((GetWindowLongPtrW(autoOptions,GWL_STYLE)&WS_THICKFRAME)!=0,
"auto-correction dialog supports resizing");
RECT original{}, before[3]{}, after[3]{}, buttonBefore{}, buttonAfter{};
GetWindowRect(autoOptions,&original);
// Use a client size above the scrolling baseline at every DPI.
UINT dpi=GetDpiForWindow(autoOptions);
SetWindowPos(autoOptions,nullptr,0,0,MulDiv(800,dpi,96),MulDiv(900,dpi,96),
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
RECT baseline{}; GetWindowRect(autoOptions,&baseline);
for(int i=0;i<3;++i) GetWindowRect(GetDlgItem(autoOptions,411+i),&before[i]);
GetWindowRect(GetDlgItem(autoOptions,IDOK),&buttonBefore);
SetWindowPos(autoOptions,nullptr,0,0,baseline.right-baseline.left+240,
baseline.bottom-baseline.top+120,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
for(int i=0;i<3;++i) {
GetWindowRect(GetDlgItem(autoOptions,411+i),&after[i]);
require(after[i].right-after[i].left==before[i].right-before[i].left+80 &&
after[i].bottom-after[i].top==before[i].bottom-before[i].top+120,
"dictionary columns share extra width and receive extra height");
}
GetWindowRect(GetDlgItem(autoOptions,IDOK),&buttonAfter);
require(buttonAfter.left-buttonBefore.left==240 && buttonAfter.top-buttonBefore.top==120,
"auto-correction buttons follow bottom-right corner");
require(after[0].right<after[1].left && after[1].right<after[2].left &&
after[2].bottom<buttonAfter.top,
"resized dictionary fields and footer do not overlap");
SetWindowPos(autoOptions,nullptr,0,0,original.right-original.left,original.bottom-original.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
}
for(int id:{411,412,413}) {
RECT control{},client{};
GetWindowRect(GetDlgItem(autoOptions,id),&control);
+95 -2
View File
@@ -21,6 +21,12 @@ ks::App *app{};
HWND host{}, field{};
ks::Clip saved;
bool captured = false, failed = false;
int enterPresses = 0;
LRESULT CALLBACK observeEnter(HWND w, UINT message, WPARAM wp, LPARAM lp, UINT_PTR, DWORD_PTR)
{
if (message == WM_KEYDOWN && wp == VK_RETURN) ++enterPresses;
return DefSubclassProc(w, message, wp, lp);
}
int stage = 0, ru = -1, en = -1;
size_t punctuationCase = 0;
bool typeDuringCorrection = false, typedDuringCorrection = false;
@@ -281,7 +287,73 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
break;
case 17:
require(text() == punctuationCases.back().first, "undo preserves custom punctuation");
[[fallthrough]];
stage = 20;
break;
case 30:
case 32:
case 34:
if (!captured)
{
saved = ks::readClipboard(app->window, 64 * 1024 * 1024);
captured = true;
}
app->ownSequence = ks::writeClipboard(app->window, ks::textClip(sentinel));
app->settings.autoCorrect = stage == 35;
app->settings.autoLanguages = {L"en", L"ru"};
app->autoPredictor.configure(L"dictionaries", app->settings.autoLanguages);
app->settings.snippets = {{L";r", stage == 31 ? L"rider .{cursor}" : L"rider .{cursor}{enter}"}};
enterPresses = 0;
ActivateKeyboardLayout(app->layouts[en].handle, 0);
prepare(L"prefix ", false);
{
std::vector<INPUT> inputs;
const std::vector<WORD> keys = stage == 35
? std::vector<WORD>{VK_OEM_1, 'R', 'G', 'H', 'B', 'D', 'T', 'N', VK_SPACE}
: std::vector<WORD>{VK_OEM_1, 'R', VK_SPACE, 'X'};
for (WORD key : keys)
for (DWORD flags : {DWORD(0), DWORD(KEYEVENTF_KEYUP)})
{
auto input = ks::keyboardInput(key, flags);
input.ki.dwExtraInfo = 123;
inputs.push_back(input);
}
require(SendInput((UINT)inputs.size(), inputs.data(), sizeof(INPUT)) == inputs.size(),
"snippet trigger and following text submitted without a pause");
}
break;
case 31:
require(text() == L"prefix rider . x", "snippet expands through keyboard hook and preserves following typing");
require(ks::readClipboard(app->window).text() == sentinel, "hook snippet restores clipboard");
require(enterPresses == 0, "snippet without Enter marker sends no Enter");
stage = 32;
break;
case 33:
require(text() == L"prefix rider .\r\n x", "Enter action precedes buffered typing");
require(enterPresses == 1, "Enter marker sends an actual Enter key press");
require(ks::readClipboard(app->window).text() == sentinel, "Enter snippet restores clipboard");
stage = 34;
break;
case 35:
require(text() == L"prefix rider .\r\nghbdtn ", "snippet replay does not trigger automatic correction");
require(app->settings.autoCorrect, "snippet preserves global auto-correction setting");
require(enterPresses == 1, "snippet punctuation and Enter survive with auto-correction enabled");
{
std::vector<INPUT> inputs;
for (WORD key : std::wstring(L"GHBDTN "))
for (DWORD flags : {DWORD(0), DWORD(KEYEVENTF_KEYUP)})
{
auto input = ks::keyboardInput(key == L' ' ? VK_SPACE : key, flags);
input.ki.dwExtraInfo = 123;
inputs.push_back(input);
}
require(SendInput((UINT)inputs.size(), inputs.data(), sizeof(INPUT)) == inputs.size(),
"normal typing submitted after snippet completes");
}
break;
case 36:
require(text() == L"prefix rider .\r\nghbdtn привет ", "automatic correction resumes for subsequent normal typing");
finish();
break;
case 20:
if (!captured)
{
@@ -334,8 +406,26 @@ LRESULT CALLBACK procedure(HWND w, UINT msg, WPARAM wp, LPARAM lp)
stage = 21;
break;
case 21:
{
require(text() == L"привет а", "automatic correction preserves immediate next-word typing without a pause");
finish();
auto uk = std::find_if(app->layouts.begin(), app->layouts.end(), [](const auto &layout) {
return ks::layoutLanguage(layout) == L"uk";
});
require(uk != app->layouts.end(), "Ukrainian layout available for punctuation-key regression");
app->settings.autoLanguages = {L"en", L"uk"};
app->settings.cycle = {app->layouts[en].id, uk->id};
app->settings.autoWords[L"uk"] = {L"робить"};
app->autoCorrector = ks::AutoCorrector{};
ActivateKeyboardLayout(app->layouts[en].handle, 0);
prepare(L"hj,bnm ", false);
record(L"hj,bnm ");
app->transform(ks::AutoCorrect);
stage = 22;
break;
}
case 22:
require(text() == L"робить ", "automatic correction selects and converts the whole word across an internal comma");
stage = 30;
break;
}
}
@@ -459,8 +549,11 @@ int main(int argc, char **argv)
CreateWindowW(L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_WANTRETURN,
20, 20, 590, 230, host, nullptr, cls.hInstance, nullptr);
deadline = GetTickCount64() + 30000;
SetWindowSubclass(field, observeEnter, 1, 0);
if (argc > 1 && std::string(argv[1]) == "--typing-only")
stage = 20;
if (argc > 1 && std::string(argv[1]) == "--snippets-only")
stage = 30;
SetTimer(host, 1, 100, nullptr);
app->execute();
}
+15
View File
@@ -276,6 +276,15 @@ int main(int argc, char **argv)
require(!supplemental.suggest(L"релызик ", 1, layouts, options),
"never-correct list takes precedence over personal word");
options.autoNever.clear();
options.autoWords[L"uk"].push_back(L"робить");
auto commaWord = supplemental.suggest(L"hj,bnm ", 0, layouts, options);
require(commaWord && commaWord->text == L"робить " && commaWord->target == 2,
"personal Ukrainian word accepts a punctuation key that maps to a letter");
require(!supplemental.suggest(L"hj,bnm123 ", 0, layouts, options),
"punctuation-key correction still rejects digits");
options.autoMinLength = 1;
require(!supplemental.suggest(L"ye ", 0, layouts, options),
"known English ye remains protected at minimum length one");
options.cycle = {L"en", L"ru"};
require(!supplemental.suggest(L"релызик ", 1, layouts, options),
"personal dictionary respects disabled target layouts");
@@ -292,6 +301,12 @@ int main(int argc, char **argv)
require(ks::transliterate(L"Shchuka") == L"Щука", "reverse transliteration");
require(ks::parseTemplate(L"a{cursor}b").suffix == L"b", "snippet suffix");
require(ks::parseTemplate(L"{{cursor}}").text == L"{cursor}", "escaped cursor");
require(ks::parseTemplate(L"rider .{enter}").text == L"rider ." &&
ks::parseTemplate(L"rider .{enter}").enters == 1, "Enter is an action, not inserted text");
require(ks::parseTemplate(L"a{cursor}b{enter}{enter}").suffix == L"b" &&
ks::parseTemplate(L"a{cursor}b{enter}{enter}").enters == 2, "Enter actions preserve cursor suffix");
require(ks::parseTemplate(L"{{enter}}").text == L"{enter}" &&
ks::parseTemplate(L"{{enter}}").enters == 0, "escaped Enter is literal");
require(ks::parseTemplate(L"{cursor}{cursor}").cursors == 2, "duplicate cursor detection");
require(ks::Hotkey::parse(L"Ctrl+Alt+Shift+Space")->key == VK_SPACE, "hotkey parse");
require(!ks::Hotkey::parse(L"Ctrl+F25"), "invalid function key");