#include <sys/select.h>
#endif
+#include <algorithm>
+
#include "LString.h"
#include "sp_form.h"
#include "spellchecker.h"
#include "debug.h"
#include "support/lstrings.h"
-
+using std::reverse;
using std::endl;
// Spellchecker status
argv[argc++] = 0;
- execvp("ispell", const_cast<char * const *>(argv));
+ execvp(argv[0], const_cast<char * const *>(argv));
// free the memory used by string::copy in the
// setup of argv
FL_OBJECT * obj;
string tmp = (lyxrc.isp_use_alt_lang) ? lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
+ bool rtl = tmp == "hebrew" || tmp == "arabic";
int oldval = 0; /* used for updating slider only when needed */
float newval = 0.0;
"Check /usr/lib/ispell or set another\n"
"dictionary in the Spellchecker Options menu."), "", "");
fclose(out);
- return true;
+ return false;
}
// Put ispell in terse mode to improve speed
if(newvalue!= oldval) {
oldval = newvalue;
fl_set_slider_value(fd_form_spell_check->slider, oldval);
+ }
+
+ if (word_count%1000 == 0) {
+ obj = fl_check_forms();
+ if (obj == fd_form_spell_check->stop) {
+ delete[] word;
+ ispell_terminate();
+ return true;
+ }
+ if (obj == fd_form_spell_check->done) {
+ delete[] word;
+ ispell_terminate();
+ return false;
+ }
}
result = ispell_check_word(word);
if (isp_pid == -1) {
+ delete result;
delete[] word;
break;
}
- obj = fl_check_forms();
- if (obj == fd_form_spell_check->stop) {
- delete result;
- delete[] word;
- ispell_terminate();
- return true;
- }
- if (obj == fd_form_spell_check->done) {
- delete result;
- delete[] word;
- ispell_terminate();
- return false;
- }
-
switch (result->flag) {
case ISP_UNKNOWN:
case ISP_MISSED:
{
bv->selectLastWord();
- fl_set_object_label(fd_form_spell_check->text, word);
+ if (rtl) {
+ string tmp = word;
+ reverse(tmp.begin(),tmp.end());
+ fl_set_object_label(fd_form_spell_check->text, tmp.c_str());
+ } else
+ fl_set_object_label(fd_form_spell_check->text, word);
fl_set_input(fd_form_spell_check->input, word);
fl_clear_browser(fd_form_spell_check->browser);
for (i = 0; i < result->count; ++i) {
- fl_add_browser_line(fd_form_spell_check->browser, result->misses[i]);
+ if (rtl) {
+ string tmp = result->misses[i];
+ reverse(tmp.begin(),tmp.end());
+ fl_add_browser_line(fd_form_spell_check->browser, tmp.c_str());
+ } else
+ fl_add_browser_line(fd_form_spell_check->browser, result->misses[i]);
}
int clickline = -1;
break;
}
clickline = fl_get_browser(fd_form_spell_check->browser);
- fl_set_input(fd_form_spell_check->input,
- fl_get_browser_line(fd_form_spell_check->browser,
- fl_get_browser(fd_form_spell_check->browser)));
-
+ /// Why not use
+ /// fl_set_input(fd_form_spell_check->input, result->misses[clickline-1]); ?
+ if (rtl) {
+ string tmp = fl_get_browser_line(fd_form_spell_check->browser,
+ clickline);
+ reverse(tmp.begin(),tmp.end());
+ fl_set_input(fd_form_spell_check->input, tmp.c_str());
+ } else
+ fl_set_input(fd_form_spell_check->input,
+ fl_get_browser_line(fd_form_spell_check->browser,
+ clickline));
}
if (obj == fd_form_spell_check->stop) {
delete result;