Introduce a helper function and use it.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29130 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-04-06 22:12:22 +00:00
parent 0de1e7730f
commit 3e341497a8
4 changed files with 16 additions and 6 deletions

View File

@ -1617,7 +1617,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
cur.niceInsert(createInsetMath("sim"));
return true;
}
if (c >= 0x80 && !Encodings::isMathAlpha(c)) {
if (!isAsciiOrMathAlpha(c)) {
MathAtom at = createInsetMath("text");
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
cur.niceInsert(at);

View File

@ -513,4 +513,10 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
}
bool isAsciiOrMathAlpha(char_type c)
{
return c < 0x80 || Encodings::isMathAlpha(c);
}
} // namespace lyx

View File

@ -33,6 +33,11 @@ MathAtom createInsetMath(char const * const);
*/
bool createInsetMath_fromDialogStr(docstring const &, MathData &);
/** Tells whether the argument is an ascii character or is marked as
* mathalpha in the unicodesymbols file.
*/
bool isAsciiOrMathAlpha(char_type);
typedef std::map<docstring, latexkeys> MathWordList;
MathWordList const & mathedWordList();

View File

@ -909,17 +909,16 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
else if (t.cat() == catOther) {
char_type c = t.character();
if (c < 0x80 || mode_ & Parse::VERBATIM
if (isAsciiOrMathAlpha(c)
|| mode_ & Parse::VERBATIM
|| !(mode_ & Parse::USETEXT)
|| mode == InsetMath::TEXT_MODE
|| Encodings::isMathAlpha(c)) {
|| mode == InsetMath::TEXT_MODE) {
cell->push_back(MathAtom(new InsetMathChar(c)));
} else {
MathAtom at = createInsetMath("text");
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
while (nextToken().cat() == catOther
&& nextToken().character() >= 0x80
&& !Encodings::isMathAlpha(nextToken().character())) {
&& !isAsciiOrMathAlpha(nextToken().character())) {
c = getToken().character();
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
}