#pragma once #include #include #include #include #include #include #include namespace ks { struct Layout { HKL handle{}; std::wstring id, name, normal, shifted; bool convertible = true; int code(wchar_t ch) const; wchar_t at(int code) const; bool hasLetter(wchar_t ch) const; }; bool letter(wchar_t ch); std::wstring lower(std::wstring text); std::wstring upper(std::wstring text); std::wstring convert(const std::wstring &, const Layout &, const Layout &, bool force = false); int detect(const std::wstring &, const std::vector &, int preferred = -1); std::wstring convertTo(const std::wstring &, const std::vector &, int target, int hint); int nextConversionLayout(const std::wstring &, const std::vector &, const std::vector &cycle, int hint); std::wstring cycleCase(const std::wstring &); std::wstring transliterate(const std::wstring &); struct Snippet { std::wstring trigger, text; std::wstring id; }; std::wstring snippetId(const Snippet &); std::wstring newSnippetId(); struct Template { std::wstring text, suffix; int cursors = 0; int enters = 0; }; Template parseTemplate(const std::wstring &); struct Hotkey { UINT modifiers{}, key{}; bool operator==(const Hotkey &) const = default; static std::optional parse(std::wstring); std::wstring format() const; }; struct Settings { bool recent = true, switchLayout = true, history = true, autostart = false, awake = false; bool elevatedAutostart = false; bool autoCorrect = false; bool autoReplace = false, autoTypos = false; std::map autoReplacements; bool writeLog = true; bool screenshotAutoOpenEditor = false; bool useTesseract = false; std::wstring tesseractPath; std::wstring tesseractLanguages = L"ukr+eng+rus"; int autoMaxRank = 0; int autoMinLength = 3; std::wstring autoPrefixChars = L"([{«“‘\""; std::wstring autoSuffixChars = L")]}»”’\".,!?:;"; std::vector autoLanguages{L"en", L"uk"}; std::vector autoNever; std::map> autoWords; std::vector autoExcluded{ L"Code", L"rider64", L"devenv", L"WindowsTerminal", L"cmd", L"powershell", L"pwsh", L"Far", L"ConEmu64", L"putty", L"KeePass", L"KeePassXC", L"1Password", L"Bitwarden"}; int maxItems = 500, maxMiB = 200, maxImageMiB = 20; std::wstring toggle = L"Ctrl+Alt+Shift+Space", casing = L"Ctrl+Alt+Shift+C", translit = L"Ctrl+Alt+Shift+T", undo = L"Ctrl+Alt+Shift+Z", clipboard = L"Win+V", screenshot = L"Win+Shift+S"; std::vector cycle, direct, directIds; std::vector excluded{L"KeePass", L"KeePassXC", L"1Password", L"Bitwarden"}; std::vector snippets; std::vector snippetTombstones; }; // Consume repeats and key-up for intercepted chords, even if settings change. struct HotkeyHook { bool pressed[256]{}; // 0: pass through, -1: consume only, positive: dispatch that action once. int update(UINT key, bool down, UINT modifiers, const std::vector> &bindings); }; std::string utf8(const std::wstring &); std::wstring wide(const std::string &); struct Run { HWND window{}; HKL layout{}; ULONGLONG at{}; std::wstring keys; bool overflow{}; void reset(); void record(wchar_t, HWND, HKL, ULONGLONG); void backspace(HWND, ULONGLONG); int match(const std::wstring &, const std::vector &, const Layout &physical) const; int matchSuffix(const std::wstring &, const std::vector &, const Layout &physical) const; }; } // namespace ks