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, "language-tag", 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;
49 delete_pspell_string_emulation(els);
53 void PSpell::cleanUp()
55 if (spell_error_object) {
56 delete_pspell_can_have_error(spell_error_object);
57 spell_error_object = 0;
62 enum PSpell::Result PSpell::check(string const & word)
69 int word_ok = pspell_manager_check(sc, word.c_str());
70 lyx::Assert(word_ok != -1);
75 PspellWordList const * sugs =
76 pspell_manager_suggest(sc, word.c_str());
77 lyx::Assert(sugs != 0);
78 els = pspell_word_list_elements(sugs);
79 if (pspell_word_list_empty(sugs))
91 pspell_manager_save_all_word_lists(sc);
95 void PSpell::insert(string const & word)
98 pspell_manager_add_to_personal(sc, word.c_str());
102 void PSpell::accept(string const & word)
105 pspell_manager_add_to_session(sc, word.c_str());
109 string const PSpell::nextMiss()
111 char const * str = 0;
114 str = pspell_string_emulation_next(els);
121 string const PSpell::error()
123 char const * err = 0;
125 if (spell_error_object && pspell_error_number(spell_error_object) != 0) {
126 err = pspell_error_message(spell_error_object);