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 // new aspell pspell missing extern "C"
23 #include <pspell/pspell.h>
30 PSpell::PSpell(BufferParams const &, string const & lang)
31 : sc(0), els(0), spell_error_object(0), alive_(false)
33 PspellConfig * config = new_pspell_config();
34 pspell_config_replace(config, "lang", lang.c_str());
35 spell_error_object = new_pspell_manager(config);
36 if (pspell_error_number(spell_error_object) == 0) {
37 sc = to_pspell_manager(spell_error_object);
38 spell_error_object = 0;
41 lyxerr << pspell_error_message(spell_error_object) << endl;
51 delete_pspell_string_emulation(els);
55 void PSpell::cleanUp()
57 if (spell_error_object) {
58 delete_pspell_can_have_error(spell_error_object);
59 spell_error_object = 0;
64 enum PSpell::Result PSpell::check(string const & word)
71 int word_ok = pspell_manager_check(sc, word.c_str());
72 lyx::Assert(word_ok != -1);
77 PspellWordList const * sugs =
78 pspell_manager_suggest(sc, word.c_str());
79 lyx::Assert(sugs != 0);
80 els = pspell_word_list_elements(sugs);
81 if (pspell_word_list_empty(sugs))
93 pspell_manager_save_all_word_lists(sc);
97 void PSpell::insert(string const & word)
100 pspell_manager_add_to_personal(sc, word.c_str());
104 void PSpell::accept(string const & word)
107 pspell_manager_add_to_session(sc, word.c_str());
111 string const PSpell::nextMiss()
113 char const * str = 0;
116 str = pspell_string_emulation_next(els);
123 string const PSpell::error()
125 char const * err = 0;
127 if (spell_error_object && pspell_error_number(spell_error_object) != 0) {
128 err = pspell_error_message(spell_error_object);