2002-08-04 23:11:50 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2002-09-26 08:57:43 +00:00
|
|
|
* \file ispell.h
|
2003-08-23 00:17:00 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-08-04 23:11:50 +00:00
|
|
|
*
|
|
|
|
* \author unknown
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-08-04 23:11:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SP_ISPELL_H
|
|
|
|
#define SP_ISPELL_H
|
|
|
|
|
|
|
|
#include "SpellBase.h"
|
|
|
|
|
2006-09-11 08:54:10 +00:00
|
|
|
#include "support/docstring.h"
|
|
|
|
|
2003-02-17 18:40:04 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
namespace lyx {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
class BufferParams;
|
|
|
|
|
|
|
|
namespace support { class ForkedProcess; }
|
2002-08-04 23:11:50 +00:00
|
|
|
|
|
|
|
/// i/a spell process-based spellchecker
|
|
|
|
class ISpell : public SpellBase {
|
|
|
|
public:
|
2003-10-06 15:43:21 +00:00
|
|
|
ISpell(BufferParams const & params, std::string const & lang);
|
2002-08-04 23:11:50 +00:00
|
|
|
|
|
|
|
~ISpell();
|
|
|
|
|
|
|
|
/// return true if the spellchecker instance still exists
|
|
|
|
virtual bool alive();
|
|
|
|
|
|
|
|
/// check the given word and return the result
|
2002-08-06 22:38:44 +00:00
|
|
|
virtual enum Result check(WordLangTuple const & word);
|
2002-08-04 23:11:50 +00:00
|
|
|
|
|
|
|
/// insert the given word into the personal dictionary
|
2002-08-06 22:38:44 +00:00
|
|
|
virtual void insert(WordLangTuple const & word);
|
2002-08-04 23:11:50 +00:00
|
|
|
|
|
|
|
/// accept the given word temporarily
|
2002-08-06 22:38:44 +00:00
|
|
|
virtual void accept(WordLangTuple const & word);
|
2002-08-04 23:11:50 +00:00
|
|
|
|
2005-01-20 16:17:37 +00:00
|
|
|
/// return the next near miss after a SUGGESTED_WORDS result
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual std::string const nextMiss();
|
2002-08-04 23:11:50 +00:00
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
/// give an error message on messy exit
|
2006-10-21 00:16:43 +00:00
|
|
|
virtual docstring const error();
|
2002-08-04 23:11:50 +00:00
|
|
|
|
|
|
|
private:
|
2003-02-17 18:40:04 +00:00
|
|
|
/// read some data. Returns true on an error. Sets err_read
|
|
|
|
/// to true if the data was from stderr.
|
|
|
|
bool select(bool & err_read);
|
2002-10-31 12:42:26 +00:00
|
|
|
|
2002-08-04 23:11:50 +00:00
|
|
|
/// instream to communicate with ispell
|
|
|
|
FILE * in;
|
|
|
|
/// outstream to communicate with ispell
|
|
|
|
FILE * out;
|
2003-02-17 18:40:04 +00:00
|
|
|
/// errstream for ispell
|
|
|
|
FILE * inerr;
|
|
|
|
|
|
|
|
/// pipe fds
|
|
|
|
int pipein[2];
|
|
|
|
int pipeout[2];
|
|
|
|
int pipeerr[2];
|
|
|
|
|
|
|
|
/// buffer for reading
|
|
|
|
char buf[BUFSIZ];
|
|
|
|
|
2002-08-04 23:11:50 +00:00
|
|
|
/// spell error
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring error_;
|
2003-02-17 18:40:04 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
boost::scoped_ptr<support::ForkedProcess> child_;
|
2002-08-04 23:11:50 +00:00
|
|
|
|
|
|
|
// vileness below ... please FIXME
|
|
|
|
/// str ???
|
|
|
|
char * str;
|
|
|
|
/// e ???
|
|
|
|
char * e;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2002-08-04 23:11:50 +00:00
|
|
|
#endif // ISPELL_H
|