#pragma once #include "platform.h" #include #include #include namespace ks { struct AutoSuggestion { int source{-1}, target{-1}; std::wstring text; }; std::wstring layoutLanguage(const Layout &); bool safeAutoWord(const std::wstring &, int minimumLength = 3); bool autoClosingSelection(const std::wstring &, const Settings & = {}); int matchAutoInput(const Run &, const std::wstring &, const std::vector &, const Layout &, const Settings & = {}); bool autoCorrectionAllowed(HWND, const Settings &); class AutoCorrector { struct Dictionary { std::string bytes; std::vector offsets; std::string_view word(size_t) const; explicit Dictionary(const std::filesystem::path &); int rank(const std::wstring &) const; }; std::map dictionaries; std::vector languages; std::set rejected; public: void configure(const std::filesystem::path &, const std::vector &); std::optional suggest(const std::wstring &, int source, const std::vector &, const Settings &) const; void reject(std::wstring word, const Settings & = {}); size_t memoryBytes() const; }; } // namespace ks