3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Kevin Atkinson
7 * \author John Levon <levon@movementarian.org>
13 #pragma implementation
18 #include "support/LAssert.h"
20 #define USE_ORIGINAL_MANAGER_FUNCS 1
21 #include <pspell/pspell.h>
26 PSpell::PSpell(BufferParams const & params, string const & lang)
27 : sc(0), els(0), spell_error_object(0), alive_(false)
29 PspellConfig * config = new_pspell_config();
30 config->replace("language-tag", lang.c_str());
31 spell_error_object = new_pspell_manager(config);
32 if (pspell_error_number(spell_error_object) == 0) {
33 sc = to_pspell_manager(spell_error_object);
34 spell_error_object = 0;
45 delete_pspell_string_emulation(els);
49 void PSpell::cleanUp()
51 if (spell_error_object) {
52 delete_pspell_can_have_error(spell_error_object);
53 spell_error_object = 0;
58 enum PSpell::Result PSpell::check(string const & word)
65 int word_ok = pspell_manager_check(sc, word.c_str());
66 lyx::Assert(word_ok != -1);
71 PspellWordList const * sugs =
72 pspell_manager_suggest(sc, word.c_str());
73 lyx::Assert(sugs != 0);
74 els = pspell_word_list_elements(sugs);
75 if (pspell_word_list_empty(sugs))
87 pspell_manager_save_all_word_lists(sc);
91 void PSpell::insert(string const & word)
94 pspell_manager_add_to_personal(sc, word.c_str());
98 void PSpell::accept(string const & word)
101 pspell_manager_add_to_session(sc, word.c_str());
105 string const PSpell::nextMiss()
107 char const * str = 0;
110 str = pspell_string_emulation_next(els);
117 string const PSpell::error()
119 char const * err = 0;
121 if (pspell_error_number(spell_error_object) != 0) {
122 err = pspell_error_message(spell_error_object);