]> git.lyx.org Git - lyx.git/blob - src/ISpell.h
Cosmetics.
[lyx.git] / src / ISpell.h
1 // -*- C++ -*-
2 /**
3  * \file ISpell.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef SP_ISPELL_H
14 #define SP_ISPELL_H
15
16 #include "SpellBase.h"
17
18 #include "support/docstring.h"
19
20 #include <boost/scoped_ptr.hpp>
21
22 #include <cstdio>
23
24 namespace lyx {
25
26 class BufferParams;
27
28 namespace support { class ForkedProcess; }
29
30 /// i/a spell process-based spellchecker
31 class ISpell : public SpellBase {
32 public:
33         ISpell(BufferParams const & params, std::string const & lang);
34
35         ~ISpell();
36
37         /// return true if the spellchecker instance still exists
38         virtual bool alive();
39
40         /// check the given word and return the result
41         virtual enum Result check(WordLangTuple const & word);
42
43         /// insert the given word into the personal dictionary
44         virtual void insert(WordLangTuple const & word);
45
46         /// accept the given word temporarily
47         virtual void accept(WordLangTuple const & word);
48
49         /// return the next near miss after a SUGGESTED_WORDS result
50         virtual docstring const nextMiss();
51
52         /// give an error message on messy exit
53         virtual docstring const error();
54
55 private:
56         /// read some data. Returns true on an error. Sets err_read
57         /// to true if the data was from stderr.
58         bool select(bool & err_read);
59
60         /// instream to communicate with ispell
61         FILE * in;
62         /// outstream to communicate with ispell
63         FILE * out;
64         /// errstream for ispell
65         FILE * inerr;
66
67         /// pipe fds
68         int pipein[2];
69         int pipeout[2];
70         int pipeerr[2];
71
72         /// buffer for reading
73         char buf[BUFSIZ];
74
75         /// spell error
76         docstring error_;
77
78         boost::scoped_ptr<support::ForkedProcess> child_;
79
80         /// iconv name of the encoding that is used to communicate with ispell
81         std::string encoding;
82
83         // vileness below ... please FIXME
84         /// str ???
85         char * str;
86         /// e ???
87         char * e;
88
89 };
90
91 } // namespace lyx
92
93 #endif // ISPELL_H