Introduce a helper function and use it.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29145 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-04-07 17:41:25 +00:00
parent a67a5bf598
commit b59d7f44d6
4 changed files with 16 additions and 6 deletions

View File

@ -1598,7 +1598,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type 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

@ -505,4 +505,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)));
}