mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Put the foundations to support continuous spell checking.
* Font: new misspelled_ member. * GuiPrefs/PrefSpellchecker: new check box to enable/disable continuous spellcheck. * LyXRC: new spellcheck_continuously parameter. * RowPainter: new paintMisspelledMark() method. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28973 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1141ccb997
commit
29c40527e5
@ -108,7 +108,7 @@ char const * LaTeXSizeNames[14] =
|
||||
|
||||
|
||||
Font::Font(FontInfo bits, Language const * l)
|
||||
: bits_(bits), lang_(l), open_encoding_(false)
|
||||
: bits_(bits), lang_(l), misspelled_(false), open_encoding_(false)
|
||||
{
|
||||
if (!lang_)
|
||||
lang_ = default_language;
|
||||
|
@ -47,6 +47,10 @@ public:
|
||||
///
|
||||
Language const * language() const { return lang_; }
|
||||
///
|
||||
void setMisspelled(bool misspelled) { misspelled_ = misspelled; }
|
||||
///
|
||||
bool isMisspelled() const { return misspelled_; }
|
||||
///
|
||||
bool isRightToLeft() const;
|
||||
///
|
||||
bool isVisibleRightToLeft() const;
|
||||
@ -121,6 +125,8 @@ private:
|
||||
FontInfo bits_;
|
||||
///
|
||||
Language const * lang_;
|
||||
///
|
||||
bool misspelled_;
|
||||
|
||||
/// Did latexWriteStartChanges open an encoding environment?
|
||||
mutable bool open_encoding_;
|
||||
@ -131,7 +137,8 @@ private:
|
||||
inline
|
||||
bool operator==(Font const & font1, Font const & font2)
|
||||
{
|
||||
return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_;
|
||||
return font1.bits_ == font2.bits_ && font1.lang_ == font2.lang_
|
||||
&& font1.misspelled_ == font2.misspelled_;
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -2026,6 +2026,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_SHOW_BANNER:
|
||||
case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
|
||||
case LyXRC::RC_SPELL_COMMAND:
|
||||
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
|
||||
case LyXRC::RC_TEMPDIRPATH:
|
||||
case LyXRC::RC_TEMPLATEPATH:
|
||||
case LyXRC::RC_TEX_ALLOWS_SPACES:
|
||||
|
@ -163,6 +163,7 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\show_banner", LyXRC::RC_SHOW_BANNER },
|
||||
{ "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
|
||||
{ "\\spell_command", LyXRC::RC_SPELL_COMMAND },
|
||||
{ "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
|
||||
{ "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
|
||||
{ "\\template_path", LyXRC::RC_TEMPLATEPATH },
|
||||
{ "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
|
||||
@ -268,6 +269,7 @@ void LyXRC::setDefaults()
|
||||
spellchecker_use_alt_lang = false;
|
||||
spellchecker_use_pers_dict = false;
|
||||
spellchecker_use_esc_chars = false;
|
||||
spellcheck_continuously = false;
|
||||
use_kbmap = false;
|
||||
rtl_support = true;
|
||||
visual_cursor = false;
|
||||
@ -883,6 +885,9 @@ int LyXRC::read(Lexer & lexrc)
|
||||
case RC_ESC_CHARS:
|
||||
lexrc >> spellchecker_esc_chars;
|
||||
break;
|
||||
case RC_SPELLCHECK_CONTINUOUSLY:
|
||||
lexrc >> spellcheck_continuously;
|
||||
break;
|
||||
case RC_MAKE_BACKUP:
|
||||
lexrc >> make_backup;
|
||||
break;
|
||||
@ -2121,6 +2126,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
os << "\n#\n"
|
||||
<< "# SPELLCHECKER SECTION ##############################\n"
|
||||
<< "#\n\n";
|
||||
|
||||
case RC_SPELL_COMMAND:
|
||||
case RC_USE_SPELL_LIB:
|
||||
// Obsoleted in 2.0
|
||||
@ -2210,6 +2216,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
<< "# LANGUAGE SUPPORT SECTION ##########################\n"
|
||||
<< "#\n\n";
|
||||
|
||||
case RC_SPELLCHECK_CONTINUOUSLY:
|
||||
if (ignore_system_lyxrc ||
|
||||
spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
|
||||
os << "\\spellcheck_continuously " << convert<string>(spellcheck_continuously)
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
|
||||
case RC_RTL_SUPPORT:
|
||||
if (ignore_system_lyxrc ||
|
||||
rtl_support != system_lyxrc.rtl_support) {
|
||||
|
@ -147,6 +147,7 @@ public:
|
||||
RC_OPEN_BUFFERS_IN_TABS,
|
||||
RC_SORT_LAYOUTS,
|
||||
RC_SPELL_COMMAND,
|
||||
RC_SPELLCHECK_CONTINUOUSLY,
|
||||
RC_TEMPDIRPATH,
|
||||
RC_TEMPLATEPATH,
|
||||
RC_TEX_ALLOWS_SPACES,
|
||||
@ -329,6 +330,8 @@ public:
|
||||
std::string spellchecker_pers_dict;
|
||||
/// Escape characters
|
||||
std::string spellchecker_esc_chars;
|
||||
/// spellcheck continuously?
|
||||
bool spellcheck_continuously;
|
||||
///
|
||||
bool use_kbmap;
|
||||
///
|
||||
|
@ -1102,6 +1102,8 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(inputEncodingCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(spellcheckContinuouslyCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
|
||||
@ -1118,6 +1120,7 @@ void PrefSpellchecker::apply(LyXRC & rc) const
|
||||
rc.spellchecker_use_pers_dict = !rc.spellchecker_pers_dict.empty();
|
||||
rc.spellchecker_accept_compound = compoundWordCB->isChecked();
|
||||
rc.spellchecker_use_input_encoding = inputEncodingCB->isChecked();
|
||||
rc.spellcheck_continuously = spellcheckContinuouslyCB->isChecked();
|
||||
}
|
||||
|
||||
|
||||
@ -1131,6 +1134,7 @@ void PrefSpellchecker::update(LyXRC const & rc)
|
||||
persDictionaryED->setText(toqstr(external_path(rc.spellchecker_pers_dict)));
|
||||
compoundWordCB->setChecked(rc.spellchecker_accept_compound);
|
||||
inputEncodingCB->setChecked(rc.spellchecker_use_input_encoding);
|
||||
spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,49 +1,81 @@
|
||||
<ui version="4.0">
|
||||
<ui version="4.0" >
|
||||
<class>PrefSpellcheckerUi</class>
|
||||
<widget class="QWidget" name="PrefSpellcheckerUi">
|
||||
<property name="geometry">
|
||||
<widget class="QWidget" name="PrefSpellcheckerUi" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>340</width>
|
||||
<height>198</height>
|
||||
<width>405</width>
|
||||
<height>215</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<property name="windowTitle" >
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="altLanguageLA" >
|
||||
<property name="text" >
|
||||
<string>Al&ternative language:</string>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
<property name="buddy" >
|
||||
<cstring>altLanguageED</cstring>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="altLanguageED" >
|
||||
<property name="toolTip" >
|
||||
<string>Override the language used for the spellchecker</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="escapeCharactersLA" >
|
||||
<property name="text" >
|
||||
<string>&Escape characters:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>escapeCharactersED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="escapeCharactersED" />
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="persDictionaryLA" >
|
||||
<property name="text" >
|
||||
<string>Personal &dictionary:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>persDictionaryED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="persDictionaryED" >
|
||||
<property name="toolTip" >
|
||||
<string>Specify a personal dictionary file other than the default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" >
|
||||
<widget class="QPushButton" name="persDictionaryPB" >
|
||||
<property name="text" >
|
||||
<string>Br&owse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
@ -51,78 +83,57 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="persDictionaryPB">
|
||||
<property name="text">
|
||||
<string>Br&owse...</string>
|
||||
<item row="3" column="0" colspan="4" >
|
||||
<widget class="QCheckBox" name="compoundWordCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Accept words such as "diskdrive"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="altLanguageLA">
|
||||
<property name="text">
|
||||
<string>Al&ternative language:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>altLanguageED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="escapeCharactersED"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="persDictionaryED">
|
||||
<property name="toolTip">
|
||||
<string>Specify a personal dictionary file other than the default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="persDictionaryLA">
|
||||
<property name="text">
|
||||
<string>Personal &dictionary:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>persDictionaryED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="escapeCharactersLA">
|
||||
<property name="text">
|
||||
<string>&Escape characters:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>escapeCharactersED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="altLanguageED">
|
||||
<property name="toolTip">
|
||||
<string>Override the language used for the spellchecker</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="inputEncodingCB">
|
||||
<property name="text">
|
||||
<string>Use input encod&ing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="compoundWordCB">
|
||||
<property name="toolTip">
|
||||
<string>Accept words such as "diskdrive"</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<property name="text" >
|
||||
<string>Accept compound &words</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="4" >
|
||||
<widget class="QCheckBox" name="inputEncodingCB" >
|
||||
<property name="text" >
|
||||
<string>Use input encod&ing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3" >
|
||||
<widget class="QCheckBox" name="spellcheckContinuouslyCB" >
|
||||
<property name="text" >
|
||||
<string>Spellcheck continuously (mark misspelled words with wavy underline)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>altLanguageLA</zorder>
|
||||
<zorder>persDictionaryLA</zorder>
|
||||
<zorder>escapeCharactersLA</zorder>
|
||||
<zorder>inputEncodingCB</zorder>
|
||||
<zorder>compoundWordCB</zorder>
|
||||
<zorder>spellcheckContinuouslyCB</zorder>
|
||||
<zorder>persDictionaryPB</zorder>
|
||||
<zorder>escapeCharactersED</zorder>
|
||||
<zorder>persDictionaryED</zorder>
|
||||
<zorder>altLanguageED</zorder>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>altLanguageED</tabstop>
|
||||
@ -133,7 +144,7 @@
|
||||
<tabstop>inputEncodingCB</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -328,6 +328,13 @@ void RowPainter::paintForeignMark(double orig_x, Language const * lang,
|
||||
}
|
||||
|
||||
|
||||
void RowPainter::paintMisspelledMark(double orig_x, int desc)
|
||||
{
|
||||
int const y = yo_ + desc;
|
||||
pi_.pain.wavyHorizontalLine(int(orig_x), y, int(x_) - int(orig_x), Color_red);
|
||||
}
|
||||
|
||||
|
||||
void RowPainter::paintFromPos(pos_type & vpos)
|
||||
{
|
||||
pos_type const pos = bidi_.vis2log(vpos);
|
||||
@ -355,6 +362,9 @@ void RowPainter::paintFromPos(pos_type & vpos)
|
||||
}
|
||||
|
||||
paintForeignMark(orig_x, orig_font.language());
|
||||
|
||||
if (orig_font.isMisspelled())
|
||||
paintMisspelledMark(orig_x, 3);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
|
||||
private:
|
||||
void paintForeignMark(double orig_x, Language const * lang, int desc = 0);
|
||||
void paintMisspelledMark(double orig_x, int desc);
|
||||
void paintHebrewComposeChar(pos_type & vpos, FontInfo const & font);
|
||||
void paintArabicComposeChar(pos_type & vpos, FontInfo const & font);
|
||||
void paintChars(pos_type & vpos, FontInfo const & font,
|
||||
|
Loading…
Reference in New Issue
Block a user