]> git.lyx.org Git - lyx.git/commitdiff
Introduce a helper function and use it.
authorEnrico Forestieri <forenr@lyx.org>
Mon, 6 Apr 2009 22:12:22 +0000 (22:12 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 6 Apr 2009 22:12:22 +0000 (22:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29130 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathNest.cpp
src/mathed/MathFactory.cpp
src/mathed/MathFactory.h
src/mathed/MathParser.cpp

index fadc82cccf1d9d5609e652a36eb859bb6073f42d..57933a1e182ffefa781fcc671f79865e3a838a94 100644 (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);
index 52ba762f67454408261c3c1d54e30b9915f1a604..c41f68d03cba0fd9628878010bf4493ee3556fdc 100644 (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
index 7737429a61174e9332dc3a3051909e3ef51b578d..82515baeb82c0447f8fe2a76aed6332a4f8c300d 100644 (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();
 
index 456a7fd3fc21027e8cca7191460c2bec098df73a..7c22bcba1eba3efbd03d494193767feeb24865e7 100644 (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)));
                                }