sptk2 logo
SPTK Home Page
CEditorSpellChecker.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <FL/Fl.H>
30
31#include <sptk5/cgui>
32#include <sptk5/sptk.h>
33
34#include <map>
35
36struct AspellSpeller;
37struct AspellConfig;
38
39namespace sptk {
40
50{
51public:
56
61
65 CSpellOption(const String& name, const String& value);
66
71 {
72 m_name = co.m_name;
73 m_value = co.m_value;
74 }
75
79 CSpellOption& operator=(const char* value);
80
85};
86
90class CSpellOptions : public std::map<String, CSpellOption>
91{
92
93public:
98 {
99 }
100};
101
106 , public CDialog
107{
111 CInput* m_wordInput;
112
116 CInput* m_replaceToInput;
117
121 CListView* m_suggestionListView;
122
126 AspellSpeller* m_spellChecker;
127
128#ifdef _WIN32
129
133 std::string m_personalDirectory;
134
135#endif
136
142 static void getConfigStrings(AspellConfig* aconfig, CSpellOptions& options);
143
148 void setLocalOptions(AspellConfig* aconfig);
149
150protected:
154 static void cb_learn(Fl_Widget*, void*);
155
159 static void cb_ignore(Fl_Widget*, void*);
160
164 static void cb_suggest(Fl_Widget*, void*);
165
169 static void cb_replaceword(Fl_Widget*, void*);
170
171
176
181
186
187public:
192
197 {
198 }
199
203 void getDictionaries(Strings& dictionaries);
204
208 void getOptions(CSpellOptions& options);
209
213 virtual void textStart() = 0;
214
218 virtual bool getNextWord(String& w, int& wordStart, int& wordEnd)
219 {
220 return false;
221 }
222
226 virtual bool replaceWord(const String& w, int wordStart, int wordEnd)
227 {
228 return false;
229 }
230
235
239 CSpellOption& operator[](const String& optionName);
240
241#ifdef _WIN32
245 void personalDirectory(const String& dir)
246 {
247 m_personalDirectory = dir;
248 }
249
253 String personalDirectory() const
254 {
255 return m_personalDirectory;
256 }
257#endif
258};
259
264{
268 CEditor* m_editor;
269
273 uint32_t m_bufferPosition {0};
274
275public:
280 explicit CEditorSpellChecker(CEditor* editor)
281 : m_editor(editor)
282 {
283 }
284
288 virtual void textStart();
289
293 virtual bool getNextWord(String& w, int& wordStart, int& wordEnd);
294
298 virtual bool replaceWord(const String& w, int wordStart, int wordEnd);
299};
303} // namespace sptk
Definition: CDialog.h:126
Definition: CEditorSpellChecker.h:264
virtual bool replaceWord(const String &w, int wordStart, int wordEnd)
virtual bool getNextWord(String &w, int &wordStart, int &wordEnd)
CEditorSpellChecker(CEditor *editor)
Definition: CEditorSpellChecker.h:280
virtual void textStart()
Text editor widget.
Definition: CEditor.h:50
Definition: CInput.h:197
List view widget.
Definition: CListView.h:108
Definition: CEditorSpellChecker.h:107
virtual bool replaceWord(const String &w, int wordStart, int wordEnd)
Definition: CEditorSpellChecker.h:226
static void cb_suggest(Fl_Widget *, void *)
void getDictionaries(Strings &dictionaries)
CSpellOption & operator[](const String &optionName)
void getOptions(CSpellOptions &options)
virtual bool getNextWord(String &w, int &wordStart, int &wordEnd)
Definition: CEditorSpellChecker.h:218
static void cb_replaceword(Fl_Widget *, void *)
static void cb_ignore(Fl_Widget *, void *)
virtual void textStart()=0
static void cb_learn(Fl_Widget *, void *)
virtual ~CSpellChecker()
Definition: CEditorSpellChecker.h:196
Definition: CEditorSpellChecker.h:50
CSpellOption(const String &name, const String &value)
String m_value
Definition: CEditorSpellChecker.h:60
CSpellOption & operator=(const char *value)
CSpellOption & operator=(const String &value)
CSpellOption(const CSpellOption &co)
Definition: CEditorSpellChecker.h:70
String m_name
Definition: CEditorSpellChecker.h:55
Definition: CEditorSpellChecker.h:91
CSpellOptions()
Definition: CEditorSpellChecker.h:97
Definition: String.h:49
Definition: Strings.h:52

Fri Oct 14 2022 09:58:31: SPTK 5.4.1