]> git.lyx.org Git - lyx.git/blobdiff - src/spellchecker.C
Dekels tabular/textinset patches
[lyx.git] / src / spellchecker.C
index 81153c61e0a01bbc0b1fef0ff59f4055e07f8c2a..77f4eaaa2fe966852b9102e14be5ddde0f34ec05 100644 (file)
 #ifdef HAVE_SYS_SELECT_H
 # ifdef HAVE_STRINGS_H
    // <strings.h> is needed at least on AIX because FD_ZERO uses bzero().
-# include <strings.h> 
+   // BUT we cannot include both string.h and strings.h on Irix 6.5 :(
+#  ifdef _AIX
+#   include <strings.h>
+#  endif
 # endif
 #include <sys/select.h>
 #endif
 #include "encoding.h"
 #include "support/lstrings.h"
 
-//#define USE_PSPELL 1
-
 #ifdef USE_PSPELL
-
-#include <pspell/pspell.h>
-
+# include <pspell/pspell.h>
 #endif
 
 using std::reverse;
@@ -103,13 +102,12 @@ PspellManager * sc;
 
 #endif
 
-static FD_form_spell_options *fd_form_spell_options = 0;
+// Non-static so that it can be redrawn if the xforms colors are re-mapped
+FD_form_spell_options *fd_form_spell_options = 0;
 FD_form_spell_check *fd_form_spell_check = 0;
 
-//void sigchldhandler(int sig);
 void sigchldhandler(pid_t pid, int *status);
 
-//extern void sigchldchecker(int sig);
 extern void sigchldchecker(pid_t pid, int *status);
 
 #ifndef USE_PSPELL
@@ -277,7 +275,7 @@ void SpellCheckerOptions()
                fl_raise_form(fd_form_spell_options->form_spell_options);
        } else {
                fl_show_form(fd_form_spell_options->form_spell_options,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Spellchecker Options"));
        }
 }
@@ -298,7 +296,7 @@ void init_spell_checker(BufferParams const & params, string const & lang)
 
        isp_pid = -1;
 
-       if(pipe(pipein) == -1 || pipe(pipeout) == -1) {
+       if (pipe(pipein) == -1 || pipe(pipeout) == -1) {
                lyxerr << "LyX: Can't create pipe for spellchecker!" << endl;
                goto END;
        }
@@ -321,13 +319,13 @@ void init_spell_checker(BufferParams const & params, string const & lang)
 
        isp_pid = fork();
 
-       if(isp_pid == -1) {
+       if (isp_pid == -1) {
                lyxerr << "LyX: Can't create child process for spellchecker!"
                       << endl;
                goto END;
        }
        
-       if(isp_pid == 0) {        
+       if (isp_pid == 0) {        
                /* child process */
                dup2(pipein[0], STDIN_FILENO);
                dup2(pipeout[1], STDOUT_FILENO);
@@ -392,7 +390,7 @@ void init_spell_checker(BufferParams const & params, string const & lang)
                if (lyxrc.isp_use_input_encoding &&
                    params.inputenc != "default") {
                        string enc = (params.inputenc == "auto")
-                               ? params.language_info->encoding()->LatexName()
+                               ? params.language->encoding()->LatexName()
                                : params.inputenc;
                        string::size_type n = enc.length();
                        tmp = new char[3];
@@ -581,7 +579,7 @@ void sc_accept_word(string const & word)
 
 static inline
 void sc_store_replacement(string const & mis, string const & cor) {
-        if(actual_spell_checker == ASC_ASPELL) {
+        if (actual_spell_checker == ASC_ASPELL) {
                 ::fputs("$$ra ", out);
                 ::fputs(mis.c_str(), out);
                 ::fputc(',', out);
@@ -624,7 +622,7 @@ void sc_clean_up_after_error()
 
 
 
-// Send word to ispell and get reply
+// Send word to pspell and get reply
 static
 isp_result * sc_check_word(string const & word)
 {
@@ -706,7 +704,7 @@ void ShowSpellChecker(BufferView * bv)
                fl_raise_form(fd_form_spell_check->form_spell_check);
        } else {
                fl_show_form(fd_form_spell_check->form_spell_check,
-                            FL_PLACE_MOUSE, FL_FULLBORDER,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
                             _("Spellchecker"));
        }
        fl_deactivate_object(fd_form_spell_check->slider); 
@@ -801,22 +799,26 @@ bool RunSpellChecker(BufferView * bv)
        int newvalue;
        FL_OBJECT * obj;
 
+#ifndef NEW_INSETS
+       // Open all floats
+        bv->allFloats(1, 0);
+        bv->allFloats(1, 1);
+#endif
+
 #ifdef USE_PSPELL
        string tmp = (lyxrc.isp_use_alt_lang) ?
-           lyxrc.isp_alt_lang : bv->buffer()->params.language_info->code();
+           lyxrc.isp_alt_lang : bv->buffer()->params.language->code();
 #else
        string tmp = (lyxrc.isp_use_alt_lang) ?
-           lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
+           lyxrc.isp_alt_lang : bv->buffer()->params.language->lang();
 #endif
-#warning This is not good we should find a way to identify a rtl-language in a more general way. Please have a look Dekel! (Jug)
-// For now I'll change this to a bit more general solution but
-// Please comment on this if you don't like it. We probaly need
-// anoter flag something like lyxrc.isp_use_alt_lang_rtl (true/false)!
-       bool rtl;
-       if (lyxrc.isp_use_alt_lang)
-           rtl = (tmp == "hebrew" || tmp == "arabic");
-       else
-           rtl = bv->buffer()->params.language_info->RightToLeft();
+       bool rtl = false;
+       if (lyxrc.isp_use_alt_lang) {
+               Language const * lang = languages.getLanguage(tmp);
+               if (lang)
+                       rtl = lang->RightToLeft();
+       } else
+           rtl = bv->buffer()->params.language->RightToLeft();
 
        int oldval = 0;  /* used for updating slider only when needed */
        float newval = 0.0;
@@ -839,7 +841,7 @@ bool RunSpellChecker(BufferView * bv)
                
                // Update slider if and only if value has changed
                newvalue = int(100.0*newval);
-               if(newvalue!= oldval) {
+               if (newvalue!= oldval) {
                        oldval = newvalue;
                        fl_set_slider_value(fd_form_spell_check->slider, oldval);
                }
@@ -945,7 +947,7 @@ bool RunSpellChecker(BufferView * bv)
                }
        }
    
-       if(sc_still_alive()) {
+       if (sc_still_alive()) {
                close_spell_checker();
                string word_msg(tostr(word_count));
                if (word_count != 1) {
@@ -964,11 +966,10 @@ bool RunSpellChecker(BufferView * bv)
        }
 }
 
-
-#ifndef USE_PSPELL
-
+#warning should go somewhere more sensible
 void sigchldhandler(pid_t pid, int * status)
-{ 
+{
+#ifndef USE_PSPELL
        if (isp_pid > 0)
                if (pid == isp_pid) {
                        isp_pid= -1;
@@ -976,14 +977,6 @@ void sigchldhandler(pid_t pid, int * status)
                                                               to nonblocking so we can 
                                                               continue */
                }
+#endif
        sigchldchecker(pid, status);
 }
-
-#else
-
-void sigchldhandler(pid_t, int *)
-{ 
-       // do nothing
-}
-
-#endif