├── .clang-format ├── .editorconfig ├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── .gitignore ├── CMake └── PVS-Studio.cmake ├── CMakeLists.txt ├── Changes.md ├── DSpellCheck.DotSettings ├── License.txt ├── README.md ├── Resources ├── Autocheck-dark.ico ├── Autocheck-dark.svg ├── Autocheck.ico ├── Autocheck.svg ├── Autocheck16.bmp ├── Autocheck24.bmp ├── Autocheck32.bmp ├── Autocheck64.bmp ├── arrow_refresh.ico ├── arrow_refresh.svg ├── convert-svg-to-bmp.bat ├── convert-svg-to-ico.bat ├── downArrowButton.bmp ├── downArrowButton_hover.bmp └── downArrowButton_push.bmp ├── coverage.bat ├── deploy.py ├── deps ├── .clang-format ├── Catch │ ├── CMakeLists.txt │ ├── catch.hpp │ └── dummy.cpp ├── Controls │ ├── CMakeLists.txt │ ├── CheckedList │ │ ├── CheckedList.cpp │ │ └── CheckedList.h │ ├── Notepad_plus_msgs.h │ ├── TabBar │ │ ├── ControlsTab.cpp │ │ ├── ControlsTab.h │ │ ├── TabBar.cpp │ │ └── TabBar.h │ ├── Window.h │ └── menuCmdID.h ├── FtpClient │ ├── BlockingSocket.cpp │ ├── BlockingSocket.h │ ├── CMakeLists.txt │ ├── Definements.h │ ├── FTPClient.cpp │ ├── FTPClient.h │ ├── FTPDataTypes.cpp │ ├── FTPDataTypes.h │ ├── FTPFileStatus.cpp │ ├── FTPFileStatus.h │ ├── FTPListParse.cpp │ ├── FTPListParse.h │ └── smart_ptr.h ├── Hunspell │ ├── ABOUT-NLS │ ├── AUTHORS │ ├── AUTHORS.myspell │ ├── BUGS │ ├── CMakeLists.txt │ ├── COPYING │ ├── COPYING.LESSER │ ├── COPYING.LGPL │ ├── COPYING.MPL │ ├── ChangeLog │ ├── ChangeLog.O │ ├── HACKING │ ├── INSTALL │ ├── NEWS │ ├── README │ ├── README.md │ ├── README.myspell │ ├── THANKS │ ├── TODO │ ├── license.hunspell │ ├── license.myspell │ └── src │ │ └── hunspell │ │ ├── affentry.cxx │ │ ├── affentry.hxx │ │ ├── affixmgr.cxx │ │ ├── affixmgr.hxx │ │ ├── atypes.hxx │ │ ├── baseaffix.hxx │ │ ├── config.h │ │ ├── csutil.cxx │ │ ├── csutil.hxx │ │ ├── filemgr.cxx │ │ ├── filemgr.hxx │ │ ├── hashmgr.cxx │ │ ├── hashmgr.hxx │ │ ├── htypes.hxx │ │ ├── hunspell.cxx │ │ ├── hunspell.h │ │ ├── hunspell.hxx │ │ ├── hunvisapi.h │ │ ├── hunvisapi.h.in │ │ ├── hunzip.cxx │ │ ├── hunzip.hxx │ │ ├── langnum.hxx │ │ ├── phonet.cxx │ │ ├── phonet.hxx │ │ ├── replist.cxx │ │ ├── replist.hxx │ │ ├── suggestmgr.cxx │ │ ├── suggestmgr.hxx │ │ ├── utf_info.cxx │ │ └── w_char.hxx ├── aspell │ ├── CMakeLists.txt │ ├── aspell.h │ └── dummy.cpp ├── json │ ├── CMakeLists.txt │ ├── dummy.cpp │ └── json.hpp ├── lsignal │ ├── CMakeLists.txt │ ├── dummy.cpp │ └── lsignal.h ├── minizip │ ├── CMakeLists.txt │ ├── adler32.c │ ├── compress.c │ ├── crc32.c │ ├── crc32.h │ ├── deflate.c │ ├── deflate.h │ ├── gzclose.c │ ├── gzguts.h │ ├── gzlib.c │ ├── gzread.c │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── ioapi.c │ ├── ioapi.h │ ├── iowin32.c │ ├── iowin32.h │ ├── minigzip.c │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── unzip.c │ ├── unzip.h │ ├── zconf.h │ ├── zlib.h │ ├── zutil.c │ └── zutil.h ├── npp_extra │ ├── CMakeLists.txt │ ├── PluginInterface.h │ ├── SciLexer.h │ ├── Sci_Position.h │ ├── Scintilla.h │ └── dummy.cpp └── win-iconv │ ├── CMakeLists.txt │ ├── ChangeLog │ ├── FindWcecompat.cmake │ ├── Makefile │ ├── iconv.def │ ├── iconv.h │ ├── mlang.def │ ├── mlang.h │ ├── readme.txt │ ├── win_iconv.c │ └── win_iconv_test.c ├── include └── PluginMsg.h ├── src ├── common │ ├── IniWorker.cpp │ ├── IniWorker.h │ ├── MappedWstring.h │ ├── PrecompiledHeader.cpp │ ├── PrecompiledHeader.h │ ├── ProgressData.cpp │ ├── ProgressData.h │ ├── TaskWrapper.cpp │ ├── TaskWrapper.h │ ├── TemporaryAcessor.h │ ├── Utility.cpp │ ├── Utility.h │ ├── Win32Exception.cpp │ ├── Win32Exception.h │ ├── WinApiControls.cpp │ ├── WinApiControls.h │ ├── WinInet.cpp │ ├── WinInet.h │ ├── WindowsDefs.h │ ├── enum_array.h │ ├── enum_range.h │ ├── move_only.h │ ├── overload.h │ ├── raii.cpp │ ├── raii.h │ ├── remap_rvalues_for.h │ ├── string_utils.cpp │ ├── string_utils.h │ ├── utf8.cpp │ ├── utf8.h │ ├── winapi.cpp │ └── winapi.h ├── core │ ├── SpellChecker.cpp │ ├── SpellChecker.h │ ├── SpellCheckerHelpers.cpp │ └── SpellCheckerHelpers.h ├── network │ ├── FileListProvider.h │ ├── GithubFileListProvider.cpp │ ├── GithubFileListProvider.h │ ├── UrlHelpers.cpp │ └── UrlHelpers.h ├── npp │ ├── EditorInterface.cpp │ ├── EditorInterface.h │ ├── NppInterface.cpp │ ├── NppInterface.h │ ├── ScintillaUtils.cpp │ ├── ScintillaUtils.h │ ├── TextUtils.cpp │ └── TextUtils.h ├── plugin │ ├── Constants.h │ ├── DSpellCheck.rc │ ├── DllMain.cpp │ ├── Plugin.cpp │ ├── Plugin.h │ ├── Settings.cpp │ ├── Settings.h │ └── resource.h ├── spellers │ ├── AspellInterface.cpp │ ├── AspellInterface.h │ ├── HunspellInterface.cpp │ ├── HunspellInterface.h │ ├── LanguageInfo.h │ ├── NativeSpellerInterface.cpp │ ├── NativeSpellerInterface.h │ ├── SpellerContainer.cpp │ ├── SpellerContainer.h │ ├── SpellerId.h │ ├── SpellerInterface.cpp │ ├── SpellerInterface.h │ └── aspell.cpp └── ui │ ├── AboutDialog.cpp │ ├── AboutDialog.h │ ├── AspellOptionsDialog.cpp │ ├── AspellOptionsDialog.h │ ├── ConnectionSettingsDialog.cpp │ ├── ConnectionSettingsDialog.h │ ├── ContextMenuHandler.cpp │ ├── ContextMenuHandler.h │ ├── DownloadDictionariesDialog.cpp │ ├── DownloadDictionariesDialog.h │ ├── MenuItem.cpp │ ├── MenuItem.h │ ├── ProgressDialog.cpp │ ├── ProgressDialog.h │ ├── RemoveDictionariesDialog.cpp │ ├── RemoveDictionariesDialog.h │ ├── SelectMultipleLanguagesDialog.cpp │ ├── SelectMultipleLanguagesDialog.h │ ├── SettingsDialog.cpp │ ├── SettingsDialog.h │ ├── StaticDialog.cpp │ ├── StaticDialog.h │ ├── SuggestionMenuButton.cpp │ └── SuggestionMenuButton.h └── test ├── EncodingTests.cpp ├── LanguageStyleTests.cpp ├── MockEditorInterface.cpp ├── MockEditorInterface.h ├── MockSpeller.cpp ├── MockSpeller.h ├── SpellCheckerTests.cpp ├── StringTests.cpp ├── TestCommon.cpp ├── TestCommon.h └── main.cpp /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | ColumnLimit: 160 3 | IncludeBlocks: Regroup 4 | IncludeCategories: 5 | - Regex: '' 6 | Priority: 1 7 | - Regex: '<[[:alnum:].]+>' 8 | Priority: 2 9 | - Regex: '".*"' 10 | Priority: 1 11 | SortPriority: 0 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | insert_final_newline = true 8 | charset = utf-8 9 | indent_style = space 10 | indent_size = 2 11 | trim_trailing_whitespace = true 12 | 13 | [*.py] 14 | indent_style = tab 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.rc diff=set diff 2 | resource.h diff=set diff 3 | 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | 9 | # Maintain dependencies for GitHub Actions 10 | - package-ecosystem: "github-actions" 11 | directory: "/" 12 | schedule: 13 | interval: "monthly" 14 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | on: 3 | pull_request: 4 | release: 5 | types: [published] 6 | push: 7 | tags: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | Test: 13 | runs-on: ${{ matrix.os }} 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | os: 18 | - windows-latest 19 | generator: 20 | - "Visual Studio 17 2022" 21 | arch: 22 | - x64 23 | - Win32 24 | - ARM64 25 | build_type: 26 | - RelWithDebInfo 27 | - Debug 28 | compiler: 29 | - msvc 30 | package_generator: 31 | - ZIP 32 | 33 | steps: 34 | - uses: actions/checkout@v4 35 | 36 | - name: Setup Cpp 37 | uses: aminya/setup-cpp@v1 38 | with: 39 | compiler: ${{ matrix.compiler }} 40 | vcvarsall: ${{ contains(matrix.os, 'windows' )}} 41 | cmake: true 42 | ninja: true 43 | 44 | - name: Configure CMake 45 | run: | 46 | cmake -S . -B ./build -G "${{matrix.generator}}" -A "${{matrix.arch}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} 47 | 48 | - name: Build 49 | run: | 50 | cmake --build ./build --target DSpellCheck --config ${{matrix.build_type}} 51 | 52 | - name: Test 53 | run: | 54 | ctest --build-and-test . ./build --build-generator "${{matrix.generator}}" 55 | 56 | - name: Upload Artifacts 57 | if: matrix.build_type == 'RelWithDebInfo' 58 | uses: actions/upload-artifact@v4 59 | with: 60 | name: DSpellCheck-${{matrix.arch}} 61 | path: | 62 | ./build/${{matrix.build_type}}/DSpellCheck.dll 63 | ./build/${{matrix.build_type}}/DSpellCheck.pdb 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.vcxproj 2 | *.vcxproj.filters 3 | *.vcxproj.user 4 | *.suo 5 | *.sdf 6 | *.sln 7 | *.opensdf 8 | *.aps 9 | *.i 10 | *.vcproj 11 | *.vcproj.* 12 | CMakeCache.txt 13 | cmake_install.cmake 14 | *.ncb 15 | DSpellCheck.dir/* 16 | ZERO_CHECK.dir/* 17 | Hunspell/CMakeFiles/* 18 | Hunspell/Debug/* 19 | Hunspell/hunspell-static.dir/* 20 | Hunspell/Release/* 21 | Hunspell/Debug/* 22 | minizip/Debug/* 23 | minizip/Release/* 24 | libiconv/ReleaseStatic_Win32/* 25 | libiconv/DebugStatic_Win32/* 26 | libiconv/libiconv.dir/* 27 | CMakeFiles/* 28 | UnusedFiles/* 29 | libiconv/CMakeFiles/* 30 | minizip/minizip.dir/Debug/* 31 | minizip/minizip.dir/Release/* 32 | minizip/minizip/win32/ 33 | minizip/CMakeFiles 34 | Debug/* 35 | MinSizeRel/* 36 | Release/* 37 | Win32/* 38 | src/config.h 39 | ipch/* 40 | lib/* 41 | build*/ 42 | bld*/ 43 | bin*/ 44 | out/ 45 | *.TMP 46 | .vs/ 47 | CMakeSettings.json 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Build status](https://github.com/predelnik/DSpellCheck/actions/workflows/build.yml/badge.svg) 2 | 3 | DSpellCheck 4 | =========== 5 | 6 | Notepad++ Spell-checking Plug-In 7 | 8 | Following main features: 9 | - Underlining spelling mistakes 10 | - Iterating through all mistakes in document 11 | - Finding mistakes only in comments and strings (For files with standard programming language syntax e.g. C++, Basic, Tex and so on) 12 | - Possible usage of multiple languages (dictionaries) simultaneously to do spell-checking. 13 | - Getting suggestions for words by either using default Notepad++ menu or separate context menu called by special button appearing under word. 14 | - Able to add words to user dictionary or ignore them for current session of Notepad++ 15 | - Using either Aspell library (needs to be installed), either Hunspell library (Dictionaries by default should be placed to %Plugin Config Dir%\Hunspell) 16 | - A lot of customizing available from Plugin settings (Ignoring/Allowing only specific files, Choosing delimiters for words, Maximum number of suggestions etc) 17 | - Support for downloading and removing Hunspell dictionaries through user friendly GUI interface 18 | - Ability to quickly change current language through context menu or DSpellCheck sub-menu. 19 | 20 | [Changelog](Changes.md) 21 | -------------------------------------------------------------------------------- /Resources/Autocheck-dark.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/Autocheck-dark.ico -------------------------------------------------------------------------------- /Resources/Autocheck.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/Autocheck.ico -------------------------------------------------------------------------------- /Resources/Autocheck16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/Autocheck16.bmp -------------------------------------------------------------------------------- /Resources/Autocheck24.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/Autocheck24.bmp -------------------------------------------------------------------------------- /Resources/Autocheck32.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/Autocheck32.bmp -------------------------------------------------------------------------------- /Resources/Autocheck64.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/Autocheck64.bmp -------------------------------------------------------------------------------- /Resources/arrow_refresh.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/arrow_refresh.ico -------------------------------------------------------------------------------- /Resources/arrow_refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 42 | 44 | 45 | 47 | image/svg+xml 48 | 50 | 51 | 52 | 53 | 54 | 59 | 65 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /Resources/convert-svg-to-bmp.bat: -------------------------------------------------------------------------------- 1 | magick %1.svg -resize 16x16 -density 384 BMP3:%116.bmp 2 | magick %1.svg -resize 24x24 -density 384 BMP3:%124.bmp 3 | magick %1.svg -resize 32x32 -density 384 BMP3:%132.bmp 4 | magick %1.svg -resize 64x64 -density 384 BMP3:%164.bmp 5 | -------------------------------------------------------------------------------- /Resources/convert-svg-to-ico.bat: -------------------------------------------------------------------------------- 1 | magick -density 384 -background none %1.svg -define icon:auto-resize=64,48,32,16 %1.ico -------------------------------------------------------------------------------- /Resources/downArrowButton.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/downArrowButton.bmp -------------------------------------------------------------------------------- /Resources/downArrowButton_hover.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/downArrowButton_hover.bmp -------------------------------------------------------------------------------- /Resources/downArrowButton_push.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/Resources/downArrowButton_push.bmp -------------------------------------------------------------------------------- /coverage.bat: -------------------------------------------------------------------------------- 1 | SET script_dir=%~dp0 2 | OpenCppCoverage "debug/DSpellCheckTest.exe" --sources="%script_dir%src\*" -------------------------------------------------------------------------------- /deps/.clang-format: -------------------------------------------------------------------------------- 1 | { 2 | "DisableFormat": true, 3 | "SortIncludes": false 4 | } 5 | -------------------------------------------------------------------------------- /deps/Catch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (catch) 3 | file (GLOB_RECURSE source_files *.cpp *.h *.hpp) 4 | add_library (catch STATIC ${source_files}) 5 | target_include_directories(catch PUBLIC .) 6 | set_property(TARGET catch PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 7 | -------------------------------------------------------------------------------- /deps/Catch/dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/Catch/dummy.cpp -------------------------------------------------------------------------------- /deps/Controls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (Controls) 3 | file (GLOB_RECURSE source_files *.cpp *.h) 4 | add_library (Controls STATIC ${source_files}) 5 | target_include_directories(Controls PUBLIC .) 6 | target_compile_definitions(Controls PRIVATE UNICODE _UNICODE _CRT_NONSTDC_NO_DEPRECATE) 7 | set_property(TARGET Controls PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 8 | -------------------------------------------------------------------------------- /deps/Controls/CheckedList/CheckedList.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | /// 3 | /// @file checkedList.h 4 | /// 5 | /// @brief A checked listBox control in Win32 SDK C. 6 | /// 7 | /// @author David MacDermot 8 | /// 9 | /// @par Comments: 10 | /// This source is distributed in the hope that it will be useful, 11 | /// but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | /// 14 | /// @date 9-07-10 15 | /// 16 | /// @todo 17 | /// 18 | /// @bug 19 | /// 20 | ////////////////////////////////////////////////////////////////////////////// 21 | 22 | #ifndef CHECKEDLIST_H 23 | #define CHECKEDLIST_H 24 | 25 | /****************************************************************************/ 26 | /// @name Checked listbox specific messages. 27 | /// @{ 28 | 29 | #define LBCM_FLATCHECKS WM_USER + 1 /// ListBox_SetItemData((hwndCtl), (iIndex), (fCheck)) ? CB_ERR : \ 58 | (InvalidateRgn((hwndCtl), NULL, FALSE), (iIndex))) 59 | 60 | /// @def CheckedListBox_GetCheckState(hList, iIndex, fCheck) 61 | /// 62 | /// @brief Gets the checked state of an item in a checked listbox control. 63 | /// 64 | /// @param hwndCtl The handle of a checked listbox. 65 | /// @param iIndex The zero-based index of the item for which to set the check state. 66 | /// 67 | /// @returns Nonzero if the given item is selected, or zero otherwise. 68 | #define CheckedListBox_GetCheckState(hwndCtl, iIndex) \ 69 | (BOOL) ListBox_GetItemData(hwndCtl, iIndex) 70 | 71 | /// @def CheckedListBox_SetFlatStyleChecks(hwndCtl, fFlat) 72 | /// 73 | /// @brief Sets the appearance of the checkboxes. 74 | /// 75 | /// @param hwndCtl The handle of a checked listbox. 76 | /// @param fFlat TRUE for flat checkboxes, or FALSE for standard checkboxes. 77 | /// 78 | /// @returns No return value. 79 | #define CheckedListBox_SetFlatStyleChecks(hwndCtl, fFlat) \ 80 | ((void)SendMessage((hwndCtl),LBCM_FLATCHECKS,(WPARAM)(BOOL) (fFlat),(LPARAM)0L)) 81 | 82 | /// @def CheckedListBox_EnableCheckAll(hwndCtl, fEnable) 83 | /// 84 | /// @brief Sets the select/deselect all feature. 85 | /// 86 | /// @param hwndCtl The handle of a checked listbox. 87 | /// @param fEnable TRUE enables right mouse button select/deselect all feature, or FALSE disables feature. 88 | /// 89 | /// @returns No return value. 90 | #define CheckedListBox_EnableCheckAll(hwndCtl, fEnable) \ 91 | ((void)SendMessage((hwndCtl),LBCM_CHECKALL,(WPARAM)(BOOL) (fEnable),(LPARAM)0L)) 92 | 93 | /// @} 94 | 95 | /****************************************************************************/ 96 | // Exported function prototypes 97 | 98 | ATOM InitCheckedListBox(HINSTANCE hInstance); 99 | HWND New_CheckedListBox(HWND hParent, DWORD dwStyle, DWORD dwExStyle, HMENU dwID, INT x, INT y, INT nWidth, INT nHeight); 100 | 101 | #endif //CHECKEDLIST_H 102 | -------------------------------------------------------------------------------- /deps/Controls/TabBar/ControlsTab.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2003 Don HO 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either 7 | // version 2 of the License, or (at your option) any later version. 8 | // 9 | // Note that the GPL places important restrictions on "derived works", yet 10 | // it does not provide a detailed definition of that term. To avoid 11 | // misunderstandings, we consider an application to constitute a 12 | // "derivative work" for the purpose of this license if it does any of the 13 | // following: 14 | // 1. Integrates source code from Notepad++. 15 | // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable 16 | // installer, such as those produced by InstallShield. 17 | // 3. Links to a library or executes a program that does any of the above. 18 | // 19 | // This program is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with this program; if not, write to the Free Software 26 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 | 28 | #include "ControlsTab.h" 29 | #include 30 | 31 | void ControlsTab::createTabs(WindowVector & winVector) 32 | { 33 | _pWinVector = &winVector; 34 | 35 | for (int i = 0 ; i < int(winVector.size()) ; i++) 36 | TabBar::insertAtEnd(winVector[i]._name.c_str()); 37 | 38 | TabBar::activateAt(0); 39 | activateWindowAt(0); 40 | } 41 | 42 | void ControlsTab::activateWindowAt(int index) 43 | { 44 | if (index == _current) return; 45 | (*_pWinVector)[_current]._dlg->display(false); 46 | (*_pWinVector)[index]._dlg->display(true); 47 | _current = index; 48 | } 49 | 50 | void ControlsTab::reSizeTo(RECT & rc) 51 | { 52 | TabBar::reSizeTo(rc); 53 | rc.left += margeValue; 54 | rc.top += margeValue; 55 | 56 | //-- We do those dirty things 57 | //-- because it's a "vertical" tab control 58 | if (_isVertical) 59 | { 60 | rc.right -= 40; 61 | rc.bottom -= 20; 62 | if (getRowCount() == 2) 63 | { 64 | rc.right -= 20; 65 | } 66 | } 67 | //-- end of dirty things 68 | rc.bottom -= 55; 69 | rc.right -= 20; 70 | 71 | (*_pWinVector)[_current]._dlg->reSizeTo(rc); 72 | (*_pWinVector)[_current]._dlg->redraw(); 73 | } 74 | 75 | bool ControlsTab::renameTab(const wchar_t *internalName, const wchar_t *newName) 76 | { 77 | bool foundIt = false; 78 | int i = 0; 79 | for ( ; i < static_cast (_pWinVector->size()) ; i++) 80 | { 81 | if ((*_pWinVector)[i]._internalName == internalName) 82 | { 83 | foundIt = true; 84 | break; 85 | } 86 | } 87 | if (!foundIt) 88 | return false; 89 | 90 | renameTab(i, newName); 91 | return true; 92 | } 93 | 94 | void ControlsTab::renameTab(int index, const wchar_t *newName) 95 | { 96 | TCITEM tie; 97 | tie.mask = TCIF_TEXT; 98 | tie.pszText = (wchar_t *)newName; 99 | TabCtrl_SetItem(_hSelf, index, &tie); 100 | } -------------------------------------------------------------------------------- /deps/Controls/TabBar/ControlsTab.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2003 Don HO 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either 7 | // version 2 of the License, or (at your option) any later version. 8 | // 9 | // Note that the GPL places important restrictions on "derived works", yet 10 | // it does not provide a detailed definition of that term. To avoid 11 | // misunderstandings, we consider an application to constitute a 12 | // "derivative work" for the purpose of this license if it does any of the 13 | // following: 14 | // 1. Integrates source code from Notepad++. 15 | // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable 16 | // installer, such as those produced by InstallShield. 17 | // 3. Links to a library or executes a program that does any of the above. 18 | // 19 | // This program is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with this program; if not, write to the Free Software 26 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 | 28 | #ifndef CONTROLS_TAB_H 29 | #define CONTROLS_TAB_H 30 | 31 | #include 32 | #include 33 | 34 | #ifndef TAB_BAR_H 35 | #include "TabBar.h" 36 | #endif //TAB_BAR_H 37 | 38 | typedef std::basic_string generic_string; 39 | struct DlgInfo { 40 | Window *_dlg; 41 | generic_string _name; 42 | generic_string _internalName; 43 | 44 | DlgInfo(Window *dlg, const wchar_t *name, const wchar_t *internalName = NULL): _dlg(dlg), _name(name), _internalName(internalName?internalName:TEXT("")) {}; 45 | }; 46 | 47 | typedef std::vector WindowVector; 48 | 49 | class ControlsTab : public TabBar 50 | { 51 | public : 52 | ControlsTab() : TabBar(), _pWinVector(NULL), _current(0){}; 53 | ~ControlsTab(){}; 54 | 55 | void initTabBar(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isTraditional = false, bool isMultiLine = false) override { 56 | _isVertical = isVertical; 57 | TabBar::initTabBar(hInst, hwnd, false, isTraditional, isMultiLine); 58 | }; 59 | void createTabs(WindowVector & winVector); 60 | 61 | void destroy() override { 62 | TabBar::destroy(); 63 | }; 64 | 65 | void reSizeTo(RECT & rc) override; 66 | void activateWindowAt(int index); 67 | 68 | void clickedUpdate() 69 | { 70 | int indexClicked = int(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); 71 | activateWindowAt(indexClicked); 72 | }; 73 | void renameTab(int index, const wchar_t *newName); 74 | bool renameTab(const wchar_t *internalName, const wchar_t *newName); 75 | 76 | private : 77 | WindowVector *_pWinVector; 78 | int _current; 79 | }; 80 | 81 | #endif //CONTROLS_TAB_H 82 | -------------------------------------------------------------------------------- /deps/Controls/Window.h: -------------------------------------------------------------------------------- 1 | // This file is part of Notepad++ project 2 | // Copyright (C)2003 Don HO 3 | // 4 | // This program is free software; you can redistribute it and/or 5 | // modify it under the terms of the GNU General Public License 6 | // as published by the Free Software Foundation; either 7 | // version 2 of the License, or (at your option) any later version. 8 | // 9 | // Note that the GPL places important restrictions on "derived works", yet 10 | // it does not provide a detailed definition of that term. To avoid 11 | // misunderstandings, we consider an application to constitute a 12 | // "derivative work" for the purpose of this license if it does any of the 13 | // following: 14 | // 1. Integrates source code from Notepad++. 15 | // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable 16 | // installer, such as those produced by InstallShield. 17 | // 3. Links to a library or executes a program that does any of the above. 18 | // 19 | // This program is distributed in the hope that it will be useful, 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | // GNU General Public License for more details. 23 | // 24 | // You should have received a copy of the GNU General Public License 25 | // along with this program; if not, write to the Free Software 26 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 | 28 | #ifndef WINDOW_CONTROL_H 29 | #define WINDOW_CONTROL_H 30 | 31 | #include 32 | 33 | class Window 34 | { 35 | public: 36 | Window(): _hInst(NULL), _hParent(NULL), _hSelf(NULL){}; 37 | virtual ~Window() {}; 38 | 39 | virtual void init(HINSTANCE hInst, HWND parent) 40 | { 41 | _hInst = hInst; 42 | _hParent = parent; 43 | } 44 | 45 | virtual void destroy() = 0; 46 | 47 | virtual void display(bool toShow = true, bool activate = true) const { 48 | if (toShow) 49 | ::ShowWindow(_hSelf, activate?SW_SHOW:SW_SHOWNOACTIVATE); 50 | else 51 | ::ShowWindow(_hSelf, SW_HIDE); 52 | }; 53 | 54 | virtual void reSizeTo(RECT & rc) // should NEVER be const !!! 55 | { 56 | ::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE); 57 | redraw(); 58 | }; 59 | 60 | virtual void reSizeToWH(RECT & rc) // should NEVER be const !!! 61 | { 62 | ::MoveWindow(_hSelf, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); 63 | redraw(); 64 | }; 65 | 66 | virtual void redraw(bool forceUpdate = false) const { 67 | ::InvalidateRect(_hSelf, NULL, TRUE); 68 | if (forceUpdate) 69 | ::UpdateWindow(_hSelf); 70 | }; 71 | 72 | virtual void getClientRect(RECT & rc) const { 73 | ::GetClientRect(_hSelf, &rc); 74 | }; 75 | 76 | virtual void getWindowRect(RECT & rc) const { 77 | ::GetWindowRect(_hSelf, &rc); 78 | }; 79 | 80 | virtual int getWidth() const { 81 | RECT rc; 82 | ::GetClientRect(_hSelf, &rc); 83 | return (rc.right - rc.left); 84 | }; 85 | 86 | virtual int getHeight() const { 87 | RECT rc; 88 | ::GetClientRect(_hSelf, &rc); 89 | if (::IsWindowVisible(_hSelf) == TRUE) 90 | return (rc.bottom - rc.top); 91 | return 0; 92 | }; 93 | 94 | virtual bool isVisible() const { 95 | return (::IsWindowVisible(_hSelf)?true:false); 96 | }; 97 | 98 | HWND getHSelf() const { 99 | //assert(_hSelf != 0); 100 | return _hSelf; 101 | }; 102 | 103 | HWND getHParent() const { 104 | return _hParent; 105 | }; 106 | 107 | void getFocus() const { 108 | ::SetFocus(_hSelf); 109 | }; 110 | 111 | HINSTANCE getHinst() const { 112 | //assert(_hInst != 0); 113 | return _hInst; 114 | }; 115 | protected: 116 | HINSTANCE _hInst; 117 | HWND _hParent; 118 | HWND _hSelf; 119 | }; 120 | 121 | #endif //WINDOW_CONTROL_H 122 | 123 | -------------------------------------------------------------------------------- /deps/FtpClient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (ftpclient) 3 | file (GLOB_RECURSE source_files *.cpp *.h) 4 | add_library (ftpclient STATIC ${source_files}) 5 | target_compile_definitions (ftpclient PRIVATE _UNICODE UNICODE) 6 | target_include_directories (ftpclient PUBLIC .) 7 | set_property(TARGET ftpclient PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 8 | -------------------------------------------------------------------------------- /deps/FtpClient/FTPListParse.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Code taken from D. J. Bernstein (C ==> C++) 4 | // 5 | // ftpparse.c, ftpparse.h: library for parsing FTP LIST responses 6 | // 20001223 7 | // D. J. Bernstein, djb@cr.yp.to 8 | // http://cr.yp.to/ftpparse.html 9 | // 10 | // Commercial use is fine, if you let me know what programs you're using this in. 11 | // 12 | // Currently covered formats: 13 | // EPLF. 14 | // UNIX ls, with or without gid. 15 | // Microsoft FTP Service. 16 | // Windows NT FTP Server. 17 | // VMS. 18 | // WFTPD. 19 | // NetPresenz (Mac). 20 | // NetWare. 21 | // MSDOS. 22 | // 23 | // Definitely not covered: 24 | // Long VMS filenames, with information split across two lines. 25 | // NCSA Telnet FTP server. Has LIST = NLST (and bad NLST for directories). 26 | // 27 | //////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef INC_FTPLISTPARSE_H 30 | #define INC_FTPLISTPARSE_H 31 | 32 | #include 33 | #include "Definements.h" 34 | #include "FTPClient.h" 35 | 36 | namespace nsFTP 37 | { 38 | 39 | class CFTPFileStatus; 40 | 41 | /// Implements the parsing of the string returned by the LIST command. 42 | class CFTPListParser : public CFTPClient::IFileListParser 43 | { 44 | public: 45 | CFTPListParser(); 46 | virtual ~CFTPListParser(); 47 | 48 | public: 49 | bool Parse(CFTPFileStatus& ftpFileStatus, const tstring& strLineToParse); 50 | 51 | private: 52 | bool IsEPLS(LPCTSTR pszLine); 53 | bool ParseEPLF(CFTPFileStatus& ftpFileStatus, LPCTSTR pszLine, int iLength); 54 | 55 | bool IsUNIXStyleListing(LPCTSTR pszLine); 56 | bool ParseUNIXStyleListing(CFTPFileStatus& ftpFileStatus, LPCTSTR pszLine, int iLength); 57 | 58 | bool IsMultiNetListing(LPCTSTR pszLine); 59 | bool ParseMultiNetListing(CFTPFileStatus& ftpFileStatus, LPCTSTR pszLine, int iLength); 60 | 61 | bool IsMSDOSListing(LPCTSTR pszLine); 62 | bool ParseMSDOSListing(CFTPFileStatus& ftpFileStatus, LPCTSTR pszLine, int iLength); 63 | 64 | bool CheckMonth(LPCTSTR pszBuffer, LPCTSTR pszMonthName) const; 65 | int GetMonth(LPCTSTR pszBuffer, int iLength) const; 66 | bool GetLong(LPCTSTR pszLong, int iLength, long& lResult) const; 67 | long GetYear(time_t time) const; 68 | 69 | long ToTAI(long lYear, long lMonth, long lMDay) const; 70 | long GuessTAI(long lMonth, long lMDay); 71 | 72 | private: 73 | time_t m_tmBase; // time() value on this OS at the beginning of 1970 TAI 74 | long m_lCurrentYear; // approximation to current year 75 | static const TCHAR* m_Months[12]; 76 | }; 77 | 78 | } 79 | 80 | #endif // INC_FTPLISTPARSE_H 81 | -------------------------------------------------------------------------------- /deps/Hunspell/AUTHORS: -------------------------------------------------------------------------------- 1 | Author of Hunspell: 2 | Németh László nemeth (at) numbertext.org 3 | 4 | Hunspell based on OpenOffice.org's Myspell. MySpell's author: 5 | Kevin Hendricks kevin.hendricks (at) sympatico.ca 6 | -------------------------------------------------------------------------------- /deps/Hunspell/AUTHORS.myspell: -------------------------------------------------------------------------------- 1 | Developer Credits: 2 | 3 | Special credit and thanks go to ispell's creator Geoff Kuenning. 4 | Ispell affix compression code was used as the basis for the 5 | affix code used in MySpell. Specifically Geoff's use of a 6 | conds[] array that makes it easy to check if the conditions 7 | required for a particular affix are present was very 8 | ingenious! Kudos to Geoff. Very nicely done. 9 | BTW: ispell is available under a BSD style license 10 | from Geoff Kuennings ispell website: 11 | http://www.cs.ucla.edu/ficus-members/geoff/ispell.html 12 | 13 | 14 | Kevin Hendricks is the original 15 | author and now maintainer of the MySpell codebase. Recent 16 | additions include ngram support, and related character maps 17 | to help improve and create suggestions for very poorly 18 | spelled words. 19 | 20 | Please send any and all contributions or improvements 21 | to him or to dev@lingucomponent.openoffice.org. 22 | 23 | 24 | David Einstein (Deinst@world.std.com) developed an almost 25 | complete rewrite of MySpell for use by the Mozilla project. 26 | David and I are now working on parallel development tracks 27 | to help our respective projects (Mozilla and OpenOffice.org) 28 | and we will maintain full affix file and dictionary file 29 | compatibility and work on merging our versions of MySpell 30 | back into a single tree. David has been a significant help 31 | in improving MySpell. 32 | 33 | 34 | Németh László is the author of 35 | the Hungarian dictionary and he developed and contributed 36 | extensive changes to MySpell including ... 37 | * code to support compound words in MySpell 38 | * fixed numerous problems with encoding case conversion tables. 39 | * designed/developed replacement tables to improve suggestions 40 | * changed affix file parsing to trees to greatly speed loading 41 | * removed the need for malloc/free pairs in suffix_check which 42 | speeds up spell checking in suffix rich languages by 20% 43 | 44 | Davide Prina , Giuseppe Modugno 45 | , Gianluca Turconi 46 | all from the it_IT OpenOffice.org team performed an 47 | extremely detailed code review of MySpell and generated 48 | fixes for bugs, leaks, and speedup improvements. 49 | 50 | Simon Brouwer for fixes and enhancements 51 | that have greatly improved MySpell auggestions 52 | * n-gram suggestions for an initcap word have an init. cap. 53 | * fix for too many n-gram suggestions from specialized dictionary, 54 | * fix for long suggestions rather than close ones in case of 55 | dictionaries with many compound words (kompuuter) 56 | * optionally disabling split-word suggestions (controlled 57 | by NOSPLITSUGS line in affix file) 58 | 59 | 60 | Special Thanks to all others who have either contributed ideas or 61 | testing for MySpell 62 | 63 | 64 | Thanks, 65 | 66 | Kevin Hendricks 67 | kevin.hendricks@sympatico.ca 68 | -------------------------------------------------------------------------------- /deps/Hunspell/BUGS: -------------------------------------------------------------------------------- 1 | * Interactive interface has some visualization problem with long lines 2 | 3 | * Experimental -U, -u options don't support Unicode. 4 | 5 | * Compound handling is not thread safe in Hungarian specific code. 6 | -------------------------------------------------------------------------------- /deps/Hunspell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (hunspell) 3 | file (GLOB_RECURSE source_files *.cxx *.hxx) 4 | list(REMOVE_ITEM source_files "${CMAKE_CURRENT_LIST_DIR}/src/hunspell/utf_info.cxx") 5 | add_library (hunspell STATIC ${source_files}) 6 | target_compile_definitions (hunspell PRIVATE HUNSPELL_STATIC _CRT_NONSTDC_NO_DEPRECATE) 7 | target_include_directories (hunspell PUBLIC src/) 8 | set_property(TARGET hunspell PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 9 | -------------------------------------------------------------------------------- /deps/Hunspell/ChangeLog.O: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/Hunspell/ChangeLog.O -------------------------------------------------------------------------------- /deps/Hunspell/HACKING: -------------------------------------------------------------------------------- 1 | To bump a release 2 | 3 | 1. edit... 4 | a) ./configure.ac 5 | b) ./msvc/Hunspell.rc 6 | c) ./msvc/config.h 7 | and convert release string X.Y.Z/X,Y,Z to the next version 8 | 9 | 2. autoconf && ./configure && make 10 | and the various strings will get updated by the build tooling 11 | -------------------------------------------------------------------------------- /deps/Hunspell/NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/Hunspell/NEWS -------------------------------------------------------------------------------- /deps/Hunspell/README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /deps/Hunspell/README.myspell: -------------------------------------------------------------------------------- 1 | MySpell is a simple spell checker that uses affix 2 | compression and is modelled after the spell checker 3 | ispell. 4 | 5 | MySpell was written to explore how affix compression 6 | can be implemented. 7 | 8 | The Main features of MySpell are: 9 | 10 | 1. written in C++ to make it easier to interface with 11 | Pspell, OpenOffice, AbiWord, etc 12 | 13 | 2. it is stateless, uses no static variables and 14 | should be completely reentrant with almost no 15 | ifdefs 16 | 17 | 3. it tries to be as compatible with ispell to 18 | the extent it can. It can read slightly modified 19 | versions of munched ispell dictionaries (and it 20 | comes with a munched english wordlist borrowed from 21 | Kevin Atkinson's excellent Aspell. 22 | 23 | 4. it uses a heavily modified aff file format that 24 | can be derived from ispell aff files but uses 25 | the iso-8859-X character sets only 26 | 27 | 5. it is simple with *lots* of comments that 28 | describes how the affixes are stored 29 | and tested for (based on the approach used by 30 | ispell). 31 | 32 | 6. it supports improved suggestions with replacement 33 | tables and ngram-scoring based mechanisms in addition 34 | to the main suggestion mechanisms 35 | 36 | 7. like ispell it has a BSD license (and no 37 | advertising clause) 38 | 39 | But ... it has *no* support for adding words 40 | to a personal dictionary, *no* support for converting 41 | between various text encodings, and *no* command line 42 | interface (it is purely meant to be a library). 43 | 44 | It can not (in any way) replace all of the functionality 45 | of ispell or aspell/pspell. It is meant as a learning 46 | tool for understanding affix compression and for 47 | being used by front ends like OpenOffice, Abiword, etc. 48 | 49 | MySpell has been tested under Linux and Solaris 50 | and has the world's simplest Makefile and no 51 | configure support. 52 | 53 | It does come with a simple example program that 54 | spell checks some words and returns suggestions. 55 | 56 | To build a static library and an example 57 | program under Linux simply type: 58 | 59 | tar -zxvf myspell.tar.gz 60 | cd myspell2 61 | make 62 | 63 | To run the example program: 64 | ./example ./en_US.aff ./en_US.dic checkme.lst 65 | 66 | Please play around with it and let me know 67 | what you think. 68 | 69 | Please see the file CONTRIBUTORS for more info. 70 | -------------------------------------------------------------------------------- /deps/Hunspell/THANKS: -------------------------------------------------------------------------------- 1 | Many thanks to the following contributors and supporters: 2 | 3 | Mehmet Akin 4 | Göran Andersson 5 | Lars Aronsson 6 | Ruud Baars 7 | Bartkó Zoltán 8 | Mathias Bauer 9 | Bencsáth Boldizsár 10 | Bíró Árpád 11 | Ingo H. de Boer 12 | Simon Brouwer 13 | Jeppe Bundsgaard 14 | Ginn Chen 15 | Tomáš Chvátal 16 | Aaron Digulla 17 | Dmitri Gabinski 18 | Dvornik László 19 | David Einstein 20 | Rene Engelhard 21 | Frederik Fouvry 22 | Flemming Frandsen 23 | Serge Gautherie 24 | Marek Gleń 25 | Gavins at OOo 26 | Gefferth András 27 | Godó Ferenc 28 | Goldman Eleonóra 29 | Steinar H. Gunderson 30 | Halácsy Péter 31 | Chris Halls 32 | Khaled Hosny 33 | Izsók András 34 | Björn Jacke 35 | Mike Tian-Jian Jiang 36 | Dafydd Jones 37 | Ryan Jones 38 | Jean-Christophe Helary 39 | Kevin Hendricks 40 | Martin Hollmichel 41 | Pavel Janík 42 | John Winters 43 | Mohamed Kebdani 44 | Kelemen Gábor 45 | Shewangizaw Gulilat 46 | Kéménczy Kálmán 47 | Dan Kenigsberg 48 | Pham Ngoc Khanh 49 | Khiraly László 50 | Koblinger Egmont 51 | Kornai András 52 | Tor Lillqvist 53 | Christian Lohmaier 54 | Robert Longson 55 | Marot at SF dot net 56 | Mark McClain 57 | Caolan McNamara 58 | Michael Meeks 59 | Moheb Mekhaiel 60 | Laurie Mercer 61 | Ladislav Michnovič 62 | Ellis Miller 63 | Giuseppe Modugno 64 | János Mohácsi 65 | Bram Moolenaar 66 | Daniel Naber 67 | Nagy Viktor 68 | John Nisly 69 | Noll János 70 | S Page 71 | Christophe Paris 72 | Malcolm Parsons 73 | Sylvain Paschein 74 | Volkov Peter 75 | Bryan Petty 76 | Harri Pitkänen 77 | Davide Prina 78 | Kevin F. Quinn 79 | Erdal Ronahi 80 | Olivier Ronez 81 | Bernhard Rosenkraenzer 82 | Sarlós Tamás 83 | Thobias Schlemmer 84 | Jan Seeger 85 | Jose da Silva 86 | Paulo Ney de Souza 87 | Roland Smith 88 | Munzir Taha 89 | Timeless at bemail dot org 90 | Tímár András 91 | Tonal at OOo 92 | Török László 93 | Trón Viktor 94 | Gianluca Turconi 95 | Ryan VanderMeulen 96 | Varga Dániel 97 | Elio Voci 98 | Miha Vrhovnik 99 | Martijn Wargers 100 | Michel Weimerskirch 101 | Brett Wilson 102 | Friedel Wolff 103 | Daniel Yacob 104 | Gábor Zahemszky 105 | Taha Zerrouki 106 | and others (see also AUTHORS.myspell) 107 | 108 | FSF.hu Foundation 109 | http://www.fsf.hu 110 | 111 | LibreOffice community 112 | http://www.libreoffice.org 113 | 114 | MOKK Research Centre 115 | Budapest University of Technology and Economics 116 | Sociology and Communications Department 117 | http://www.mokk.bme.hu 118 | 119 | Hungarian Ministry of Informatics and Telecommunications 120 | 121 | IMEDIA Kft. 122 | http://www.imedia.hu 123 | 124 | OpenOffice.org community 125 | http://www.openoffice.org 126 | 127 | OpenTaal Foundation, Netherlands and 128 | Dutch Language Union (Nederlandse Taalunie) 129 | http://opentaal.org 130 | 131 | UHU-Linux Kft. 132 | 133 | Thanks, 134 | 135 | Németh László 136 | nemeth at numbertext org 137 | -------------------------------------------------------------------------------- /deps/Hunspell/TODO: -------------------------------------------------------------------------------- 1 | * shared dictionaries for multi-user environment 2 | * improve compound handling 3 | * Unicode unmunch (munch) 4 | * forbiddenword and pseudoword support in unmunch 5 | -------------------------------------------------------------------------------- /deps/Hunspell/license.hunspell: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): 19 | * David Einstein 20 | * Davide Prina 21 | * Giuseppe Modugno 22 | * Gianluca Turconi 23 | * Simon Brouwer 24 | * Noll János 25 | * Bíró Árpád 26 | * Goldman Eleonóra 27 | * Sarlós Tamás 28 | * Bencsáth Boldizsár 29 | * Halácsy Péter 30 | * Dvornik László 31 | * Gefferth András 32 | * Nagy Viktor 33 | * Varga Dániel 34 | * Chris Halls 35 | * Rene Engelhard 36 | * Bram Moolenaar 37 | * Dafydd Jones 38 | * Harri Pitkänen 39 | * Andras Timar 40 | * Tor Lillqvist 41 | * 42 | * Alternatively, the contents of this file may be used under the terms of 43 | * either the GNU General Public License Version 2 or later (the "GPL"), or 44 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 45 | * in which case the provisions of the GPL or the LGPL are applicable instead 46 | * of those above. If you wish to allow use of your version of this file only 47 | * under the terms of either the GPL or the LGPL, and not to allow others to 48 | * use your version of this file under the terms of the MPL, indicate your 49 | * decision by deleting the provisions above and replace them with the notice 50 | * and other provisions required by the GPL or the LGPL. If you do not delete 51 | * the provisions above, a recipient may use your version of this file under 52 | * the terms of any one of the MPL, the GPL or the LGPL. 53 | * 54 | * ***** END LICENSE BLOCK ***** */ 55 | -------------------------------------------------------------------------------- /deps/Hunspell/license.myspell: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada 3 | * And Contributors. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * 3. All modifications to the source code must be clearly marked as 17 | * such. Binary redistributions based on modified source code 18 | * must be clearly marked as modified versions in the documentation 19 | * and/or other materials provided with the distribution. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS 22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 25 | * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * 35 | * NOTE: A special thanks and credit goes to Geoff Kuenning 36 | * the creator of ispell. MySpell's affix algorithms were 37 | * based on those of ispell which should be noted is 38 | * copyright Geoff Kuenning et.al. and now available 39 | * under a BSD style license. For more information on ispell 40 | * and affix compression in general, please see: 41 | * http://www.cs.ucla.edu/ficus-members/geoff/ispell.html 42 | * (the home page for ispell) 43 | * 44 | * An almost complete rewrite of MySpell for use by 45 | * the Mozilla project has been developed by David Einstein 46 | * (Deinst@world.std.com). David and I are now 47 | * working on parallel development tracks to help 48 | * our respective projects (Mozilla and OpenOffice.org 49 | * and we will maintain full affix file and dictionary 50 | * file compatibility and work on merging our versions 51 | * of MySpell back into a single tree. David has been 52 | * a significant help in improving MySpell. 53 | * 54 | * Special thanks also go to La'szlo' Ne'meth 55 | * who is the author of the 56 | * Hungarian dictionary and who developed and contributed 57 | * the code to support compound words in MySpell 58 | * and fixed numerous problems with the encoding 59 | * case conversion tables. 60 | * 61 | */ 62 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/atypes.hxx: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, 19 | * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, 20 | * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, 21 | * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, 22 | * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef ATYPES_HXX_ 39 | #define ATYPES_HXX_ 40 | 41 | #ifndef HUNSPELL_WARNING 42 | #include 43 | #ifdef HUNSPELL_WARNING_ON 44 | #define HUNSPELL_WARNING fprintf 45 | #else 46 | // empty inline function to switch off warnings (instead of the C99 standard 47 | // variadic macros) 48 | static inline void HUNSPELL_WARNING(FILE*, const char*, ...) {} 49 | #endif 50 | #endif 51 | 52 | // HUNSTEM def. 53 | #define HUNSTEM 54 | 55 | #include "w_char.hxx" 56 | #include 57 | #include 58 | #include 59 | 60 | #define SETSIZE 256 61 | #define CONTSIZE 65536 62 | 63 | // AffEntry options 64 | #define aeXPRODUCT (1 << 0) 65 | #define aeUTF8 (1 << 1) 66 | #define aeALIASF (1 << 2) 67 | #define aeALIASM (1 << 3) 68 | #define aeLONGCOND (1 << 4) 69 | 70 | // compound options 71 | #define IN_CPD_NOT 0 72 | #define IN_CPD_BEGIN 1 73 | #define IN_CPD_END 2 74 | #define IN_CPD_OTHER 3 75 | 76 | // info options 77 | #define SPELL_COMPOUND (1 << 0) 78 | #define SPELL_FORBIDDEN (1 << 1) 79 | #define SPELL_ALLCAP (1 << 2) 80 | #define SPELL_NOCAP (1 << 3) 81 | #define SPELL_INITCAP (1 << 4) 82 | #define SPELL_ORIGCAP (1 << 5) 83 | #define SPELL_WARN (1 << 6) 84 | 85 | #define MINCPDLEN 3 86 | #define MAXCOMPOUND 10 87 | #define MAXCONDLEN 20 88 | #define MAXCONDLEN_1 (MAXCONDLEN - sizeof(char*)) 89 | 90 | #define MAXACC 1000 91 | 92 | #define FLAG unsigned short 93 | #define FLAG_NULL 0x00 94 | #define FREE_FLAG(a) a = 0 95 | 96 | #define TESTAFF(a, b, c) (std::binary_search(a, a + c, b)) 97 | 98 | struct guessword { 99 | char* word; 100 | bool allow; 101 | char* orig; 102 | }; 103 | 104 | typedef std::vector mapentry; 105 | typedef std::vector flagentry; 106 | 107 | struct patentry { 108 | std::string pattern; 109 | std::string pattern2; 110 | std::string pattern3; 111 | FLAG cond; 112 | FLAG cond2; 113 | patentry() 114 | : cond(FLAG_NULL) 115 | , cond2(FLAG_NULL) { 116 | } 117 | }; 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/baseaffix.hxx: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, 19 | * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, 20 | * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, 21 | * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, 22 | * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef BASEAFF_HXX_ 39 | #define BASEAFF_HXX_ 40 | 41 | #include 42 | 43 | class AffEntry { 44 | private: 45 | AffEntry(const AffEntry&); 46 | AffEntry& operator=(const AffEntry&); 47 | 48 | public: 49 | AffEntry() 50 | : numconds(0), 51 | opts(0), 52 | aflag(0), 53 | morphcode(0), 54 | contclass(NULL), 55 | contclasslen(0) {} 56 | virtual ~AffEntry(); 57 | std::string appnd; 58 | std::string strip; 59 | unsigned char numconds; 60 | char opts; 61 | unsigned short aflag; 62 | union { 63 | char conds[MAXCONDLEN]; 64 | struct { 65 | char conds1[MAXCONDLEN_1]; 66 | char* conds2; 67 | } l; 68 | } c; 69 | char* morphcode; 70 | unsigned short* contclass; 71 | short contclasslen; 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/Hunspell/src/hunspell/config.h -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/htypes.hxx: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, 19 | * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, 20 | * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, 21 | * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, 22 | * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef HTYPES_HXX_ 39 | #define HTYPES_HXX_ 40 | 41 | #define ROTATE_LEN 5 42 | 43 | #define ROTATE(v, q) \ 44 | (v) = ((v) << (q)) | (((v) >> (32 - q)) & ((1 << (q)) - 1)); 45 | 46 | // hentry options 47 | #define H_OPT (1 << 0) 48 | #define H_OPT_ALIASM (1 << 1) 49 | #define H_OPT_PHON (1 << 2) 50 | 51 | // see also csutil.hxx 52 | #define HENTRY_WORD(h) &(h->word[0]) 53 | 54 | // approx. number of user defined words 55 | #define USERWORD 1000 56 | 57 | struct hentry { 58 | unsigned char blen; // word length in bytes 59 | unsigned char clen; // word length in characters (different for UTF-8 enc.) 60 | short alen; // length of affix flag vector 61 | unsigned short* astr; // affix flag vector 62 | struct hentry* next; // next word with same hash code 63 | struct hentry* next_homonym; // next homonym word (with same hash code) 64 | char var; // variable fields (only for special pronounciation yet) 65 | char word[1]; // variable-length word (8-bit or UTF-8 encoding) 66 | }; 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/hunvisapi.h: -------------------------------------------------------------------------------- 1 | #ifndef HUNSPELL_VISIBILITY_H_ 2 | #define HUNSPELL_VISIBILITY_H_ 3 | 4 | #if defined(HUNSPELL_STATIC) 5 | # define LIBHUNSPELL_DLL_EXPORTED 6 | #elif defined(_MSC_VER) 7 | # if defined(BUILDING_LIBHUNSPELL) 8 | # define LIBHUNSPELL_DLL_EXPORTED __declspec(dllexport) 9 | # else 10 | # define LIBHUNSPELL_DLL_EXPORTED __declspec(dllimport) 11 | # endif 12 | #elif defined(BUILDING_LIBHUNSPELL) && 1 13 | # define LIBHUNSPELL_DLL_EXPORTED __attribute__((__visibility__("default"))) 14 | #else 15 | # define LIBHUNSPELL_DLL_EXPORTED 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/hunvisapi.h.in: -------------------------------------------------------------------------------- 1 | #ifndef HUNSPELL_VISIBILITY_H_ 2 | #define HUNSPELL_VISIBILITY_H_ 3 | 4 | #if defined(HUNSPELL_STATIC) 5 | # define LIBHUNSPELL_DLL_EXPORTED 6 | #elif defined(_MSC_VER) 7 | # if defined(BUILDING_LIBHUNSPELL) 8 | # define LIBHUNSPELL_DLL_EXPORTED __declspec(dllexport) 9 | # else 10 | # define LIBHUNSPELL_DLL_EXPORTED __declspec(dllimport) 11 | # endif 12 | #elif defined(BUILDING_LIBHUNSPELL) && @HAVE_VISIBILITY@ 13 | # define LIBHUNSPELL_DLL_EXPORTED __attribute__((__visibility__("default"))) 14 | #else 15 | # define LIBHUNSPELL_DLL_EXPORTED 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/hunzip.hxx: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, 19 | * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, 20 | * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, 21 | * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, 22 | * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | /* hunzip: file decompression for sorted dictionaries with optional encryption, 39 | * algorithm: prefix-suffix encoding and 16-bit Huffman encoding */ 40 | 41 | #ifndef HUNZIP_HXX_ 42 | #define HUNZIP_HXX_ 43 | 44 | #include "hunvisapi.h" 45 | 46 | #include 47 | #include 48 | #include 49 | 50 | #define BUFSIZE 65536 51 | #define HZIP_EXTENSION ".hz" 52 | 53 | #define MSG_OPEN "error: %s: cannot open\n" 54 | #define MSG_FORMAT "error: %s: not in hzip format\n" 55 | #define MSG_MEMORY "error: %s: missing memory\n" 56 | #define MSG_KEY "error: %s: missing or bad password\n" 57 | 58 | struct bit { 59 | unsigned char c[2]; 60 | int v[2]; 61 | }; 62 | 63 | class LIBHUNSPELL_DLL_EXPORTED Hunzip { 64 | private: 65 | Hunzip(const Hunzip&); 66 | Hunzip& operator=(const Hunzip&); 67 | 68 | protected: 69 | char* filename; 70 | std::ifstream fin; 71 | int bufsiz, lastbit, inc, inbits, outc; 72 | std::vector dec; // code table 73 | char in[BUFSIZE]; // input buffer 74 | char out[BUFSIZE + 1]; // Huffman-decoded buffer 75 | char line[BUFSIZE + 50]; // decoded line 76 | int getcode(const char* key); 77 | int getbuf(); 78 | int fail(const char* err, const char* par); 79 | 80 | public: 81 | Hunzip(const char* filename, const char* key = NULL); 82 | ~Hunzip(); 83 | bool is_open() { return fin.is_open(); } 84 | bool getline(std::string& dest); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/langnum.hxx: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, 19 | * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, 20 | * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, 21 | * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, 22 | * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef LANGNUM_HXX_ 39 | #define LANGNUM_HXX_ 40 | 41 | /* 42 | language numbers for language specific codes 43 | see https://wiki.openoffice.org/w/index.php?title=Languages&oldid=230199 44 | */ 45 | 46 | enum { 47 | LANG_ar = 96, 48 | LANG_az = 100, // custom number 49 | LANG_bg = 41, 50 | LANG_ca = 37, 51 | LANG_cs = 42, 52 | LANG_da = 45, 53 | LANG_de = 49, 54 | LANG_el = 30, 55 | LANG_en = 01, 56 | LANG_es = 34, 57 | LANG_eu = 10, 58 | LANG_fr = 02, 59 | LANG_gl = 38, 60 | LANG_hr = 78, 61 | LANG_hu = 36, 62 | LANG_it = 39, 63 | LANG_la = 99, // custom number 64 | LANG_lv = 101, // custom number 65 | LANG_nl = 31, 66 | LANG_pl = 48, 67 | LANG_pt = 03, 68 | LANG_ru = 07, 69 | LANG_sv = 50, 70 | LANG_tr = 90, 71 | LANG_uk = 80, 72 | LANG_xx = 999 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/phonet.hxx: -------------------------------------------------------------------------------- 1 | /* phonetic.c - generic replacement aglogithms for phonetic transformation 2 | Copyright (C) 2000 Bjoern Jacke 3 | 4 | This library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License version 2.1 as published by the Free Software Foundation; 7 | 8 | This library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | Lesser General Public License for more details. 12 | 13 | You should have received a copy of the GNU Lesser General Public 14 | License along with this library; If not, see 15 | . 16 | 17 | Changelog: 18 | 19 | 2000-01-05 Bjoern Jacke 20 | Initial Release insprired by the article about phonetic 21 | transformations out of c't 25/1999 22 | 23 | 2007-07-26 Bjoern Jacke 24 | Released under MPL/GPL/LGPL tri-license for Hunspell 25 | 26 | 2007-08-23 Laszlo Nemeth 27 | Porting from Aspell to Hunspell using C-like structs 28 | */ 29 | 30 | #ifndef PHONET_HXX_ 31 | #define PHONET_HXX_ 32 | 33 | #define HASHSIZE 256 34 | #define MAXPHONETLEN 256 35 | #define MAXPHONETUTF8LEN (MAXPHONETLEN * 4) 36 | 37 | #include "hunvisapi.h" 38 | 39 | struct phonetable { 40 | char utf8; 41 | std::vector rules; 42 | int hash[HASHSIZE]; 43 | }; 44 | 45 | LIBHUNSPELL_DLL_EXPORTED void init_phonet_hash(phonetable& parms); 46 | 47 | LIBHUNSPELL_DLL_EXPORTED std::string phonet(const std::string& inword, 48 | phonetable& phone); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /deps/Hunspell/src/hunspell/w_char.hxx: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * Copyright (C) 2002-2017 Németh László 5 | * 6 | * The contents of this file are subject to the Mozilla Public License Version 7 | * 1.1 (the "License"); you may not use this file except in compliance with 8 | * the License. You may obtain a copy of the License at 9 | * http://www.mozilla.org/MPL/ 10 | * 11 | * Software distributed under the License is distributed on an "AS IS" basis, 12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing rights and limitations under the 14 | * License. 15 | * 16 | * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. 17 | * 18 | * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, 19 | * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, 20 | * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, 21 | * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, 22 | * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | #ifndef W_CHAR_HXX_ 39 | #define W_CHAR_HXX_ 40 | 41 | #include 42 | 43 | #ifndef GCC 44 | struct w_char { 45 | #else 46 | struct __attribute__((packed)) w_char { 47 | #endif 48 | unsigned char l; 49 | unsigned char h; 50 | 51 | friend bool operator<(const w_char a, const w_char b) { 52 | unsigned short a_idx = (a.h << 8) + a.l; 53 | unsigned short b_idx = (b.h << 8) + b.l; 54 | return a_idx < b_idx; 55 | } 56 | 57 | friend bool operator==(const w_char a, const w_char b) { 58 | return (((a).l == (b).l) && ((a).h == (b).h)); 59 | } 60 | 61 | friend bool operator!=(const w_char a, const w_char b) { 62 | return !(a == b);; 63 | } 64 | }; 65 | 66 | // two character arrays 67 | struct replentry { 68 | std::string pattern; 69 | std::string outstrings[4]; // med, ini, fin, isol 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /deps/aspell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (aspell) 3 | file (GLOB_RECURSE source_files *.cpp *.h) 4 | add_library (aspell STATIC ${source_files}) 5 | set_property(TARGET aspell PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 6 | target_include_directories(aspell PUBLIC .) 7 | -------------------------------------------------------------------------------- /deps/aspell/dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/aspell/dummy.cpp -------------------------------------------------------------------------------- /deps/json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (json) 3 | file (GLOB_RECURSE source_files *.hpp *.cpp) 4 | add_library (json STATIC ${source_files}) 5 | target_include_directories(json PUBLIC .) 6 | set_property(TARGET json PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 7 | -------------------------------------------------------------------------------- /deps/json/dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/json/dummy.cpp -------------------------------------------------------------------------------- /deps/lsignal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (lsignal) 3 | file (GLOB_RECURSE source_files *.cpp *.h) 4 | add_library (lsignal STATIC ${source_files}) 5 | target_include_directories(lsignal PUBLIC .) 6 | set_property(TARGET lsignal PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 7 | -------------------------------------------------------------------------------- /deps/lsignal/dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/lsignal/dummy.cpp -------------------------------------------------------------------------------- /deps/minizip/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (MiniZip) 3 | file (GLOB_RECURSE source_files *.c *.h) 4 | add_library (minizip STATIC ${source_files}) 5 | target_include_directories(minizip PUBLIC .) 6 | set_property(TARGET minizip PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 7 | -------------------------------------------------------------------------------- /deps/minizip/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /deps/minizip/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /deps/minizip/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /deps/minizip/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /deps/minizip/iowin32.h: -------------------------------------------------------------------------------- 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip 2 | Version 1.1, February 14h, 2010 3 | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) 4 | 5 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) 6 | 7 | Modifications for Zip64 support 8 | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 9 | 10 | For more info read MiniZip_info.txt 11 | 12 | */ 13 | 14 | #include 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 22 | void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); 23 | void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); 24 | void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /deps/minizip/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (Bytef*)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /deps/npp_extra/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.15) 2 | project (npp_extra) 3 | file (GLOB_RECURSE source_files *.cpp *.h) 4 | add_library (npp_extra STATIC ${source_files}) 5 | target_include_directories(npp_extra PUBLIC .) 6 | set_property(TARGET npp_extra PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 7 | -------------------------------------------------------------------------------- /deps/npp_extra/PluginInterface.h: -------------------------------------------------------------------------------- 1 | //this file is part of notepad++ 2 | //Copyright (C)2003 Don HO ( donho@altern.org ) 3 | // 4 | //This program is free software; you can redistribute it and/or 5 | //modify it under the terms of the GNU General Public License 6 | //as published by the Free Software Foundation; either 7 | //version 2 of the License, or (at your option) any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, 10 | //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | //GNU General Public License for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License 15 | //along with this program; if not, write to the Free Software 16 | //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | #ifndef PLUGININTERFACE_H 19 | #define PLUGININTERFACE_H 20 | 21 | #ifndef SCINTILLA_H 22 | #include "Scintilla.h" 23 | #endif //SCINTILLA_H 24 | 25 | #include 26 | 27 | // hardcoded in N++ currently: 28 | constexpr auto URL_INDIC = 8; 29 | 30 | const int nb_char = 64; 31 | 32 | class NppData { 33 | public: 34 | HWND npp_handle; 35 | HWND scintilla_main_handle; 36 | HWND scintilla_second_handle; 37 | }; 38 | 39 | typedef void (__cdecl * Pfuncplugincmd)(); 40 | 41 | struct ShortcutKey { 42 | bool is_ctrl; 43 | bool is_alt; 44 | bool is_shift; 45 | UCHAR key; 46 | }; 47 | 48 | struct FuncItem { 49 | wchar_t item_name[nb_char]; 50 | Pfuncplugincmd p_func; 51 | int cmd_id; 52 | bool init2_check; 53 | ShortcutKey* p_sh_key; 54 | }; 55 | 56 | // You should implement (or define an empty function body) those functions which are called by Notepad++ plugin manager 57 | // ReSharper disable CppInconsistentNaming 58 | extern "C" __declspec(dllexport) void setInfo(NppData); 59 | extern "C" __declspec(dllexport) const wchar_t* getName(); 60 | extern "C" __declspec(dllexport) FuncItem* getFuncsArray(int*); 61 | extern "C" __declspec(dllexport) void beNotified(SCNotification*); 62 | extern "C" __declspec(dllexport) LRESULT messageProc(UINT message, WPARAM w_param, LPARAM l_param); 63 | 64 | #ifdef UNICODE 65 | extern "C" __declspec(dllexport) BOOL isUnicode(); 66 | #endif //UNICODE 67 | // ReSharper restore CppInconsistentNaming 68 | 69 | #endif //PLUGININTERFACE_H 70 | -------------------------------------------------------------------------------- /deps/npp_extra/Sci_Position.h: -------------------------------------------------------------------------------- 1 | // Scintilla source code edit control 2 | /** @file Sci_Position.h 3 | ** Define the Sci_Position type used in Scintilla's external interfaces. 4 | ** These need to be available to clients written in C so are not in a C++ namespace. 5 | **/ 6 | // Copyright 2015 by Neil Hodgson 7 | // The License.txt file describes the conditions under which this software may be distributed. 8 | 9 | #ifndef SCI_POSITION_H 10 | #define SCI_POSITION_H 11 | 12 | #include 13 | 14 | // Basic signed type used throughout interface 15 | typedef ptrdiff_t Sci_Position; 16 | 17 | // Unsigned variant used for ILexer::Lex and ILexer::Fold 18 | typedef size_t Sci_PositionU; 19 | 20 | // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE 21 | typedef intptr_t Sci_PositionCR; 22 | 23 | #ifdef _WIN32 24 | #define SCI_METHOD __stdcall 25 | #else 26 | #define SCI_METHOD 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /deps/npp_extra/dummy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/deps/npp_extra/dummy.cpp -------------------------------------------------------------------------------- /deps/win-iconv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(win_iconv) 2 | 3 | cmake_minimum_required(VERSION 3.15) 4 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) 5 | 6 | set(CPACK_GENERATOR "TBZ2") 7 | include(CPack) 8 | 9 | option(WINICONV_BUILD_TEST "build test executable" OFF) 10 | 11 | if(WINICONV_BUILD_TEST) 12 | enable_testing() 13 | endif(WINICONV_BUILD_TEST) 14 | 15 | if(MSVC) 16 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 17 | endif(MSVC) 18 | 19 | if(BUILD_EXECUTABLE) 20 | add_executable(win_iconv win_iconv.c) 21 | set_target_properties(win_iconv PROPERTIES COMPILE_FLAGS "-DMAKE_EXE") 22 | if(WINCE) 23 | target_link_libraries(win_iconv ${WCECOMPAT_LIBRARIES}) 24 | endif(WINCE) 25 | install(TARGETS win_iconv RUNTIME DESTINATION bin 26 | LIBRARY DESTINATION lib 27 | ARCHIVE DESTINATION lib) 28 | endif(BUILD_EXECUTABLE) 29 | 30 | add_library(iconv-static STATIC win_iconv.c) 31 | set_property(TARGET iconv-static PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 32 | set_target_properties(iconv-static PROPERTIES OUTPUT_NAME "iconv") 33 | if(WINCE) 34 | target_link_libraries(iconv-static ${WCECOMPAT_LIBRARIES}) 35 | endif(WINCE) 36 | install(TARGETS iconv-static RUNTIME DESTINATION bin 37 | LIBRARY DESTINATION lib 38 | ARCHIVE DESTINATION lib) 39 | 40 | 41 | install(FILES iconv.h DESTINATION include) 42 | 43 | if(WINICONV_BUILD_TEST) 44 | # tests: 45 | add_executable(win_iconv_test win_iconv_test.c) 46 | add_test(win_iconv_test win_iconv_test) 47 | if(WINCE) 48 | target_link_libraries(win_iconv_test ${WCECOMPAT_LIBRARIES}) 49 | endif(WINCE) 50 | endif(WINICONV_BUILD_TEST) 51 | -------------------------------------------------------------------------------- /deps/win-iconv/FindWcecompat.cmake: -------------------------------------------------------------------------------- 1 | # Try to find Wcecompat functionality 2 | # Once done this will define 3 | # 4 | # WCECOMPAT_FOUND - system has Wcecompat 5 | # WCECOMPAT_INCLUDE_DIR - Wcecompat include directory 6 | # WCECOMPAT_LIBRARIES - Libraries needed to use Wcecompat 7 | # 8 | # Copyright (c) 2010, Andreas Holzammer, 9 | # 10 | # Redistribution and use is allowed according to the terms of the BSD license. 11 | 12 | if(WCECOMPAT_INCLUDE_DIR AND WCECOMPAT_LIB_FOUND) 13 | set(Wcecompat_FIND_QUIETLY TRUE) 14 | endif(WCECOMPAT_INCLUDE_DIR AND WCECOMPAT_LIB_FOUND) 15 | 16 | find_path(WCECOMPAT_INCLUDE_DIR errno.h PATH_SUFFIXES wcecompat) 17 | 18 | set(WCECOMPAT_LIB_FOUND FALSE) 19 | 20 | if(WCECOMPAT_INCLUDE_DIR) 21 | find_library(WCECOMPAT_LIBRARIES NAMES wcecompat wcecompatex ) 22 | if(WCECOMPAT_LIBRARIES) 23 | set(WCECOMPAT_LIB_FOUND TRUE) 24 | endif(WCECOMPAT_LIBRARIES) 25 | endif(WCECOMPAT_INCLUDE_DIR) 26 | 27 | # I have no idea what this is about, but it seems to be used quite often, so I add this here 28 | set(WCECOMPAT_CONST const) 29 | 30 | include(FindPackageHandleStandardArgs) 31 | find_package_handle_standard_args(Wcecompat DEFAULT_MSG WCECOMPAT_LIBRARIES WCECOMPAT_LIB_FOUND) 32 | 33 | mark_as_advanced(WCECOMPAT_INCLUDE_DIR WCECOMPAT_LIBRARIES WCECOMPAT_CONST WCECOMPAT_LIB_FOUND) 34 | -------------------------------------------------------------------------------- /deps/win-iconv/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for win-iconv 2 | # 3 | # Variables that can be overridden: 4 | # 5 | # CC, AR, RANLIB, DLLTOOL 6 | # MKDIR_P, INSTALL, RM 7 | # prefix, BINARY_PATH, INCLUDE_PATH, LIBRARY_PATH 8 | 9 | CC ?= gcc 10 | AR ?= ar 11 | RANLIB ?= ranlib 12 | DLLTOOL ?= dlltool 13 | 14 | MKDIR_P = mkdir -p 15 | INSTALL = install -c 16 | RM = rm -f 17 | 18 | # comma separated list (e.g. "iconv.dll,libiconv.dll") 19 | DEFAULT_LIBICONV_DLL ?= \"\" 20 | 21 | CFLAGS += -pedantic -Wall 22 | CFLAGS += -DUSE_LIBICONV_DLL 23 | CFLAGS += -DDEFAULT_LIBICONV_DLL=$(DEFAULT_LIBICONV_DLL) 24 | 25 | prefix ?= /usr/local 26 | BINARY_PATH = $(prefix)/bin 27 | INCLUDE_PATH = $(prefix)/include 28 | LIBRARY_PATH = $(prefix)/lib 29 | 30 | all: iconv.dll libiconv.a win_iconv.exe 31 | 32 | dist: test win_iconv.zip 33 | 34 | iconv.dll: win_iconv.c 35 | $(CC) $(CFLAGS) -c win_iconv.c -DMAKE_DLL 36 | $(CC) -shared -o iconv.dll -Wl,-s -Wl,--out-implib=libiconv.dll.a -Wl,--export-all-symbols win_iconv.o $(SPECS_FLAGS) 37 | 38 | libiconv.a: win_iconv.c 39 | $(CC) $(CFLAGS) -c win_iconv.c 40 | $(AR) rcs libiconv.a win_iconv.o 41 | $(RANLIB) libiconv.a 42 | 43 | win_iconv.exe: win_iconv.c 44 | $(CC) $(CFLAGS) -s -o win_iconv.exe win_iconv.c -DMAKE_EXE 45 | 46 | libmlang.a: mlang.def 47 | $(DLLTOOL) --kill-at --input-def mlang.def --output-lib libmlang.a 48 | 49 | test: 50 | $(CC) $(CFLAGS) -s -o win_iconv_test.exe win_iconv_test.c 51 | ./win_iconv_test.exe 52 | 53 | win_iconv.zip: msvcrt msvcr70 msvcr71 54 | rm -rf win_iconv 55 | svn export . win_iconv 56 | cp msvcrt/iconv.dll msvcrt/win_iconv.exe win_iconv/ 57 | mkdir win_iconv/msvcr70 58 | cp msvcr70/iconv.dll win_iconv/msvcr70/ 59 | mkdir win_iconv/msvcr71 60 | cp msvcr71/iconv.dll win_iconv/msvcr71/ 61 | zip -r win_iconv.zip win_iconv 62 | 63 | msvcrt: 64 | svn export . msvcrt; \ 65 | cd msvcrt; \ 66 | $(MAKE); 67 | 68 | msvcr70: 69 | svn export . msvcr70; \ 70 | cd msvcr70; \ 71 | gcc -dumpspecs | sed s/-lmsvcrt/-lmsvcr70/ > specs; \ 72 | $(MAKE) "SPECS_FLAGS=-specs=$$PWD/specs"; 73 | 74 | msvcr71: 75 | svn export . msvcr71; \ 76 | cd msvcr71; \ 77 | gcc -dumpspecs | sed s/-lmsvcrt/-lmsvcr71/ > specs; \ 78 | $(MAKE) "SPECS_FLAGS=-specs=$$PWD/specs"; 79 | 80 | install: iconv.dll libiconv.a win_iconv.exe 81 | -@$(MKDIR_P) '$(DESTDIR)$(BINARY_PATH)' 82 | -@$(MKDIR_P) '$(DESTDIR)$(INCLUDE_PATH)' 83 | -@$(MKDIR_P) '$(DESTDIR)$(LIBRARY_PATH)' 84 | -$(INSTALL) iconv.dll '$(DESTDIR)$(BINARY_PATH)' 85 | -$(INSTALL) win_iconv.exe '$(DESTDIR)$(BINARY_PATH)' 86 | -$(INSTALL) -m 0644 iconv.h '$(DESTDIR)$(INCLUDE_PATH)' 87 | -$(INSTALL) -m 0644 libiconv.dll.a '$(DESTDIR)$(LIBRARY_PATH)' 88 | -$(INSTALL) -m 0644 libiconv.a '$(DESTDIR)$(LIBRARY_PATH)' 89 | 90 | uninstall: 91 | -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/libiconv.a 92 | -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/libiconv.dll.a 93 | -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/iconv.h 94 | -$(RM) '$(DESTDIR)$(BINARY_PATH)'/win_iconv.exe 95 | -$(RM) '$(DESTDIR)$(BINARY_PATH)'/iconv.dll 96 | 97 | clean: 98 | rm -f win_iconv.exe 99 | rm -f win_iconv.o 100 | rm -f iconv.dll* 101 | rm -f libiconv.a 102 | rm -f libiconv.dll 103 | rm -f win_iconv_test.exe 104 | rm -f libmlang.a 105 | rm -rf win_iconv 106 | rm -rf win_iconv.zip 107 | rm -rf msvcrt 108 | rm -rf msvcr70 109 | rm -rf msvcr71 110 | 111 | -------------------------------------------------------------------------------- /deps/win-iconv/iconv.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | iconv 3 | iconv_open 4 | iconv_close 5 | iconvctl 6 | libiconv=iconv 7 | libiconv_open=iconv_open 8 | libiconv_close=iconv_close 9 | libiconvctl=iconvctl 10 | ;; libiconv-1.11.dll 11 | ;; TODO for binary compatibility 12 | ; _libiconv_version @1 13 | ; aliases2_lookup @2 14 | ; aliases_lookup @3 15 | ; iconv_canonicalize @4 16 | ; libiconv @5 17 | ; libiconv_close @6 18 | ; libiconv_open @7 19 | ; libiconv_relocate @8 20 | ; libiconv_set_relocation_prefix @9 21 | ; libiconvctl @10 22 | ; libiconvlist @11 23 | ; locale_charset @12 24 | -------------------------------------------------------------------------------- /deps/win-iconv/iconv.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBICONV_H 2 | #define _LIBICONV_H 3 | #include 4 | #ifndef WINICONV_CONST 5 | # ifdef ICONV_CONST 6 | # define WINICONV_CONST ICONV_CONST 7 | # else 8 | # define WINICONV_CONST const 9 | # endif 10 | #endif 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | typedef void* iconv_t; 15 | iconv_t iconv_open(const char *tocode, const char *fromcode); 16 | int iconv_close(iconv_t cd); 17 | size_t iconv(iconv_t cd, WINICONV_CONST char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /deps/win-iconv/mlang.def: -------------------------------------------------------------------------------- 1 | LIBRARY MLANG.DLL 2 | EXPORTS 3 | ConvertINetMultiByteToUnicode@24 4 | ;; ConvertINetReset (not documented) 5 | ConvertINetString@28 6 | ConvertINetUnicodeToMultiByte@24 7 | IsConvertINetStringAvailable@8 8 | LcidToRfc1766A@12 9 | LcidToRfc1766W@12 10 | Rfc1766ToLcidA@8 11 | Rfc1766ToLcidW@8 12 | -------------------------------------------------------------------------------- /deps/win-iconv/mlang.h: -------------------------------------------------------------------------------- 1 | HRESULT WINAPI ConvertINetString( 2 | LPDWORD lpdwMode, 3 | DWORD dwSrcEncoding, 4 | DWORD dwDstEncoding, 5 | LPCSTR lpSrcStr, 6 | LPINT lpnSrcSize, 7 | LPBYTE lpDstStr, 8 | LPINT lpnDstSize 9 | ); 10 | 11 | HRESULT WINAPI ConvertINetMultiByteToUnicode( 12 | LPDWORD lpdwMode, 13 | DWORD dwSrcEncoding, 14 | LPCSTR lpSrcStr, 15 | LPINT lpnMultiCharCount, 16 | LPWSTR lpDstStr, 17 | LPINT lpnWideCharCount 18 | ); 19 | 20 | HRESULT WINAPI ConvertINetUnicodeToMultiByte( 21 | LPDWORD lpdwMode, 22 | DWORD dwEncoding, 23 | LPCWSTR lpSrcStr, 24 | LPINT lpnWideCharCount, 25 | LPSTR lpDstStr, 26 | LPINT lpnMultiCharCount 27 | ); 28 | 29 | HRESULT WINAPI IsConvertINetStringAvailable( 30 | DWORD dwSrcEncoding, 31 | DWORD dwDstEncoding 32 | ); 33 | 34 | HRESULT WINAPI LcidToRfc1766A( 35 | LCID Locale, 36 | LPSTR pszRfc1766, 37 | int nChar 38 | ); 39 | 40 | HRESULT WINAPI LcidToRfc1766W( 41 | LCID Locale, 42 | LPWSTR pszRfc1766, 43 | int nChar 44 | ); 45 | 46 | HRESULT WINAPI Rfc1766ToLcidA( 47 | LCID *pLocale, 48 | LPSTR pszRfc1766 49 | ); 50 | 51 | HRESULT WINAPI Rfc1766ToLcidW( 52 | LCID *pLocale, 53 | LPWSTR pszRfc1766 54 | ); 55 | -------------------------------------------------------------------------------- /deps/win-iconv/readme.txt: -------------------------------------------------------------------------------- 1 | win_iconv is a iconv implementation using Win32 API to convert. 2 | 3 | win_iconv is placed in the public domain. 4 | 5 | ENVIRONMENT VARIABLE: 6 | WINICONV_LIBICONV_DLL 7 | If $WINICONV_LIBICONV_DLL is set, win_iconv uses the DLL. If 8 | loading the DLL or iconv_open() failed, falls back to internal 9 | conversion. If a few DLL are specified as comma separated list, 10 | the first loadable DLL is used. The DLL should have 11 | iconv_open(), iconv_close() and iconv(). Or libiconv_open(), 12 | libiconv_close() and libiconv(). 13 | (only available when USE_LIBICONV_DLL is defined at compile time) 14 | 15 | Win32 API does not support strict encoding conversion for some codepage. 16 | And MLang function drops or replaces invalid bytes and does not return 17 | useful error status as iconv does. This implementation cannot be used for 18 | encoding validation purpose. 19 | 20 | Yukihiro Nakadaira 21 | -------------------------------------------------------------------------------- /include/PluginMsg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DSPELLCHECK_SETLANG_MSG 1 // See DSpellCheckSetLangMsgInfo 4 | #define DSPELLCHECK_GETLANGUAGELIST_MSG 2 // See DSpellCheckGetLanguageListMsgInfo 5 | #define DSPELLCHECK_ENABLESPELLCHECK_MSG 3 // See DSpellCheckEnableSpellCheckMsgInfo 6 | 7 | // Set language to lang_name, if was_success non-zero, it will be set to true in case of success and fales in case of failure 8 | struct DSpellCheckSetLangMsgInfo { 9 | const wchar_t *lang_name; 10 | bool *was_success; // optional out param, pointed bool set to true if language was switched 11 | }; 12 | 13 | // language_callback will be called once for each language with payload provided as a second struct element 14 | struct DSpellCheckGetLanguageListMsgInfo { 15 | void (*language_callback)(void *payload, const wchar_t *lang_name); 16 | void *payload; 17 | }; 18 | 19 | struct DSpellCheckEnableSpellCheckMsgInfo { 20 | bool enabled; 21 | }; 22 | -------------------------------------------------------------------------------- /src/common/IniWorker.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | class IniWorker { 18 | public: 19 | enum class Action { 20 | save, 21 | load, 22 | }; 23 | 24 | explicit IniWorker(std::wstring_view app_name, std::wstring_view file_name, Action action); 25 | void process(const wchar_t *name, std::wstring &value, std::wstring_view default_value, bool in_quotes = false) const; 26 | void process(const wchar_t *name, int &value, int default_value) const; 27 | // Enums are currently processed as ints. This is no good but supporting backwards compatibility would be required to upgrade this 28 | template >...> 29 | void process(const wchar_t *name, EnumT &value, EnumT default_value) const { 30 | using UType = std::underlying_type_t; 31 | auto u_value = static_cast(value); 32 | process(name, u_value, static_cast(default_value)); 33 | value = static_cast(u_value); 34 | } 35 | 36 | void process_utf8(const wchar_t *name, std::string &value, const char *default_value, bool in_quotes = false) const; 37 | 38 | void process(const wchar_t *name, bool &value, bool default_value) const; 39 | Action get_action() const { return m_action; } 40 | 41 | private: 42 | std::wstring m_app_name; 43 | std::wstring m_file_name; 44 | Action m_action; 45 | }; 46 | -------------------------------------------------------------------------------- /src/common/MappedWstring.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | template 18 | class MappedWstringGeneric { 19 | public: 20 | IndexType to_original_index(IndexType cur_index) const { return !mapping.empty() ? mapping[cur_index] : cur_index; } 21 | 22 | IndexType from_original_index(IndexType cur_index) const { 23 | return !mapping.empty() ? static_cast(std::lower_bound(mapping.begin(), mapping.end(), cur_index) - mapping.begin()) : cur_index; 24 | } 25 | 26 | IndexType original_length() const { return !mapping.empty() ? mapping.back() : static_cast(str.size()); } 27 | 28 | void append(const MappedWstringGeneric &other) { 29 | if (!str.empty() && !other.str.empty()) 30 | str.push_back(L'\n'); 31 | str.insert(str.end(), other.str.begin(), other.str.end()); 32 | mapping.insert(mapping.end(), other.mapping.begin(), other.mapping.end()); 33 | } 34 | 35 | public: 36 | std::wstring str; 37 | std::vector mapping; // should have size str.length () or empty (if empty mapping is identity a<->a) 38 | // indices should correspond to offsets string `str` had in original encoding 39 | }; 40 | -------------------------------------------------------------------------------- /src/common/PrecompiledHeader.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "PrecompiledHeader.h" 16 | -------------------------------------------------------------------------------- /src/common/PrecompiledHeader.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #define NOMINMAX 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #pragma warning(push) 40 | #pragma warning(disable: 4091) 41 | #include "Shlobj.h" 42 | #pragma warning(pop) 43 | 44 | #include "plugin/Plugin.h" // plugin should be available everywhere to provide acess to rc_str function 45 | #include "plugin/resource.h" // resource should be available everywhere to have acess to string ids 46 | 47 | using namespace std::literals; 48 | -------------------------------------------------------------------------------- /src/common/ProgressData.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "ProgressData.h" 16 | 17 | void ProgressData::set(int progress, const std::wstring &status, bool marquee) { 18 | std::lock_guard lg(m_mutex); 19 | m_progress = progress; 20 | m_status = status; 21 | m_marquee = marquee; 22 | } 23 | 24 | bool ProgressData::get_marquee() const { 25 | std::lock_guard lg(m_mutex); 26 | return m_marquee; 27 | } 28 | 29 | int ProgressData::get_progress() const { 30 | std::lock_guard lg(m_mutex); 31 | return m_progress; 32 | } 33 | 34 | std::wstring ProgressData::get_status() const { 35 | std::lock_guard lg(m_mutex); 36 | return m_status; 37 | } 38 | -------------------------------------------------------------------------------- /src/common/ProgressData.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | class ProgressData { 18 | public: 19 | void set(int progress, const std::wstring &status, bool marquee = false); 20 | bool get_marquee() const; 21 | int get_progress() const; 22 | std::wstring get_status() const; 23 | 24 | private: 25 | int m_progress = 0; 26 | std::wstring m_status; 27 | mutable std::mutex m_mutex; 28 | bool m_marquee = false; 29 | }; 30 | -------------------------------------------------------------------------------- /src/common/TaskWrapper.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "TaskWrapper.h" 16 | 17 | TaskWrapper::TaskWrapper(HWND target_hwnd) 18 | : m_target_hwnd(target_hwnd), m_valid(true) { 19 | } 20 | 21 | TaskWrapper::~TaskWrapper() { 22 | if (m_valid.get()) 23 | cancel(); 24 | } 25 | 26 | void TaskWrapper::reset_alive_status() { 27 | m_alive_status = {new concurrency::cancellation_token_source(), []( 28 | concurrency::cancellation_token_source *source) { 29 | source->cancel(); 30 | delete source; 31 | }}; 32 | } 33 | 34 | void TaskWrapper::cancel() { 35 | if (m_alive_status) { 36 | m_alive_status->cancel(); 37 | m_alive_status.reset(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/common/TaskWrapper.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "Utility.h" 18 | #include "common/move_only.h" 19 | 20 | #include 21 | 22 | class CallbackData { 23 | public: 24 | std::weak_ptr alive_status; 25 | std::function callback; 26 | }; 27 | 28 | class TaskWrapper { 29 | private: 30 | using AliveStatusType = std::shared_ptr; 31 | using Self = TaskWrapper; 32 | 33 | public: 34 | explicit TaskWrapper(HWND target_hwnd); 35 | TaskWrapper(Self &&) = default; 36 | Self &operator=(Self &&) = default; 37 | ~TaskWrapper(); 38 | void reset_alive_status(); 39 | void cancel(); 40 | 41 | template 42 | void do_deferred(ActionType action, GuiCallbackType gui_callback) { 43 | reset_alive_status(); 44 | concurrency::create_task( 45 | [ 46 | action = std::move(action), 47 | guiCallback = std::move(gui_callback), 48 | as = weaken(m_alive_status), 49 | ctoken = m_alive_status->get_token(), 50 | hwnd = m_target_hwnd 51 | ]() { 52 | auto ret = action(ctoken); 53 | if (as.expired() || ctoken.is_canceled()) 54 | return; 55 | 56 | auto cb_data = std::make_unique(); 57 | cb_data->callback = [guiCallback = std::move(guiCallback), ret = std::move(ret)]()mutable { guiCallback(std::move(ret)); }; 58 | cb_data->alive_status = as; 59 | PostMessage(hwnd, 60 | get_custom_gui_message_id(CustomGuiMessage::generic_callback), reinterpret_cast(cb_data.release()) 61 | , 0); 62 | }); 63 | } 64 | 65 | private: 66 | HWND m_target_hwnd = nullptr; 67 | AliveStatusType m_alive_status; 68 | move_only m_valid; 69 | }; 70 | -------------------------------------------------------------------------------- /src/common/TemporaryAcessor.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | template 20 | class TemporaryAcessor { 21 | public: 22 | TemporaryAcessor(HeldType &held, std::function finalizer) 23 | : m_held(held), m_finalizer(std::move(finalizer)) { 24 | } 25 | 26 | auto &operator*() { return m_held; } 27 | auto &operator*() const { return m_held; } 28 | auto operator->() { return &m_held; } 29 | auto operator->() const { return &m_held; } 30 | ~TemporaryAcessor() { m_finalizer(); } 31 | 32 | private: 33 | HeldType &m_held; 34 | std::function m_finalizer; 35 | }; 36 | -------------------------------------------------------------------------------- /src/common/Win32Exception.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "Win32Exception.h" 16 | 17 | #include "Utility.h" 18 | 19 | #include 20 | #include 21 | 22 | namespace { 23 | 24 | struct LocalFreeHelper { 25 | void operator()(void *toFree) const { 26 | ::LocalFree(toFree); 27 | }; 28 | }; 29 | 30 | std::string get_win32_error_msg(DWORD error_code) { 31 | std::unique_ptr buff; 32 | LPWSTR buf_ptr = nullptr; 33 | DWORD buf_len = 0; 34 | if (error_code >= INTERNET_ERROR_BASE && error_code <= INTERNET_ERROR_LAST) { 35 | buf_len = ::FormatMessageW( 36 | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, GetModuleHandle(L"wininet.dll"), 37 | error_code, 0, reinterpret_cast(&buf_ptr), 0, nullptr); 38 | } else { 39 | assert(false); // unsupported 40 | } 41 | buff.reset(buf_ptr); 42 | auto str = to_utf8_string({buff.get(), buf_len}); 43 | return str; 44 | } 45 | 46 | } // namespace 47 | 48 | void throw_if_error() { 49 | auto err = GetLastError(); 50 | if (err != ERROR_SUCCESS) 51 | throw Win32Exception(std::to_string(err) + " - " + get_win32_error_msg(err)); 52 | } 53 | -------------------------------------------------------------------------------- /src/common/Win32Exception.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | class Win32Exception : public std::runtime_error { 18 | using Parent = std::runtime_error; 19 | 20 | public: 21 | Win32Exception(const std::string &message) 22 | : Parent{message} { 23 | } 24 | }; 25 | 26 | void throw_if_error(); 27 | 28 | template T throw_if_error(T ret_val) { 29 | throw_if_error(); 30 | return ret_val; 31 | } 32 | -------------------------------------------------------------------------------- /src/common/WinApiControls.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "enum_range.h" 17 | #include "lsignal.h" 18 | 19 | enum class DlgProcResult { 20 | processed, 21 | pass_through 22 | }; 23 | 24 | namespace WinApi { 25 | class WinBase { 26 | public: 27 | virtual ~WinBase(); 28 | void set_enabled(bool enabled); 29 | bool is_enabled() const; 30 | void init(HWND hwnd); 31 | virtual DlgProcResult dlg_proc(UINT message, WPARAM w_param, LPARAM l_param); // should be called for possibility of making signals in windows work 32 | explicit operator bool() const; 33 | bool was_inited() const; 34 | 35 | private: 36 | virtual void check_hwnd() = 0; 37 | 38 | virtual void init_impl() { 39 | } 40 | 41 | protected: 42 | HWND m_hwnd = nullptr; 43 | int m_id = -1; 44 | }; 45 | 46 | class ComboBox : public WinBase { 47 | void check_hwnd() override; 48 | 49 | public: 50 | template void add_item(EnumType val) { 51 | add_item(gui_string(val).c_str(), static_cast(val)); 52 | } 53 | 54 | template void add_items() { 55 | static_assert(std::is_enum_v); 56 | for (auto val : enum_range()) { 57 | add_item(gui_string(val).c_str(), static_cast(val)); 58 | } 59 | } 60 | 61 | void add_item(const wchar_t *text, int data = -1) { 62 | ComboBox_AddString(m_hwnd, text); 63 | ComboBox_SetItemData(m_hwnd, ComboBox_GetCount(m_hwnd) - 1, data); 64 | } 65 | 66 | int current_index() const; 67 | std::wstring current_text() const; 68 | int current_data() const; 69 | void set_current_index(int index); 70 | 71 | std::optional find_by_data(int data); 72 | void clear(); 73 | int count() const; 74 | }; 75 | 76 | class Button : public WinBase { 77 | void check_hwnd() override; 78 | public: 79 | DlgProcResult dlg_proc(UINT message, WPARAM w_param, LPARAM l_param) override; 80 | lsignal::signal button_pressed; 81 | }; 82 | 83 | template class EnumComboBox : protected ComboBox { 84 | using Parent = ComboBox; 85 | 86 | public: 87 | using Parent::init; 88 | using Parent::set_enabled; 89 | using Parent::clear; 90 | using Parent::add_item; 91 | 92 | EnumType current_data() const { return static_cast(Parent::current_data()); } 93 | 94 | void set_current(EnumType value) { 95 | if (!was_inited()) 96 | return; 97 | set_current_index(*find_by_data(static_cast>(value))); 98 | } 99 | 100 | private: 101 | void init_impl() override { this->add_items(); } 102 | }; 103 | 104 | class Timer { 105 | public: 106 | Timer(HWND hwnd); 107 | ~Timer(); 108 | void set_resolution(std::chrono::milliseconds resolution); 109 | void stop_timer(); 110 | bool is_set() const; 111 | 112 | lsignal::signal on_timer_tick; 113 | 114 | private: 115 | void do_register(); 116 | void unregister(); 117 | void kill_timer(); 118 | void generate_id(); 119 | void initialize(); 120 | 121 | private: 122 | HWND m_hwnd = nullptr; 123 | UINT_PTR m_id = 0; 124 | std::optional current_resolution; 125 | }; 126 | } // namespace WinApi 127 | -------------------------------------------------------------------------------- /src/common/WindowsDefs.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | constexpr auto COLOR_OK = RGB(0, 144, 0); 18 | constexpr auto COLOR_FAIL = RGB(225, 0, 0); 19 | constexpr auto COLOR_WARN = RGB(144, 144, 0); 20 | constexpr auto COLOR_NEUTRAL = RGB(0, 0, 0); 21 | 22 | // Custom WMs (Only for our windows and threads) 23 | constexpr auto WM_SHOWANDRECREATEMENU = WM_USER + 1000; 24 | -------------------------------------------------------------------------------- /src/common/enum_range.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | template 18 | class enum_range_t; 19 | 20 | template 21 | class enum_range_iterator { 22 | using iterator_category = std::forward_iterator_tag; 23 | using value_type = EnumT; 24 | using difference_type = EnumT; 25 | using pointer = EnumT *; 26 | using reference = EnumT; 27 | EnumT m_value; 28 | public: 29 | EnumT operator *() const { 30 | return m_value; 31 | } 32 | 33 | enum_range_iterator operator++() { 34 | enum_range_iterator val{m_value}; 35 | m_value = static_cast(static_cast(m_value) + 1); 36 | return val; 37 | } 38 | 39 | bool operator ==(const enum_range_iterator &rhs) const { 40 | return m_value == rhs.m_value; 41 | } 42 | 43 | bool operator !=(const enum_range_iterator &rhs) const { 44 | return m_value != rhs.m_value; 45 | } 46 | 47 | private: 48 | enum_range_iterator(EnumT value) { 49 | m_value = value; 50 | } 51 | 52 | friend class enum_range_t; 53 | }; 54 | 55 | 56 | template 57 | class enum_range_t { 58 | public: 59 | using iterator = enum_range_iterator; 60 | using value_type = EnumT; 61 | 62 | enum_range_t() 63 | : m_begin{static_cast(0)}, m_end{EnumT::COUNT} { 64 | } 65 | 66 | enum_range_t(EnumT begin) 67 | : enum_range_t{} { 68 | m_begin = iterator{begin}; 69 | } 70 | 71 | enum_range_t(EnumT begin, EnumT end) 72 | : m_begin{begin}, m_end{end} { 73 | } 74 | 75 | iterator begin() const { 76 | return m_begin; 77 | } 78 | 79 | iterator end() const { 80 | return m_end; 81 | } 82 | 83 | private: 84 | iterator m_begin; 85 | iterator m_end; 86 | }; 87 | 88 | template 89 | enum_range_t enum_range() { 90 | return enum_range_t(); 91 | } 92 | 93 | template 94 | enum_range_t enum_range(EnumT begin) { 95 | return enum_range_t(begin); 96 | } 97 | 98 | template 99 | enum_range_t enum_range(EnumT begin, EnumT end) { 100 | return enum_range_t(begin, end); 101 | } 102 | -------------------------------------------------------------------------------- /src/common/move_only.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | // helper class which allows for arbitrary type T to have semantics similar to 18 | // unique_ptr<> i.e. move_only is move only, obviously a = std::move (b), 19 | // causes b to have value of default constructed T{} useful with bool flags and 20 | // possibly pointers/handles In case of pointers/handles unique_ptr with custom 21 | // deleter could be used instead though. 22 | 23 | #include 24 | 25 | template class move_only { 26 | using self_t = move_only; 27 | 28 | public: 29 | move_only() = default; 30 | 31 | move_only(const T &arg) 32 | : value(arg) { 33 | } 34 | 35 | move_only(T &&arg) 36 | : value(std::move(arg)) { 37 | } 38 | 39 | move_only(const self_t &) = delete; 40 | move_only &operator=(const self_t &) = delete; 41 | 42 | move_only(self_t &&other) noexcept 43 | : value(std::move(other.value)) { 44 | other.value = T{}; 45 | } 46 | 47 | move_only &operator=(self_t &&other) noexcept { 48 | value = std::move(other.value); 49 | other.value = T{}; 50 | return *this; 51 | } 52 | 53 | ~move_only() = default; 54 | const T &get() const { return value; } 55 | T &get() { return value; } 56 | 57 | private: 58 | T value = {}; 59 | }; 60 | -------------------------------------------------------------------------------- /src/common/overload.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace detail { 20 | template class overload_class; 21 | 22 | template class overload_class : Arg { 23 | using self = overload_class; 24 | 25 | public: 26 | using Arg::operator(); 27 | 28 | template , self>::value, int> = 0> overload_class(const ActualArg &arg) 29 | : Arg(arg) { 30 | } 31 | }; 32 | 33 | template class overload_class : Arg0, overload_class { 34 | using self = overload_class; 35 | using parent_t = overload_class; 36 | 37 | public: 38 | using Arg0::operator(); 39 | using parent_t::operator(); 40 | 41 | template , self>::value, int> = 0> 42 | overload_class(const ActualArg0 &arg0, const ActualArgs &... args) 43 | : Arg0(arg0), parent_t(args...) { 44 | } 45 | }; 46 | 47 | template struct wrapper_for { 48 | using type = T; 49 | }; 50 | 51 | template struct func_ptr_wrapper; 52 | 53 | template struct func_ptr_wrapper { 54 | using func_ptr_t = Ret (*)(Args ...); 55 | func_ptr_t m_ptr; 56 | 57 | func_ptr_wrapper(func_ptr_t ptr) 58 | : m_ptr(ptr) { 59 | } 60 | 61 | template auto operator()(ActualArgs &&... args) -> decltype(this->m_ptr(std::forward(args)...)) { 62 | return this->m_ptr(std::forward(args)...); 63 | } 64 | }; 65 | 66 | template struct wrapper_for { 67 | using type = func_ptr_wrapper; 68 | }; 69 | 70 | template using wrapper_for_t = typename wrapper_for::type; 71 | 72 | } // namespace detail 73 | 74 | template auto overload(Args &&... args) -> detail::overload_class>...> { 75 | return {std::forward(args)...}; 76 | } 77 | -------------------------------------------------------------------------------- /src/common/raii.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "raii.h" 16 | 17 | #include "Notepad_plus_msgs.h" 18 | 19 | #include 20 | #include 21 | 22 | ToolbarIconsWrapper::ToolbarIconsWrapper() : m_icons{std::make_unique()} { 23 | m_icons->hToolbarBmp = nullptr; 24 | m_icons->hToolbarIcon = nullptr; 25 | m_icons->hToolbarIconDarkMode = nullptr; 26 | } 27 | 28 | ToolbarIconsWrapper::~ToolbarIconsWrapper() { 29 | if (m_icons->hToolbarBmp != nullptr) 30 | DeleteObject(m_icons->hToolbarBmp); 31 | 32 | if (m_icons->hToolbarIcon != nullptr) 33 | DeleteObject(m_icons->hToolbarIcon); 34 | 35 | if (m_icons->hToolbarIconDarkMode != nullptr) 36 | DeleteObject(m_icons->hToolbarIconDarkMode); 37 | } 38 | 39 | ToolbarIconsWrapper::ToolbarIconsWrapper(HINSTANCE h_inst, LPCWSTR normal_name, LPCWSTR dark_mode_name, std::span bmp_icons) 40 | : ToolbarIconsWrapper() { 41 | HDC hdc = ::GetDC(NULL); 42 | int icon_width = 0; 43 | int icon_height = 0; 44 | if (hdc) { 45 | icon_width = ::MulDiv(16, GetDeviceCaps(hdc, LOGPIXELSX), 96); 46 | icon_height = ::MulDiv(16, GetDeviceCaps(hdc, LOGPIXELSY), 96); 47 | } 48 | auto style = (LR_LOADTRANSPARENT | LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS); 49 | assert(!bmp_icons.empty()); 50 | auto it = std::ranges::find_if(bmp_icons, [&](size_t size) { return size == static_cast(icon_width) && size == static_cast(icon_height); }, &BmpData::size); 51 | if (it == std::cend(bmp_icons)) { 52 | it = std::prev(it); 53 | } 54 | m_icons->hToolbarBmp = static_cast(::LoadImage(h_inst, it->name, IMAGE_BITMAP, icon_width, icon_height, style)); 55 | m_icons->hToolbarIcon = static_cast(::LoadImage(h_inst, normal_name, IMAGE_ICON, icon_width, icon_height, style)); 56 | m_icons->hToolbarIconDarkMode = ::LoadIcon(h_inst, dark_mode_name); 57 | } 58 | 59 | const toolbarIconsWithDarkMode *ToolbarIconsWrapper::get() { 60 | return m_icons.get(); 61 | } 62 | -------------------------------------------------------------------------------- /src/common/raii.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | struct toolbarIconsWithDarkMode; 20 | 21 | struct BmpData 22 | { 23 | size_t size; 24 | LPCWSTR name; 25 | }; 26 | 27 | struct ToolbarIconsWrapper { 28 | ToolbarIconsWrapper(HINSTANCE h_inst, LPCWSTR normal_name, LPCWSTR dark_mode_name, std::span bmp_icons); 29 | const toolbarIconsWithDarkMode *get(); 30 | ~ToolbarIconsWrapper(); 31 | 32 | private: 33 | ToolbarIconsWrapper(); 34 | std::unique_ptr m_icons; 35 | }; 36 | -------------------------------------------------------------------------------- /src/common/remap_rvalues_for.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | // useful for chaining functions. Just write original chaining function ref 20 | // qualified Then write REMAP_RVALUES_FOR (function name) it will add 21 | // appropriate overload for ref-ref-qualified case. Preserving reference 22 | // category of return type. 23 | #define REMAP_RVALUES_FOR(MEMBER_FUNC_NAME) \ 24 | template \ 25 | auto MEMBER_FUNC_NAME(ArgTypes &&... args) && { \ 26 | return std::move( \ 27 | static_cast &>(*this) \ 28 | .MEMBER_FUNC_NAME(std::forward(args)...)); \ 29 | } 30 | -------------------------------------------------------------------------------- /src/common/utf8.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "utf8.h" 16 | 17 | bool utf8_is_lead(char c) { 18 | return (((c & 0x80) == 0) // 0xxxxxxx 19 | || ((c & 0xC0) == 0xC0 && (c & 0x20) == 0) // 110xxxxx 20 | || ((c & 0xE0) == 0xE0 && (c & 0x10) == 0) // 1110xxxx 21 | || ((c & 0xF0) == 0xF0 && (c & 0x08) == 0) // 11110xxx 22 | || ((c & 0xF8) == 0xF8 && (c & 0x04) == 0) // 111110xx 23 | || ((c & 0xFC) == 0xFC && (c & 0x02) == 0)); 24 | } 25 | 26 | bool utf8_is_cont(char c) { 27 | return ((c & 0x80) == 0x80 && (c & 0x40) == 0); // 10xxxxx 28 | } 29 | 30 | char *utf8_dec(const char *string, const char *current) { 31 | if (string >= current) 32 | return nullptr; 33 | 34 | const char *temp = current - 1; 35 | while (string <= temp && (!utf8_is_lead(*temp))) 36 | temp--; 37 | 38 | return const_cast(temp); 39 | } 40 | 41 | const char *utf8_inc(const char *string) { 42 | return string + utf8_symbol_len(*string); 43 | } 44 | 45 | char *utf8_inc(char *string) { return string + utf8_symbol_len(*string); } 46 | 47 | int utf8_symbol_len(char c) { 48 | if ((c & 0x80) == 0) 49 | return 1; 50 | if ((c & 0xC0) > 0 && (c & 0x20) == 0) 51 | return 2; 52 | if ((c & 0xE0) > 0 && (c & 0x10) == 0) 53 | return 3; 54 | if ((c & 0xF0) > 0 && (c & 0x08) == 0) 55 | return 4; 56 | if ((c & 0xF8) > 0 && (c & 0x04) == 0) 57 | return 5; 58 | if ((c & 0xFC) > 0 && (c & 0x02) == 0) 59 | return 6; 60 | return 1; // to avoid unnecessary endless loops, skipping bad symbol 61 | } 62 | 63 | bool utf8_first_chars_equal(const char *str1, const char *str2) { 64 | int char1_size = utf8_symbol_len(*str1); 65 | int char2_size = utf8_symbol_len(*str2); 66 | if (char1_size != char2_size) 67 | return false; 68 | return (strncmp(str1, str2, char1_size) == 0); 69 | } 70 | 71 | const char *utf8_pbrk(const char *s, const char *set) { 72 | for (; *s != 0; s = utf8_inc(s)) 73 | for (auto x = set; *x != 0; x = utf8_inc(x)) 74 | if (utf8_first_chars_equal(s, x)) 75 | return s; 76 | return nullptr; 77 | } 78 | 79 | char *utf8_chr(const char *s, const char *sfc) // Char is first from the string 80 | // sfc (string with first char) 81 | { 82 | while (*s != 0) { 83 | if ((s != nullptr) && utf8_first_chars_equal(s, sfc)) 84 | return const_cast(s); 85 | s = utf8_inc(s); 86 | } 87 | return nullptr; 88 | } 89 | 90 | size_t utf8_length(const char *string) { 91 | auto it = string; 92 | size_t size = 0; 93 | while (*it != 0) { 94 | size++; 95 | it = utf8_inc(it); 96 | } 97 | return size; 98 | } 99 | -------------------------------------------------------------------------------- /src/common/utf8.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | char *utf8_dec(const char *string, const char *current); 18 | char *utf8_chr(const char *s, const char *sfc); 19 | int utf8_symbol_len(char c); 20 | const char *utf8_inc(const char *string); 21 | char *utf8_inc(char *string); 22 | const char *utf8_pbrk(const char *s, const char *set); 23 | size_t utf8_length(const char *string); 24 | bool utf8_is_lead(char c); 25 | bool utf8_is_cont(char c); 26 | -------------------------------------------------------------------------------- /src/common/winapi.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "move_only.h" 17 | 18 | // various winapi helpers 19 | namespace WinApi { 20 | std::wstring get_edit_text(HWND edit); 21 | bool move_file_and_reset_security_descriptor(const wchar_t *from, const wchar_t *to); 22 | 23 | std::wstring get_class_name(HWND hwnd); 24 | std::optional browse_for_directory(HWND parent_wnd, const wchar_t *initial_path); 25 | 26 | HWND create_tooltip(int tool_id, HWND h_dlg, const wchar_t *psz_text); 27 | bool delete_file(const wchar_t *path); 28 | std::optional library_bitness(const wchar_t *path); 29 | 30 | bool is_locale_info_available(); 31 | std::wstring get_locale_info(const wchar_t *locale_name, LCTYPE type); 32 | 33 | class Brush { 34 | using Self = Brush; 35 | public: 36 | Brush () = default; 37 | Brush (HBRUSH brush) : m_brush (brush) {} 38 | HBRUSH get () const { return m_brush.get(); } 39 | Brush (const Self&) = delete; 40 | Brush &operator= (const Self&) = delete; 41 | Brush (Self&&) = default; 42 | Brush &operator= (Self&&) = default; 43 | ~Brush () { DeleteObject (m_brush.get()); } 44 | 45 | private: 46 | move_only m_brush; 47 | }; 48 | } // namespace WinApi 49 | -------------------------------------------------------------------------------- /src/core/SpellChecker.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | // Class that will do most of the job with spellchecker 17 | 18 | #include "npp/EditorInterface.h" 19 | 20 | 21 | class EditorInterface; 22 | class Settings; 23 | class LanguageInfo; 24 | class SettingsDialog; 25 | class SelectMultipleLanguagesDialog; 26 | class SuggestionMenuButton; 27 | class SpellerInterface; 28 | class AspellInterface; 29 | class HunspellInterface; 30 | class SelectProxy; 31 | class NativeSpellerInterface; 32 | class WordForSpeller; 33 | class SpellerContainer; 34 | class SpellerWordData; 35 | 36 | class SpellChecker { 37 | enum class CheckTextMode { 38 | find_first, 39 | find_last, 40 | }; 41 | 42 | public: 43 | SpellChecker(const Settings *settings, EditorInterface &editor, 44 | const SpellerContainer &speller_container); 45 | ~SpellChecker(); 46 | void recheck_visible_both_views(); 47 | void recheck_visible(); 48 | 49 | std::wstring get_all_misspellings_as_string() const; 50 | void on_settings_changed(); 51 | void find_next_mistake(); 52 | void find_prev_mistake(); 53 | WordForSpeller to_word_for_speller(std::wstring_view word) const; 54 | void recheck_visible_on_active_view(); 55 | bool is_word_under_cursor_correct(TextPosition &pos, TextPosition &length, 56 | bool use_text_cursor = false) const; 57 | void erase_all_misspellings(); 58 | void mark_lines_with_misspelling() const; 59 | 60 | private: 61 | void create_word_underline(TextPosition start, TextPosition end) const; 62 | void remove_underline(TextPosition start, TextPosition end) const; 63 | void clear_all_underlines() const; 64 | bool check_word(std::wstring_view word, 65 | TextPosition word_start) const; 66 | TextPosition prev_token_begin_in_document(TextPosition start) const; 67 | TextPosition next_token_end_in_document(TextPosition end) const; 68 | MappedWstring get_visible_text(); 69 | std::vector check_text(const MappedWstring &text_to_check) const; 70 | void underline_misspelled_words(const MappedWstring &text_to_check) const; 71 | std::vector get_misspelled_words(const MappedWstring &text_to_check) const; 72 | std::optional> find_first_misspelling(const MappedWstring &text_to_check, TextPosition last_valid_position) const; 73 | std::optional> find_last_misspelling(const MappedWstring &text_to_check, TextPosition last_valid_position) const; 74 | void check_visible(); 75 | 76 | std::wstring_view get_word_at(TextPosition char_pos, const MappedWstring &text) const; 77 | void refresh_underline_style(); 78 | bool is_spellchecking_needed(std::wstring_view word, 79 | TextPosition word_start) const; 80 | TextPosition next_token_end(std::wstring_view target, TextPosition index) const; 81 | TextPosition prev_token_begin(std::wstring_view target, TextPosition index) const; 82 | 83 | private: 84 | const Settings &m_settings; 85 | 86 | EditorInterface &m_editor; 87 | const SpellerContainer &m_speller_container; 88 | }; 89 | -------------------------------------------------------------------------------- /src/core/SpellCheckerHelpers.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | class Settings; 18 | class EditorInterface; 19 | class SpellerContainer; 20 | enum class NppViewType; 21 | 22 | #include "plugin/Constants.h" 23 | 24 | namespace SpellCheckerHelpers { 25 | bool is_spell_checking_needed_for_file(const EditorInterface &editor, const Settings &settings); 26 | void apply_word_conversions(const Settings &settings, std::wstring &word); 27 | void cut_apostrophes(const Settings &settings, std::wstring_view &word); 28 | // Replace all tokens equal `from` to `to`. Settings are required for tokenization style. 29 | // If to is proper name or abbreviation it should be capitalized correctly otherwise it should be all lower case 30 | void replace_all_tokens(EditorInterface &editor, const Settings &settings, const char *from, std::wstring_view to, bool 31 | is_proper_name); 32 | bool is_word_spell_checking_needed(const Settings &settings, const EditorInterface &editor, std::wstring_view word, TextPosition word_start); 33 | void replace_current_word_with_topmost_suggestion(EditorInterface &editor, const SpellChecker &spell_checker, const SpellerContainer &speller_container); 34 | } // namespace SpellCheckerHelpers 35 | -------------------------------------------------------------------------------- /src/network/FileListProvider.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "lsignal.h" 18 | 19 | class ProgressData; 20 | 21 | class FileDescription { 22 | public: 23 | std::wstring title; 24 | std::wstring path; 25 | bool was_alias_applied = false; 26 | }; 27 | 28 | enum class FileListProviderDownloadErrorType { 29 | none, 30 | canceled, 31 | file_is_not_writeable, 32 | was_not_able_to_download, 33 | }; 34 | 35 | class FileListProvider { 36 | virtual void update_file_list() = 0; // asynchronous call, caller should wait for file_list_received 37 | virtual void download_dictionary(const std::wstring &aff_filepath, const std::wstring &target_path, std::shared_ptr progress_data) = 0; 38 | public: 39 | virtual ~FileListProvider() = default; 40 | lsignal::signal)> file_list_received; 41 | lsignal::signal &error_description, bool was_cancelled)> file_downloaded; 42 | lsignal::signal error_happened; 43 | }; 44 | -------------------------------------------------------------------------------- /src/network/GithubFileListProvider.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "FileListProvider.h" 18 | #include "common/TaskWrapper.h" 19 | #include "common/WinInet.h" 20 | #include "plugin/Settings.h" 21 | 22 | class Settings; 23 | 24 | class GitHubFileListProvider : public FileListProvider { 25 | public: 26 | GitHubFileListProvider(HWND parent, const Settings &settings); 27 | void set_root_path(const std::wstring &root_path); 28 | void update_file_list() override; 29 | void download_dictionary(const std::wstring &aff_filepath, const std::wstring &target_path, std::shared_ptr progress_data) override; 30 | void cancel_download(); 31 | 32 | private: 33 | static WinInet::GlobalHandle create_global_handle(const Settings::Data &settings_data); 34 | static WinInet::UrlHandle create_url_handle(const Settings::Data &settings_data, const WinInet::GlobalHandle &global_handle, const wchar_t *url); 35 | static std::optional download_dictionary_impl(const Concurrency::cancellation_token &token, const std::wstring &aff_filepath, 36 | const std::wstring &target_path, std::shared_ptr progress_data, 37 | std::vector &downloaded_file_names, const 38 | Settings::Data &settings_data, bool &cancelled); 39 | 40 | private: 41 | std::wstring m_root_path; 42 | TaskWrapper m_get_file_list_task; 43 | TaskWrapper m_download_file_task; 44 | const Settings &m_settings; 45 | }; 46 | -------------------------------------------------------------------------------- /src/network/UrlHelpers.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "UrlHelpers.h" 16 | 17 | #include "common/string_utils.h" 18 | 19 | namespace UrlHelpers { 20 | bool is_ftp_url(std::wstring s) { 21 | trim_inplace(s); 22 | to_lower_inplace(s); 23 | return starts_with(s, L"ftp://"); 24 | } 25 | 26 | bool is_github_url(std::wstring url) { 27 | trim_inplace(url); 28 | to_lower_inplace(url); 29 | auto view = std::wstring_view(url); 30 | view = remove_prefix_equals(view, L"https://"); 31 | view = remove_prefix_equals(view, L"www."); 32 | return starts_with(view, L"github.com"); 33 | } 34 | 35 | namespace { 36 | std::wstring to_github_base_url(std::wstring github_url) { 37 | std::wstring_view vw = github_url; 38 | vw = remove_prefix_equals(vw, L"https://"); 39 | vw = remove_prefix_equals(vw, L"www."); 40 | github_url = vw; 41 | github_url.insert(L"github.com/"sv.length(), L"repos/"); 42 | return L"https://api." + github_url; 43 | } 44 | } 45 | 46 | 47 | std::wstring github_url_to_api_recursive_tree_url(std::wstring github_url, std::wstring_view branch_name) { 48 | auto ret = to_github_base_url(std::move(github_url)); 49 | ret += L"/git/trees/"; 50 | ret += branch_name; 51 | ret += L"?recursive=1"; 52 | return ret; 53 | } 54 | 55 | std::wstring github_file_url_to_download_url(std::wstring github_url, std::wstring_view branch_name) { 56 | std::wstring_view url = github_url; 57 | url = remove_prefix_equals(url, L"https://"); 58 | url = remove_prefix_equals(url, L"www."); 59 | url = remove_prefix_equals(url, L"github.com"); 60 | github_url = url; 61 | github_url.insert(0, L"https://raw.githubusercontent.com"); 62 | github_url += L"/"; 63 | github_url += branch_name; 64 | github_url += L"/"; 65 | return github_url; 66 | } 67 | } // namespace UrlHelpers 68 | -------------------------------------------------------------------------------- /src/network/UrlHelpers.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | namespace UrlHelpers { 18 | bool is_ftp_url(std::wstring s); 19 | 20 | bool is_github_url(std::wstring url); 21 | 22 | std::wstring github_url_to_api_recursive_tree_url(std::wstring github_url, std::wstring_view branch_name); 23 | std::wstring github_file_url_to_download_url(std::wstring github_url, std::wstring_view branch_name); 24 | } 25 | -------------------------------------------------------------------------------- /src/npp/EditorInterface.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "EditorInterface.h" 16 | 17 | #include "TextUtils.h" 18 | #include "common/utf8.h" 19 | #include "common/Utility.h" 20 | #include 21 | 22 | POINT EditorInterface::get_point_from_position(TextPosition position) const { 23 | return {get_point_x_from_position(position), 24 | get_point_y_from_position(position)}; 25 | } 26 | 27 | TextPosition EditorInterface::get_prev_valid_begin_pos(TextPosition pos) const { 28 | if (pos == 0) 29 | return 0; 30 | if (get_encoding() == EditorCodepage::ansi) 31 | return pos - 1; 32 | 33 | auto worst_prev_pos = std::max(0_sz, pos - static_cast(max_utf8_char_length)); 34 | auto rng = get_text_range(worst_prev_pos, pos); 35 | auto it = std::find_if(rng.rbegin(), rng.rend(), &utf8_is_lead); 36 | assert(it != rng.rend ()); 37 | return worst_prev_pos + (it.base() - rng.begin()) - 1; 38 | } 39 | 40 | TextPosition EditorInterface::get_next_valid_end_pos(TextPosition pos) const { 41 | auto doc_len = get_active_document_length(); 42 | if (pos >= doc_len) 43 | return doc_len; 44 | 45 | if (get_encoding() == EditorCodepage::ansi) 46 | return pos + 1; 47 | 48 | auto text = get_text_range(pos, pos + 1); 49 | return pos + utf8_symbol_len(*text.begin()); 50 | } 51 | 52 | std::string EditorInterface::to_editor_encoding(std::wstring_view str) const { 53 | switch (get_encoding()) { 54 | case EditorCodepage::ansi: 55 | return to_string(str); 56 | case EditorCodepage::utf8: 57 | return to_utf8_string(str); 58 | case EditorCodepage::COUNT: 59 | break; 60 | } 61 | throw std::runtime_error("Unsupported encoding"); 62 | } 63 | 64 | MappedWstring EditorInterface::to_mapped_wstring(const std::string &str) { 65 | if (get_encoding() == EditorCodepage::utf8) 66 | return utf8_to_mapped_wstring(str); 67 | 68 | return ::to_mapped_wstring(str); 69 | } 70 | 71 | MappedWstring EditorInterface::get_mapped_wstring_range(TextPosition from, TextPosition to) { 72 | auto result = to_mapped_wstring(get_text_range(from, to)); 73 | for (auto &val : result.mapping) 74 | val += from; 75 | return result; 76 | } 77 | 78 | MappedWstring EditorInterface::get_mapped_wstring_line(TextPosition line) { 79 | auto result = to_mapped_wstring(get_line(line));; 80 | auto line_start = get_line_start_position(line); 81 | for (auto &val : result.mapping) 82 | val += line_start; 83 | return result; 84 | } 85 | -------------------------------------------------------------------------------- /src/npp/ScintillaUtils.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | namespace ScintillaUtils { 18 | enum class StyleCategory { 19 | text, 20 | // should be spell-checked 21 | comment, 22 | string, 23 | identifier, 24 | unknown, 25 | // Should not be spell-checked 26 | 27 | COUNT, 28 | }; 29 | 30 | StyleCategory get_style_category(LRESULT lexer, LRESULT style, const Settings &settings); 31 | } // namespace ScintillaUtils 32 | -------------------------------------------------------------------------------- /src/npp/TextUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "npp/TextUtils.h" 2 | 3 | #include "common/Utility.h" 4 | #include "common/utf8.h" 5 | 6 | MappedWstring utf8_to_mapped_wstring(std::string_view str) { 7 | if (str.empty()) 8 | return {}; 9 | ptrdiff_t len = str.length(); 10 | std::vector buf; 11 | std::vector mapping; 12 | buf.reserve(len); 13 | mapping.reserve(len); 14 | auto it = str.data(); 15 | // sadly this garbage skipping is required due to bad find prev mistake algorithm 16 | while (utf8_is_cont(*it)) 17 | ++it; 18 | size_t char_cnt = 1; 19 | while (it - str.data() < len) { 20 | auto next = utf8_inc(it); 21 | buf.resize(char_cnt); 22 | MultiByteToWideChar(CP_UTF8, 0, it, static_cast(next - it), buf.data() + char_cnt - 1, 1); 23 | mapping.push_back(it - str.data()); 24 | ++char_cnt; 25 | it = next; 26 | } 27 | mapping.push_back(it - str.data()); 28 | return {std::wstring{buf.begin(), buf.end()}, std::move(mapping)}; 29 | } 30 | 31 | MappedWstring to_mapped_wstring(std::string_view str) { 32 | if (str.empty()) 33 | return {}; 34 | std::vector mapping(str.length() + 1); 35 | std::iota(mapping.begin(), mapping.end(), 0); 36 | return {to_wstring(str), std::move(mapping)}; 37 | } 38 | -------------------------------------------------------------------------------- /src/npp/TextUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "plugin/Constants.h" 4 | 5 | MappedWstring utf8_to_mapped_wstring(std::string_view str); 6 | MappedWstring to_mapped_wstring(std::string_view str); 7 | -------------------------------------------------------------------------------- /src/plugin/Constants.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "common/MappedWstring.h" 18 | 19 | constexpr int spell_check_indicator_id = 19; 20 | 21 | enum class EncodingType { utf8 = 0, ansi }; 22 | 23 | enum class CustomGuiMessage { 24 | generic_callback, 25 | max, 26 | }; 27 | 28 | const wchar_t *const custom_gui_messages_names[] = {L"DSpellCheck_GenericCallback"}; 29 | 30 | namespace menu_id { 31 | // Global Menu ID 32 | constexpr auto plguin_menu = 193; 33 | constexpr auto language_menu = 197; 34 | 35 | // Menu item IDs 36 | constexpr auto replace_all_start = 50; 37 | constexpr auto add_to_dictionary = 101; 38 | constexpr auto ignore_all = 102; 39 | constexpr auto multiple_languages = 201; 40 | constexpr auto customize_multiple_languages = 202; 41 | constexpr auto download_dictionaries = 203; 42 | constexpr auto remove_dictionaries = 204; 43 | } // namespace menu_id 44 | 45 | constexpr auto USER_SERVER_CONST = 100; 46 | 47 | constexpr auto static_plugin_name = L"DSpellCheck"; 48 | constexpr auto config_file_name = L"DSpellCheck.ini"; 49 | constexpr auto multiple_language_alias = L""; 50 | 51 | using TextPosition = ptrdiff_t; 52 | using MappedWstring = MappedWstringGeneric; 53 | -------------------------------------------------------------------------------- /src/plugin/DSpellCheck.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Predelnik/DSpellCheck/a152beb134d091771829e11dd53a4b7a766fbef6/src/plugin/DSpellCheck.rc -------------------------------------------------------------------------------- /src/plugin/DllMain.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include 16 | void set_hmodule(HANDLE h_module_arg); 17 | 18 | bool APIENTRY DllMain(HANDLE h_module, DWORD reason_for_call, 19 | LPVOID /*lpvReserved*/) { 20 | switch (reason_for_call) { 21 | case DLL_PROCESS_ATTACH: 22 | set_hmodule(h_module); 23 | break; 24 | 25 | case DLL_PROCESS_DETACH: 26 | //_CrtDumpMemoryLeaks(); 27 | break; 28 | 29 | case DLL_THREAD_ATTACH: 30 | break; 31 | 32 | case DLL_THREAD_DETACH: 33 | break; 34 | } 35 | 36 | return true; 37 | } 38 | -------------------------------------------------------------------------------- /src/plugin/Plugin.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | // 18 | // All difinitions of plugin interface 19 | // 20 | #include "PluginInterface.h" 21 | #include "common/enum_array.h" 22 | 23 | class MenuItem; 24 | class AspellOptionsDialog; 25 | 26 | 27 | enum class Action { 28 | toggle_auto_spell_check, 29 | quick_language_change, 30 | copy_all_misspellings, 31 | erase_all_misspellings, 32 | settings, 33 | show_spell_check_menu_at_cursor, 34 | reload_user_dictionaries, 35 | additional_actions, 36 | toggle_debug_logging, 37 | open_debug_log, 38 | replace_with_1st_suggestion, 39 | ignore_for_current_session, 40 | mark_lines_with_misspelling, 41 | online_manual, 42 | about, 43 | find_next_error, 44 | find_prev_error, 45 | 46 | COUNT, 47 | }; 48 | 49 | const int nb_func = static_cast(Action::COUNT); 50 | constexpr int requested_menu_count = 350; 51 | 52 | extern enum_array action_index; 53 | 54 | enum class CustomGuiMessage; 55 | class SelectMultipleLanguagesDialog; 56 | class NppInterface; 57 | class DownloadDictionariesDialog; 58 | class ConnectionSettingsDialog; 59 | class SpellChecker; 60 | class ProgressDialog; 61 | class RemoveDictionariesDialog; 62 | class Settings; 63 | 64 | void set_hmodule(HANDLE h_module_arg); 65 | std::wstring rc_str(UINT string_id); 66 | std::wstring_view rc_str_view(UINT string_id); 67 | LRESULT show_calculated_menu(std::vector &&menu_list); 68 | HMENU get_this_plugin_menu(); 69 | HMENU get_langs_sub_menu(); 70 | HANDLE get_h_module(); 71 | SelectMultipleLanguagesDialog *get_lang_list(); 72 | RemoveDictionariesDialog *get_remove_dics(); 73 | AspellOptionsDialog *get_aspell_options_dlg(); 74 | ConnectionSettingsDialog *get_select_proxy(); 75 | ProgressDialog *get_progress_dlg(); 76 | FuncItem *get_func_item(); 77 | std::wstring get_default_hunspell_path(); 78 | int get_context_menu_id_start(); 79 | int get_langs_menu_id_start(); 80 | bool get_use_allocated_ids(); 81 | DWORD get_custom_gui_message_id(CustomGuiMessage message_id); 82 | std::wstring get_debug_log_path(); 83 | NppInterface &npp_interface(); 84 | void copy_misspellings_to_clipboard(); 85 | void delete_log(); 86 | void print_to_log(std::wstring_view line, HWND parent_wnd); 87 | -------------------------------------------------------------------------------- /src/spellers/AspellInterface.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "aspell.h" 17 | #include "SpellerContainer.h" 18 | 19 | struct AspellCanHaveError; 20 | struct AspellSpeller; 21 | class Settings; 22 | 23 | #include "SpellerInterface.h" 24 | 25 | class LanguageInfo; 26 | 27 | class AspellInterface : public SpellerInterface { 28 | using SpellerPtr = std::unique_ptr; 29 | public: 30 | AspellInterface(HWND npp_window_arg, const Settings &settings); // Window for error reporting 31 | ~AspellInterface() override; 32 | std::vector get_language_list() const override; 33 | void set_language(const wchar_t *lang) override; 34 | void set_multiple_languages( 35 | const std::vector &list) override; // Languages are from SelectMultipleLanguagesDialog 36 | bool 37 | check_word(const WordForSpeller &word) const override; // Word in Utf-8 or ANSI (For now only Utf-8) 38 | bool is_working() const override; 39 | std::vector get_suggestions(const wchar_t *word) const override; 40 | void add_to_dictionary(const wchar_t *word) override; 41 | void ignore_all(const wchar_t *word) override; 42 | 43 | bool init(const wchar_t *path_arg); 44 | AspellStatus get_status() const; 45 | std::wstring get_default_personal_dictionary_path() const; 46 | 47 | private: 48 | void send_aspell_error(AspellCanHaveError *error); 49 | void setup_aspell_config(AspellConfig *spell_config); 50 | 51 | private: 52 | mutable AspellSpeller *m_last_selected_speller = nullptr; 53 | SpellerPtr m_single_speller; 54 | std::vector m_spellers; 55 | bool m_aspell_loaded = false; 56 | bool m_correct_bitness = true; 57 | HWND m_npp_window = nullptr; // For message boxes 58 | const Settings &m_settings; 59 | }; 60 | -------------------------------------------------------------------------------- /src/spellers/LanguageInfo.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "common/Utility.h" 17 | 18 | class LanguageInfo { 19 | public: 20 | std::wstring orig_name; 21 | std::wstring alias_name; 22 | bool for_all_users = false; 23 | 24 | LanguageInfo(std::wstring_view name, LanguageNameStyle language_name_style, 25 | bool for_all_users_arg = false) 26 | : orig_name(name) { 27 | for_all_users = for_all_users_arg; 28 | std::tie(alias_name, std::ignore) = apply_alias(name, language_name_style); 29 | } 30 | }; 31 | 32 | inline bool less_aliases(const LanguageInfo &a, const LanguageInfo &b) { 33 | return a.alias_name < b.alias_name; 34 | } 35 | 36 | inline bool less_original(const LanguageInfo &a, const LanguageInfo &b) { 37 | return a.orig_name < b.orig_name; 38 | } 39 | -------------------------------------------------------------------------------- /src/spellers/NativeSpellerInterface.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "SpellerInterface.h" 18 | 19 | #if !defined (__clang__) 20 | #include 21 | 22 | struct ISpellCheckerFactory; 23 | struct ISpellChecker; 24 | struct IEnumSpellingError; 25 | 26 | class NativeSpellerInterface : public SpellerInterface { 27 | public: 28 | void init(); // init should be done after initialization, not after construction 29 | NativeSpellerInterface(const Settings &settings); 30 | void set_language(const wchar_t *lang) override; 31 | std::vector check_words(const std::vector &words) const override; 32 | void add_to_dictionary(const wchar_t *word) override; 33 | void ignore_all(const wchar_t *word) override; 34 | bool is_working() const override; 35 | std::vector get_language_list() const override; 36 | void set_multiple_languages(const std::vector &list) override; 37 | std::vector get_suggestions(const wchar_t *word) const override; 38 | void cleanup(); 39 | 40 | private: 41 | void init_impl(); 42 | private: 43 | class ptrs { 44 | public: 45 | CComPtr m_factory; 46 | CComPtr m_speller; 47 | std::vector> m_spellers; 48 | }; 49 | 50 | std::unique_ptr m_ptrs; 51 | mutable ISpellChecker *m_last_used_speller = nullptr; 52 | bool m_ok = false; 53 | bool m_init = false; 54 | bool m_co_initialize_successful = false; 55 | const Settings &m_settings; 56 | }; 57 | #else 58 | class NativeSpellerInterface : public DummySpeller 59 | { 60 | public: 61 | NativeSpellerInterface (const Settings &) {} 62 | void cleanup () {} 63 | void init () {} 64 | }; 65 | #endif // defined (DSPELLCHECK_NEW_SDK) && !defined (__clang__) 66 | -------------------------------------------------------------------------------- /src/spellers/SpellerContainer.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "lsignal.h" 17 | #include "SpellerId.h" 18 | #include "common/enum_array.h" 19 | #include "common/TemporaryAcessor.h" 20 | 21 | class NppData; 22 | class Settings; 23 | class AspellInterface; 24 | class HunspellInterface; 25 | class NativeSpellerInterface; 26 | class SpellerInterface; 27 | class LanguageInfo; 28 | class MockSpeller; 29 | 30 | enum class AspellStatus { 31 | working, 32 | no_dictionaries, 33 | not_working, 34 | incorrect_bitness, 35 | }; 36 | 37 | class SpellerContainer { 38 | using Self = SpellerContainer; 39 | 40 | public: 41 | explicit SpellerContainer(const Settings *settings, const NppData *npp_data); 42 | SpellerContainer(const Settings *settings, 43 | std::unique_ptr speller); 44 | ~SpellerContainer(); 45 | void apply_settings_to_active_speller(); 46 | void init_speller(); 47 | TemporaryAcessor modify() const; 48 | std::vector get_available_languages() const; 49 | 50 | HunspellInterface &get_hunspell_speller() const { 51 | return *m_hunspell_speller; 52 | } 53 | 54 | const NativeSpellerInterface &native_speller() const; 55 | const SpellerInterface &active_speller() const; 56 | AspellStatus get_aspell_status() const; 57 | std::wstring get_aspell_default_personal_dictionary_path() const; 58 | void cleanup(); 59 | void ignore_word(std::wstring wstr); 60 | void add_to_dictionary(std::wstring wstr); 61 | 62 | public: 63 | mutable lsignal::signal speller_status_changed; 64 | 65 | private: 66 | SpellerInterface &active_speller(); 67 | void create_spellers(const NppData &npp_data); 68 | void fill_speller_ptr_array(); 69 | void init_spellers(const NppData &npp_data); 70 | void on_settings_changed(); 71 | 72 | private: 73 | const Settings &m_settings; 74 | std::unique_ptr m_aspell_speller; 75 | std::unique_ptr m_hunspell_speller; 76 | std::unique_ptr m_native_speller; 77 | enum_array m_spellers; 78 | std::unique_ptr m_single_speller; 79 | }; 80 | -------------------------------------------------------------------------------- /src/spellers/SpellerId.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | enum class SpellerId { 18 | aspell, 19 | hunspell, 20 | native, 21 | 22 | // ReSharper disable once CppInconsistentNaming 23 | COUNT, 24 | }; 25 | 26 | std::wstring gui_string(SpellerId value); 27 | -------------------------------------------------------------------------------- /src/spellers/SpellerInterface.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "SpellerInterface.h" 16 | 17 | #include "LanguageInfo.h" 18 | 19 | bool SpellerInterface::check_word(const WordForSpeller &word) const { 20 | return check_words({word}).front(); 21 | } 22 | 23 | std::vector 24 | SpellerInterface::check_words(const std::vector &words) const { 25 | std::vector ret; 26 | ret.resize(words.size()); 27 | for (int i = 0; i < static_cast(words.size()); ++i) 28 | ret[i] = check_word(words[i]); 29 | return ret; 30 | } 31 | 32 | std::vector DummySpeller::get_language_list() const { return {}; } 33 | 34 | void DummySpeller::set_language(const wchar_t * /*lang*/) {} 35 | 36 | void DummySpeller::set_multiple_languages( 37 | const std::vector & /*langs*/) { 38 | } 39 | 40 | bool DummySpeller::check_word(const WordForSpeller 41 | /*word*/&) const { return true; } 42 | 43 | std::vector 44 | DummySpeller::get_suggestions(const wchar_t * /*word*/) const { 45 | return {}; 46 | } 47 | 48 | void DummySpeller::add_to_dictionary(const wchar_t * /*word*/) { 49 | } 50 | 51 | void DummySpeller::ignore_all(const wchar_t * /*word*/) { 52 | } 53 | 54 | bool DummySpeller::is_working() const { return false; } 55 | -------------------------------------------------------------------------------- /src/spellers/SpellerInterface.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include 17 | #include 18 | 19 | class LanguageInfo; 20 | 21 | class AdditionalWordData { 22 | public: 23 | bool ends_with_dot = false; // could be useful for words like etc. 24 | }; 25 | 26 | class WordForSpeller { 27 | public: 28 | std::wstring str; 29 | AdditionalWordData data; 30 | }; 31 | 32 | class SpellerInterface { 33 | 34 | public: 35 | enum class SpellerMode { 36 | SingleLanguage, 37 | MultipleLanguages, 38 | }; 39 | 40 | public: 41 | virtual ~SpellerInterface() = default; 42 | virtual std::vector get_language_list() const = 0; 43 | virtual void set_language(const wchar_t *lang) = 0; 44 | virtual void set_multiple_languages( 45 | const std::vector &list) = 0; // Languages are from SelectMultipleLanguagesDialog 46 | void set_mode(SpellerMode multi) { m_speller_mode = multi; } 47 | // Implement either check_word or check_words or get the endless recursion 48 | virtual bool check_word(const WordForSpeller &word) const; 49 | // Functions which should be implemented in case if words for some awkward 50 | // reason could be faster checked in bulk 51 | virtual std::vector 52 | check_words(const std::vector &words) const; 53 | virtual std::vector 54 | get_suggestions(const wchar_t *word) const = 0; 55 | virtual void add_to_dictionary(const wchar_t *word) = 0; 56 | virtual void ignore_all(const wchar_t *word) = 0; 57 | virtual bool is_working() const = 0; 58 | 59 | protected: 60 | SpellerMode m_speller_mode = SpellerMode::SingleLanguage; 61 | }; 62 | 63 | // speller that does not do anything and never works 64 | class DummySpeller : public SpellerInterface { 65 | public: 66 | std::vector get_language_list() const override; 67 | void set_language(const wchar_t *lang) override; 68 | 69 | void set_multiple_languages(const std::vector &langs) override; 70 | 71 | bool check_word(const WordForSpeller &word) const override; 72 | std::vector get_suggestions(const wchar_t *word) const override; 73 | void add_to_dictionary(const wchar_t *word) override; 74 | void ignore_all(const wchar_t *word) override; 75 | bool is_working() const override; 76 | }; 77 | -------------------------------------------------------------------------------- /src/ui/AboutDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "ui/StaticDialog.h" 17 | 18 | class AboutDialog : public StaticDialog { 19 | public: 20 | void init(HINSTANCE h_inst, HWND parent) override; 21 | void do_dialog(); 22 | void update_compiler_version(); 23 | 24 | protected: 25 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, LPARAM l_param) override; 26 | }; 27 | -------------------------------------------------------------------------------- /src/ui/AspellOptionsDialog.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "AspellOptionsDialog.h" 16 | 17 | #include "common/WinApi.h" 18 | #include "plugin/Settings.h" 19 | #include "spellers/SpellerContainer.h" 20 | 21 | AspellOptionsDialog::AspellOptionsDialog(HINSTANCE h_inst, HWND parent, const Settings &settings, const SpellerContainer &spellers) 22 | : m_settings(settings), m_spellers(spellers) { 23 | Window::init(h_inst, parent); 24 | } 25 | 26 | void AspellOptionsDialog::do_dialog() { 27 | if (!isCreated()) { 28 | create(IDD_ASPELL_OPTIONS); 29 | } 30 | update_controls(); 31 | goToCenter(); 32 | display(); 33 | } 34 | 35 | void AspellOptionsDialog::apply_choice() { 36 | auto s = m_settings.modify(); 37 | s->data.aspell_allow_run_together_words = Button_GetCheck(m_allow_run_together_cb) == BST_CHECKED; 38 | s->data.aspell_personal_dictionary_path = WinApi::get_edit_text(m_aspell_personal_path_le); 39 | if (s->data.aspell_personal_dictionary_path == m_spellers.get_aspell_default_personal_dictionary_path()) 40 | s->data.aspell_personal_dictionary_path = L""; 41 | } 42 | 43 | void AspellOptionsDialog::update_controls() { 44 | Button_SetCheck(m_allow_run_together_cb, m_settings.data.aspell_allow_run_together_words ? BST_CHECKED : BST_UNCHECKED); 45 | Edit_SetText(m_aspell_personal_path_le, 46 | m_settings.data.aspell_personal_dictionary_path.empty() ? m_spellers.get_aspell_default_personal_dictionary_path().c_str() 47 | : m_settings.data.aspell_personal_dictionary_path.c_str()); 48 | } 49 | 50 | INT_PTR __stdcall AspellOptionsDialog::run_dlg_proc(UINT message, WPARAM w_param, LPARAM /*l_param*/) { 51 | switch (message) { 52 | case WM_INITDIALOG: { 53 | m_allow_run_together_cb = GetDlgItem(_hSelf, IDC_ASPELL_RUNTOGETHER_CB); 54 | m_aspell_personal_path_le = GetDlgItem(_hSelf, IDC_ASPELL_PERSONAL_PATH_LE); 55 | } 56 | case WM_COMMAND: { 57 | switch (LOWORD(w_param)) { 58 | case IDC_BROWSEPDICTIONARYPATH: 59 | if (HIWORD(w_param) == BN_CLICKED) { 60 | auto cur_path = WinApi::get_edit_text(m_aspell_personal_path_le); 61 | auto path = WinApi::browse_for_directory(_hSelf, cur_path.data()); 62 | if (path) 63 | Edit_SetText(m_aspell_personal_path_le, path->data()); 64 | } 65 | break; 66 | case IDOK: 67 | if (HIWORD(w_param) == BN_CLICKED) { 68 | apply_choice(); 69 | display(false); 70 | } 71 | break; 72 | case IDCANCEL: 73 | if (HIWORD(w_param) == BN_CLICKED) { 74 | update_controls(); // Reset all settings 75 | display(false); 76 | } 77 | default: 78 | break; 79 | } 80 | } 81 | default: 82 | break; 83 | } 84 | return FALSE; 85 | } 86 | -------------------------------------------------------------------------------- /src/ui/AspellOptionsDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "ui/StaticDialog.h" 17 | 18 | class SpellerContainer; 19 | 20 | class AspellOptionsDialog : public StaticDialog { 21 | public: 22 | explicit AspellOptionsDialog(HINSTANCE h_inst, HWND parent, const Settings &settings, const SpellerContainer &spellers); 23 | void do_dialog(); 24 | void apply_choice(); 25 | void update_controls(); 26 | 27 | protected: 28 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, 29 | LPARAM l_param) override; 30 | HWND m_allow_run_together_cb = nullptr; 31 | HWND m_aspell_personal_path_le = nullptr; 32 | 33 | protected: 34 | const Settings &m_settings; 35 | const SpellerContainer &m_spellers; 36 | }; 37 | -------------------------------------------------------------------------------- /src/ui/ConnectionSettingsDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "common/Utility.h" 17 | #include "common/WinApiControls.h" 18 | #include "plugin/Settings.h" 19 | #include "ui/StaticDialog.h" 20 | 21 | class Settings; 22 | class SpellChecker; 23 | enum class ProxyType; 24 | 25 | class ConnectionSettingsDialog : public StaticDialog { 26 | public: 27 | explicit ConnectionSettingsDialog(const Settings &settings, DownloadDictionariesDialog &download_dics_dlg); 28 | void do_dialog(); 29 | void apply_choice(); 30 | void update_controls( 31 | ); 32 | 33 | protected: 34 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, 35 | LPARAM l_param) override; 36 | void disable_controls(); 37 | 38 | protected: 39 | HWND m_port = nullptr; 40 | HWND m_user_name = nullptr; 41 | HWND m_host_name = nullptr; 42 | HWND m_passive_mode_cb = nullptr; 43 | HWND m_password = nullptr; 44 | HWND m_use_proxy = nullptr; 45 | HWND m_proxy_anonymous = nullptr; 46 | DownloadDictionariesDialog &m_download_dics_dlg; 47 | 48 | WinApi::EnumComboBox m_proxy_type_cmb; 49 | const Settings &m_settings; 50 | }; 51 | -------------------------------------------------------------------------------- /src/ui/ContextMenuHandler.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "common/Utility.h" 17 | #include "plugin/Constants.h" 18 | 19 | class Settings; 20 | class SpellerContainer; 21 | class EditorInterface; 22 | class SuggestionMenuButton; 23 | class SpellChecker; 24 | 25 | class ContextMenuHandler { 26 | public: 27 | ContextMenuHandler(const Settings &settings, 28 | const SpellerContainer &speller_container, 29 | EditorInterface &editor, 30 | const SpellChecker &spell_checker); 31 | [[nodiscard]] std::vector select_word_and_get_suggestion_menu_items(); 32 | void process_menu_result(WPARAM menu_id); 33 | void update_word_under_cursor_data(); 34 | void precalculate_menu(); 35 | void init_suggestions_box(SuggestionMenuButton &suggestion_button); 36 | bool is_word_under_cursor_correct() const { return m_word_under_cursor_is_correct; } 37 | 38 | private: 39 | bool select_word_under_cursor(); 40 | void do_plugin_menu_inclusion(bool invalidate = false); 41 | void process_ignore_all(); 42 | void process_add_to_dictionary(); 43 | void process_replace(WPARAM result); 44 | void process_replace_all(WPARAM result); 45 | void process_plugin_menu_result(WPARAM menu_id); 46 | void process_language_menu_result(WPARAM menu_id); 47 | 48 | private: 49 | const Settings &m_settings; 50 | const SpellerContainer &m_speller_container; 51 | EditorInterface &m_editor; 52 | MappedWstring m_last_selected_word; 53 | TextPosition m_word_under_cursor_length = 0; 54 | TextPosition m_word_under_cursor_pos = 0; 55 | std::vector m_last_suggestions; 56 | const SpellChecker &m_spell_checker; 57 | bool m_word_under_cursor_is_correct = true; 58 | }; 59 | -------------------------------------------------------------------------------- /src/ui/MenuItem.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "MenuItem.h" 16 | 17 | #include "plugin/Constants.h" 18 | 19 | MenuItem::MenuItem(const wchar_t *text_arg, int id_arg, 20 | bool separator_arg /*= false*/) { 21 | text = text_arg; 22 | id = static_cast(id_arg); 23 | separator = separator_arg; 24 | } 25 | 26 | void MenuItem::append_to_menu(HMENU menu, int insert_pos) const { 27 | MENUITEMINFO mi; 28 | memset(&mi, 0, sizeof(mi)); 29 | mi.cbSize = sizeof(MENUITEMINFO); 30 | if (separator) { 31 | mi.fType = MFT_SEPARATOR; 32 | } else { 33 | mi.fType = MFT_STRING; 34 | mi.fMask = MIIM_ID | MIIM_TYPE; 35 | if (!children.empty()) { 36 | mi.fMask |= MIIM_SUBMENU; 37 | mi.hSubMenu = CreatePopupMenu(); 38 | for (auto &child : children) { 39 | child.append_to_menu(mi.hSubMenu); 40 | } 41 | } 42 | if (!get_use_allocated_ids()) 43 | mi.wID = MAKEWORD(id, menu_id::plguin_menu); 44 | else 45 | mi.wID = get_context_menu_id_start() + id; 46 | 47 | mi.dwTypeData = const_cast(text.data()); 48 | mi.cch = static_cast(text.length()) + 1; 49 | } 50 | if (insert_pos == -1) 51 | InsertMenuItem(menu, GetMenuItemCount(menu), 1, &mi); 52 | else 53 | InsertMenuItem(menu, insert_pos, 1, &mi); 54 | } 55 | -------------------------------------------------------------------------------- /src/ui/MenuItem.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | class MenuItem { 18 | public: 19 | struct Separator { 20 | }; 21 | 22 | std::wstring text; 23 | BYTE id; 24 | bool separator; 25 | std::vector children; 26 | MenuItem(const wchar_t *text_arg, int id_arg, 27 | bool separator_arg = false); 28 | 29 | MenuItem(const Separator &) 30 | : MenuItem(L"", -1, true) { 31 | 32 | } 33 | 34 | void append_to_menu(HMENU menu, int insert_pos = -1) const; 35 | 36 | template 37 | static void append_to_menu(HMENU menu, const Range &range) { 38 | for (auto &item : range) 39 | item.append_to_menu(menu); 40 | } 41 | 42 | template 43 | static void prepend_to_menu(HMENU menu, const Range &range) { 44 | for (auto it = range.rbegin(); it != range.rend(); ++it) 45 | it->append_to_menu(menu, 0); 46 | } 47 | }; 48 | -------------------------------------------------------------------------------- /src/ui/ProgressDialog.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "ProgressDialog.h" 16 | 17 | #include "DownloadDictionariesDialog.h" 18 | #include "common/ProgressData.h" 19 | #include "plugin/resource.h" 20 | 21 | void ProgressDialog::do_dialog() { 22 | if (!isCreated()) { 23 | create(IDD_DIALOGPROGRESS); 24 | } else { 25 | goToCenter(); 26 | display(); 27 | } 28 | } 29 | 30 | void ProgressDialog::init(HINSTANCE h_inst, HWND parent) { 31 | return Window::init(h_inst, parent); 32 | } 33 | 34 | namespace { 35 | constexpr auto ui_update_timer_id = 0; 36 | } 37 | 38 | INT_PTR ProgressDialog::run_dlg_proc(UINT message, WPARAM w_param, 39 | LPARAM /*lParam*/) { 40 | switch (message) { 41 | case WM_SHOWWINDOW: { 42 | constexpr auto timer_resolution = 100; 43 | if (w_param == TRUE) { 44 | SetTimer(_hSelf, ui_update_timer_id, timer_resolution, nullptr); 45 | } else { 46 | KillTimer(_hSelf, ui_update_timer_id); 47 | } 48 | } 49 | case WM_TIMER: { 50 | switch (w_param) { 51 | case ui_update_timer_id: 52 | update(); 53 | return 0; 54 | default: 55 | break; 56 | } 57 | } 58 | case WM_INITDIALOG: { 59 | m_h_desc_top = GetDlgItem(_hSelf, IDC_DESCTOP); 60 | m_h_desc_bottom = GetDlgItem(_hSelf, IDC_DESCBOTTOM); 61 | m_h_progress_bar = GetDlgItem(_hSelf, IDC_PROGRESSBAR); 62 | SendMessage(m_h_progress_bar, PBM_SETRANGE, 0, 63 | static_cast(MAKELONG(0, 100))); 64 | return TRUE; 65 | } 66 | case WM_COMMAND: 67 | switch (LOWORD(w_param)) { 68 | case IDC_STOP: 69 | if (HIWORD(w_param) == BN_CLICKED) { 70 | m_download_dics_dlg.set_cancel_pressed(true); 71 | } 72 | break; 73 | }; 74 | break; 75 | }; 76 | return FALSE; 77 | } 78 | 79 | void ProgressDialog::set_marquee(bool animated) { 80 | if (m_marquee == animated) 81 | return; 82 | m_marquee = animated; 83 | auto dw_style = ::GetWindowLongPtr(m_h_progress_bar, GWL_STYLE); 84 | if (animated) 85 | dw_style = dw_style | PBS_MARQUEE; 86 | else 87 | dw_style = dw_style & (~PBS_MARQUEE); 88 | 89 | ::SetWindowLongPtr(m_h_progress_bar, GWL_STYLE, dw_style); 90 | SendMessage(m_h_progress_bar, PBM_SETMARQUEE, animated, 0); 91 | } 92 | 93 | void ProgressDialog::update() { 94 | SendMessage(m_h_progress_bar, PBM_SETPOS, static_cast(m_progress_data->get_progress()), 0); 95 | Static_SetText(m_h_desc_bottom, m_progress_data->get_status().c_str()); 96 | set_marquee(m_progress_data->get_marquee()); 97 | Static_SetText(m_h_desc_top, m_top_message.c_str()); 98 | } 99 | 100 | void ProgressDialog::set_top_message(const wchar_t *message) { 101 | m_top_message = message; 102 | } 103 | 104 | ProgressDialog::ProgressDialog(DownloadDictionariesDialog &download_dics_dlg) 105 | : m_progress_data(std::make_shared()), 106 | m_download_dics_dlg(download_dics_dlg) { 107 | } 108 | 109 | ProgressDialog::~ProgressDialog() { 110 | KillTimer(_hSelf, ui_update_timer_id); 111 | } 112 | -------------------------------------------------------------------------------- /src/ui/ProgressDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "StaticDialog.h" 18 | 19 | class ProgressData; 20 | 21 | class ProgressDialog : public StaticDialog { 22 | public: 23 | ProgressDialog(DownloadDictionariesDialog &download_dics_dlg); 24 | ~ProgressDialog() override; 25 | 26 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, LPARAM l_param) override; // NOLINT 27 | void init(HINSTANCE h_inst, HWND parent) override; 28 | void do_dialog(); 29 | void set_top_message(const wchar_t *message); 30 | void set_marquee(bool animated); 31 | std::shared_ptr get_progress_data() const { return m_progress_data; } 32 | void update(); 33 | 34 | private: 35 | std::shared_ptr m_progress_data; 36 | HWND m_h_desc_bottom = nullptr; 37 | HWND m_h_desc_top = nullptr; 38 | HWND m_h_progress_bar = nullptr; 39 | bool m_marquee = false; 40 | std::wstring m_top_message; 41 | DownloadDictionariesDialog &m_download_dics_dlg; 42 | }; 43 | -------------------------------------------------------------------------------- /src/ui/RemoveDictionariesDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "ui/StaticDialog.h" 18 | 19 | class Settings; 20 | class SpellChecker; 21 | class SpellerContainer; 22 | class LanguageInfo; 23 | 24 | class RemoveDictionariesDialog : public StaticDialog { 25 | public: 26 | RemoveDictionariesDialog(HINSTANCE h_inst, HWND parent, 27 | const Settings &settings, 28 | const SpellerContainer &speller_container); 29 | void do_dialog(); 30 | void update_list(); 31 | void remove_selected(); 32 | HWND get_list_box(); 33 | void update_options(); 34 | void update_controls(); 35 | 36 | protected: 37 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, 38 | LPARAM l_param) override; 39 | 40 | protected: 41 | HWND m_lang_list = nullptr; 42 | HWND m_remove_user_dics = nullptr; 43 | HWND m_remove_system = nullptr; 44 | const Settings &m_settings; 45 | const SpellerContainer &m_speller_container; 46 | std::vector m_cur_lang_list; 47 | }; 48 | -------------------------------------------------------------------------------- /src/ui/SelectMultipleLanguagesDialog.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "ui/StaticDialog.h" 17 | 18 | class SpellChecker; 19 | class Settings; 20 | class SpellerContainer; 21 | 22 | class SelectMultipleLanguagesDialog : public StaticDialog { 23 | public: 24 | SelectMultipleLanguagesDialog(HINSTANCE h_inst, HWND parent, const Settings &settings, 25 | const SpellerContainer &speller_container); 26 | void do_dialog(); 27 | HWND get_list_box(); 28 | void update_list(); 29 | 30 | protected: 31 | void apply(); 32 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, 33 | LPARAM l_param) override; // NOLINT 34 | 35 | private: 36 | HWND m_h_lang_list = nullptr; 37 | const Settings &m_settings; 38 | const SpellerContainer &m_speller_container; 39 | }; 40 | -------------------------------------------------------------------------------- /src/ui/SuggestionMenuButton.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | #include "StaticDialog.h" 18 | 19 | class SpellChecker; 20 | class NppInterface; 21 | class Settings; 22 | class ContextMenuHandler; 23 | 24 | class SuggestionMenuButton : public StaticDialog { 25 | public: 26 | void do_dialog(); 27 | HMENU get_popup_menu() const; 28 | int get_result() const; 29 | bool is_pressed() const; 30 | SuggestionMenuButton(HINSTANCE h_inst, HWND parent, NppInterface &npp, 31 | ContextMenuHandler &context_menu_handler, 32 | const Settings &settings); 33 | void show_suggestion_menu(); 34 | void on_settings_changed(); 35 | void set_transparency(); 36 | 37 | protected: 38 | INT_PTR WINAPI run_dlg_proc(UINT message, WPARAM w_param, 39 | LPARAM l_param) override; 40 | 41 | private: 42 | bool m_state_pressed = false; 43 | bool m_state_hovered = false; 44 | bool m_state_menu = false; 45 | NppInterface &m_npp; 46 | const Settings &m_settings; 47 | ContextMenuHandler &m_context_menu_handler; 48 | }; 49 | -------------------------------------------------------------------------------- /test/EncodingTests.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "MockEditorInterface.h" 16 | #include "MockSpeller.h" 17 | #include "TestCommon.h" 18 | #include "core/SpellChecker.h" 19 | #include "plugin/Constants.h" 20 | #include "plugin/Settings.h" 21 | #include "spellers/SpellerContainer.h" 22 | 23 | #include 24 | 25 | TEST_CASE("ANSI") { 26 | Settings settings; 27 | auto speller = std::make_unique(settings); 28 | setup_speller(*speller); 29 | settings.data.speller_language[SpellerId::aspell] = L"English"; 30 | MockEditorInterface editor; 31 | TARGET_VIEW_BLOCK(editor, 0); 32 | editor.open_virtual_document(L"test.txt", L"abcd\nefgh"); 33 | SpellerContainer sp_container(&settings, std::move(speller)); 34 | SpellChecker sc(&settings, editor, sp_container); 35 | 36 | editor.set_codepage(EditorCodepage::ansi); 37 | sc.recheck_visible_both_views(); 38 | CHECK(editor.get_underlined_words(spell_check_indicator_id) == 39 | std::vector{"abcd", "efgh"}); 40 | } 41 | 42 | TEST_CASE("UTF-8 shenanigans") { 43 | { 44 | Settings settings; 45 | auto speller = std::make_unique(settings); 46 | setup_speller(*speller); 47 | settings.data.speller_language[SpellerId::aspell] = L"English"; 48 | MockEditorInterface editor; 49 | TARGET_VIEW_BLOCK(editor, 0); 50 | editor.open_virtual_document(L"test.txt", L"тестирование с нетривиальными utf-8 символами"); 51 | SpellerContainer sp_container(&settings, std::move(speller)); 52 | SpellChecker sc(&settings, editor, sp_container); 53 | 54 | CHECK(editor.get_prev_valid_begin_pos(2) == 0); 55 | CHECK(editor.get_next_valid_end_pos(4) == 6); 56 | // moving around word 'нетривиальными' 57 | CHECK(editor.get_prev_valid_begin_pos(28) == 27); 58 | CHECK(editor.get_next_valid_end_pos(56) == 57); 59 | // and a bit further 60 | CHECK(editor.get_prev_valid_begin_pos(27) == 25); 61 | CHECK(editor.get_next_valid_end_pos(56) == 57); 62 | 63 | editor.set_active_document_text(L"test tests test"); 64 | editor.set_codepage(EditorCodepage::ansi); 65 | CHECK(editor.get_prev_valid_begin_pos(5) == 4); 66 | CHECK(editor.get_next_valid_end_pos(5) == 6); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /test/MockSpeller.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | #include "spellers/SpellerInterface.h" 17 | 18 | #include 19 | #include 20 | 21 | class Settings; 22 | 23 | class MockSpeller : public SpellerInterface { 24 | using parent_t = SpellerInterface; 25 | public: 26 | using Dict = 27 | std::unordered_map>; 28 | using SuggestionsDict = std::unordered_map< 29 | std::wstring, 30 | std::unordered_map>>; 31 | ; 32 | MockSpeller(const Settings &settings); 33 | virtual ~MockSpeller(); 34 | void set_language(const wchar_t *lang) override; 35 | void add_to_dictionary(const wchar_t *word) override; 36 | void ignore_all(const wchar_t *word) override; 37 | bool is_working() const override; 38 | std::vector get_language_list() const override; 39 | void set_multiple_languages(const std::vector &list) override; 40 | std::vector get_suggestions(const wchar_t *word) const override; 41 | 42 | void set_inner_dict(const Dict &dict); 43 | void set_suggestions_dict(const SuggestionsDict &dict); 44 | 45 | bool check_word(const WordForSpeller &word) const override; 46 | void set_working(bool working); 47 | 48 | std::vector check_words(const std::vector &words) const override; 49 | private: 50 | std::wstring m_current_lang; 51 | std::unordered_set m_ignored; 52 | std::vector m_current_multi_lang; 53 | Dict m_user_dict; 54 | Dict m_inner_dict; 55 | SuggestionsDict m_sugg_dict; 56 | bool m_working = true; 57 | const Settings &m_settings; 58 | }; 59 | -------------------------------------------------------------------------------- /test/TestCommon.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #include "MockSpeller.h" 16 | 17 | void setup_speller(MockSpeller &speller) { 18 | speller.set_inner_dict({{L"English", 19 | {L"This", L"is", L"test", L"document", L"Document", L"Please", L"please", 20 | L"bear", L"with", L"me", L"И", L"ещё", L"немного", L"слов", L"Paris", L"D'Artagnan"}}}); 21 | MockSpeller::SuggestionsDict dict; 22 | dict[L"English"][L"abcdef"] = {L"document", L"please"}; 23 | dict[L"English"][L"немонго"] = {L"немного", L"много"}; 24 | speller.set_suggestions_dict(std::move (dict)); 25 | } 26 | -------------------------------------------------------------------------------- /test/TestCommon.h: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #pragma once 16 | 17 | class MockSpeller; 18 | 19 | void setup_speller(MockSpeller &speller); 20 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of DSpellCheck Plug-in for Notepad++ 2 | // Copyright (C)2019 Sergey Semushin 3 | // This program is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU General Public License 5 | // as published by the Free Software Foundation; either version 2 6 | // of the License, or (at your option) any later version. 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU General Public License for more details. 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 14 | 15 | #define CATCH_CONFIG_MAIN 16 | #include "catch.hpp" 17 | --------------------------------------------------------------------------------