From: Enrico Forestieri Date: Mon, 6 Apr 2009 22:12:22 +0000 (+0000) Subject: Introduce a helper function and use it. X-Git-Tag: 2.0.0~6917 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=3e341497a8c2717ccd6b6be6ceaad0e050e09993;p=features.git Introduce a helper function and use it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29130 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index fadc82cccf..57933a1e18 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -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); diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 52ba762f67..c41f68d03c 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -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 diff --git a/src/mathed/MathFactory.h b/src/mathed/MathFactory.h index 7737429a61..82515baeb8 100644 --- a/src/mathed/MathFactory.h +++ b/src/mathed/MathFactory.h @@ -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 MathWordList; MathWordList const & mathedWordList(); diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 456a7fd3fc..7c22bcba1e 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -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))); }