mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
* support/lstring.{cpp,h}:
- new function hasDigit * src/Paragraph.cpp (spellcheck): - ignore words with digits, as in 1.6 (bug 6493). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33395 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
70d5b8fe06
commit
5f4c5c5da9
@ -3170,6 +3170,10 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
docstring word = asString(from, to, AS_STR_INSETS);
|
docstring word = asString(from, to, AS_STR_INSETS);
|
||||||
|
// Ignore words with digits
|
||||||
|
// FIXME: make this customizable
|
||||||
|
// (note that hunspell ignores words with digits by default)
|
||||||
|
bool const ignored = hasDigit(word);
|
||||||
Language * lang = const_cast<Language *>(getFontSettings(
|
Language * lang = const_cast<Language *>(getFontSettings(
|
||||||
d->inset_owner_->buffer().params(), from).language());
|
d->inset_owner_->buffer().params(), from).language());
|
||||||
if (lang == d->inset_owner_->buffer().params().language
|
if (lang == d->inset_owner_->buffer().params().language
|
||||||
@ -3181,7 +3185,8 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
|
|||||||
lang->setVariety(lang_variety);
|
lang->setVariety(lang_variety);
|
||||||
}
|
}
|
||||||
wl = WordLangTuple(word, lang);
|
wl = WordLangTuple(word, lang);
|
||||||
SpellChecker::Result res = speller->check(wl);
|
SpellChecker::Result res = ignored ?
|
||||||
|
SpellChecker::OK : speller->check(wl);
|
||||||
#if 0
|
#if 0
|
||||||
// FIXME: the code below makes aspell abort if a word in an unknown
|
// FIXME: the code below makes aspell abort if a word in an unknown
|
||||||
// language is checked.
|
// language is checked.
|
||||||
|
@ -315,6 +315,26 @@ bool isStrDbl(string const & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool hasDigit(docstring const & str)
|
||||||
|
{
|
||||||
|
if (str.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Remove leading and trailing white space chars.
|
||||||
|
docstring const tmpstr = trim(str);
|
||||||
|
if (tmpstr.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
docstring::const_iterator cit = tmpstr.begin();
|
||||||
|
docstring::const_iterator end = tmpstr.end();
|
||||||
|
for (; cit != end; ++cit)
|
||||||
|
if (isdigit((*cit)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool isHexChar(char_type c)
|
static bool isHexChar(char_type c)
|
||||||
{
|
{
|
||||||
return c == '0' ||
|
return c == '0' ||
|
||||||
|
@ -44,6 +44,9 @@ bool isStrUnsignedInt(std::string const & str);
|
|||||||
///
|
///
|
||||||
bool isStrDbl(std::string const & str);
|
bool isStrDbl(std::string const & str);
|
||||||
|
|
||||||
|
/// does the string contain a digit?
|
||||||
|
bool hasDigit(docstring const & str);
|
||||||
|
|
||||||
bool isHex(docstring const & str);
|
bool isHex(docstring const & str);
|
||||||
|
|
||||||
int hexToInt(docstring const & str);
|
int hexToInt(docstring const & str);
|
||||||
|
Loading…
Reference in New Issue
Block a user