Abdelrazak Younes wrote:
Abdelrazak Younes wrote:
Jean-Marc Lasgouttes wrote:
Abdelrazak Younes <you...@lyx.org> writes:
We could add hunspell as a new backend in addition to apsell,
Yes. Are you able to add the autotools support? Someone else will take
care of scons and cmake I guess.
Sure. Do we want to be able to compile both aspell and hunspell in at
the same time, or rather shall we fix only one spell library?
The patch....
Hum, a cleaner patch...
And a patch that actually compiles...
Abdel.
Index: src/HunspellSpellChecker.h
===================================================================
--- src/HunspellSpellChecker.h (revision 0)
+++ src/HunspellSpellChecker.h (revision 0)
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+/**
+ * \file HunspellSpellChecker.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef LYX_HUNSPELL_H
+#define LYX_HUNSPELL_H
+
+#include "SpellChecker.h"
+
+namespace lyx {
+
+
+class HunspellSpellChecker : public SpellChecker
+{
+public:
+ HunspellSpellChecker();
+ ~HunspellSpellChecker();
+
+ SpellChecker::Result check(WordLangTuple const &);
+ void insert(WordLangTuple const &);
+ void accept(WordLangTuple const &);
+ docstring const nextMiss();
+ docstring const error();
+
+private:
+ struct Private;
+ Private * d;
+};
+
+
+} // namespace lyx
+
+#endif // LYX_Hunspell_H
Index: src/HunspellSpellChecker.cpp
===================================================================
--- src/HunspellSpellChecker.cpp (revision 0)
+++ src/HunspellSpellChecker.cpp (revision 0)
@@ -0,0 +1,80 @@
+/**
+ * \file HunspellSpellChecker.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "HunspellSpellChecker.h"
+
+#include "LyXRC.h"
+#include "WordLangTuple.h"
+
+#include "support/lassert.h"
+#include "support/debug.h"
+
+#include <hunspell/hunspell.hxx>
+
+#include <map>
+#include <string>
+
+using namespace std;
+
+namespace lyx {
+
+namespace {
+typedef map<std::string, Hunspell *> Spellers;
+}
+
+class HunspellSpellChecker::Private
+{
+ /// the spellers
+ Spellers spellers_;
+};
+
+
+HunspellSpellChecker::HunspellSpellChecker(): d(new Private)
+{
+}
+
+
+HunspellSpellChecker::~HunspellSpellChecker()
+{
+ delete d;
+}
+
+
+SpellChecker::Result HunspellSpellChecker::check(WordLangTuple const & word)
+{
+ return OK;
+}
+
+
+void HunspellSpellChecker::insert(WordLangTuple const & word)
+{
+}
+
+
+void HunspellSpellChecker::accept(WordLangTuple const & word)
+{
+}
+
+
+docstring const HunspellSpellChecker::nextMiss()
+{
+ return docstring();
+}
+
+
+docstring const HunspellSpellChecker::error()
+{
+ return docstring();
+}
+
+
+} // namespace lyx
Index: src/Makefile.am
===================================================================
--- src/Makefile.am (revision 30424)
+++ src/Makefile.am (working copy)
@@ -21,7 +21,7 @@
pch.h
OTHERLIBS = $(BOOST_LIBS) $(INTLLIBS) $(MYTHES_LIBS) $(AIKSAURUS_LIBS) \
- @LIBS@ $(SOCKET_LIBS) $(LIBSHLWAPI) $(LIBPSAPI)
+ @LIBS@ $(SOCKET_LIBS) $(LIBSHLWAPI) $(LIBPSAPI)
noinst_LIBRARIES = liblyxcore.a
bin_PROGRAMS = lyx
@@ -36,7 +36,7 @@
support/liblyxsupport.a \
$(OTHERLIBS) \
$(QT4_LDFLAGS) \
- $(QT4_LIB)
+ $(QT4_LIB)
if LYX_WIN_RESOURCE
.rc.o:
@@ -52,6 +52,10 @@
ASPELL = ASpell.cpp ASpell_local.h
endif
+if USE_HUNSPELL
+HUNSPELL = HunspellSpellChecker.cpp HunspellSpellChecker.h
+endif
+
# These four objects are linked as object files as they are not
# referenced within the core and therefore are not picked up
# by the linker without looping over libs. We do not want that,
@@ -65,6 +69,7 @@
Box.h \
Dimension.cpp \
Dimension.h \
+ $(HUNSPELL) \
PrinterParams.cpp \
PrinterParams.h \
Thesaurus.cpp \
@@ -457,7 +462,7 @@
mathed/ReplaceData.h \
mathed/MathStream.h \
mathed/MathSupport.h \
- mathed/TextPainter.h
+ mathed/TextPainter.h
lyxmathed.cpp:
@echo -e '$(SOURCEFILESMATHED:%=\n#include "%")\n' > $@
@@ -471,7 +476,7 @@
else
-liblyxmathed_a_SOURCES = $(SOURCEFILESMATHED) $(HEADERFILESMATHED)
+liblyxmathed_a_SOURCES = $(SOURCEFILESMATHED) $(HEADERFILESMATHED)
endif
Index: config/spell.m4
===================================================================
--- config/spell.m4 (revision 30424)
+++ config/spell.m4 (working copy)
@@ -2,33 +2,61 @@
# Only checks for "new" aspell, > 0.50
AC_DEFUN([CHECK_WITH_ASPELL],
[
- lyx_use_aspell=true
- AC_ARG_WITH(aspell, AC_HELP_STRING([--with-aspell],[use ASpell libraries]))
- test "$with_aspell" = "no" && lyx_use_aspell=false
+ lyx_use_aspell=true
+ AC_ARG_WITH(aspell, AC_HELP_STRING([--with-aspell],[use ASpell libraries]))
+ test "$with_aspell" = "no" && lyx_use_aspell=false
- if $lyx_use_aspell ; then
+ if $lyx_use_aspell ; then
AC_CHECK_HEADERS(aspell.h aspell/aspell.h,
- [lyx_use_aspell=true; break;],
- [lyx_use_aspell=false])
+ [lyx_use_aspell=true; break;],
+ [lyx_use_aspell=false])
AC_CHECK_LIB(aspell, new_aspell_config, LIBS="-laspell $LIBS", lyx_use_aspell=false)
AC_MSG_CHECKING([whether to use aspell])
if $lyx_use_aspell ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(USE_ASPELL, 1, [Define as 1 to use the aspell library])
- lyx_flags="$lyx_flags use-aspell"
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(USE_ASPELL, 1, [Define as 1 to use the aspell library])
+ lyx_flags="$lyx_flags use-aspell"
else
- AC_MSG_RESULT(no)
+ AC_MSG_RESULT(no)
fi
- fi
- ])
+ fi
+ ])
+# Macro to add for using hunspell spellchecker libraries! -*- sh -*-
+AC_DEFUN([CHECK_WITH_HUNSPELL],
+[
+ lyx_use_hunspell=true
+ AC_ARG_WITH(hunspell, AC_HELP_STRING([--with-hunspell],[use Hunspell libraries]))
+ test "$with_hunspell" = "no" && lyx_use_hunspell=false
-### Check if we want spell libraries, prefer new aspell
+ if $lyx_use_hunspell ; then
+ AC_CHECK_HEADERS(hunspell.hxx hunspell/hunspell.hxx,
+ [lyx_use_hunspell=true; break;],
+ [lyx_use_hunspell=false])
+ AC_CHECK_LIB(hunspell, main, LIBS="-lhunspell $LIBS", lyx_use_hunspell=false)
+
+ AC_MSG_CHECKING([whether to use hunspell])
+ if $lyx_use_hunspell ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library])
+ lyx_flags="$lyx_flags use-hunspell"
+ else
+ AC_MSG_RESULT(no)
+ fi
+ fi
+ ])
+
+### Check if we want spell libraries, prefer new aspell or hunspell
AC_DEFUN([LYX_CHECK_SPELL_ENGINES],
[
- lyx_use_aspell=false
- CHECK_WITH_ASPELL
+ lyx_use_aspell=false
+ CHECK_WITH_ASPELL
- AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
- ])
+ AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
+
+ lyx_use_hunspell=false
+ CHECK_WITH_HUNSPELL
+
+ AM_CONDITIONAL(USE_HUNSPELL, $lyx_use_hunspell)
+ ])