]> git.lyx.org Git - features.git/commitdiff
Unicode symbols entered or pasted in math are wrapped in \text{} by default.
authorEnrico Forestieri <forenr@lyx.org>
Sun, 5 Apr 2009 01:14:10 +0000 (01:14 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 5 Apr 2009 01:14:10 +0000 (01:14 +0000)
Unwrapped symbols can be obtained either by dissolving the text inset or by
verbatim paste (Ctrl+Shift+V). In such a case, the symbols are wrapped in
\lyxmathsym when exporting to latex, as usual.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29096 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathNest.cpp
src/mathed/MathParser.cpp
src/mathed/MathParser_flags.h

index 61e13dfe8c0904839ad562563138a05d8cc9b6bd..439abfa19c1d41d17fa926ef447c3ee49bbcaabe 100644 (file)
@@ -1073,7 +1073,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        //lyxerr << "*** InsetMathGrid: request: " << cmd << endl;
 
-       Parse::flags parseflg = Parse::QUIET;
+       Parse::flags parseflg = Parse::QUIET | Parse::USETEXT;
 
        switch (cmd.action) {
 
@@ -1274,7 +1274,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                }
                InsetMathGrid grid(1, 1);
                if (!topaste.empty())
-                       if (topaste.size() == 1
+                       if ((topaste.size() == 1 && topaste.at(0) < 0x80)
                            || !mathed_parse_normal(grid, topaste, parseflg)) {
                                resetGrid(grid);
                                mathed_parse_normal(grid, topaste,
index 4f3656a7364e4b6dee7c582fe3cf3f6ec8187d01..fadc82cccf1d9d5609e652a36eb859bb6073f42d 100644 (file)
@@ -16,6 +16,7 @@
 #include "InsetMathBig.h"
 #include "InsetMathBox.h"
 #include "InsetMathBrace.h"
+#include "InsetMathChar.h"
 #include "InsetMathColor.h"
 #include "InsetMathComment.h"
 #include "InsetMathDelim.h"
@@ -42,6 +43,7 @@
 #include "Cursor.h"
 #include "CutAndPaste.h"
 #include "DispatchResult.h"
+#include "Encoding.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "LyXFunc.h"
@@ -514,7 +516,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        //lyxerr << "InsetMathNest: request: " << cmd << endl;
 
-       Parse::flags parseflg = Parse::QUIET;
+       Parse::flags parseflg = Parse::QUIET | Parse::USETEXT;
 
        switch (cmd.action) {
 
@@ -1615,6 +1617,13 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        cur.niceInsert(createInsetMath("sim"));
                        return true;
                }
+               if (c >= 0x80 && !Encodings::isMathAlpha(c)) {
+                       MathAtom at = createInsetMath("text");
+                       at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
+                       cur.niceInsert(at);
+                       cur.posForward();
+                       return true;
+               }
        } else {
                if (c == '^') {
                        cur.niceInsert(createInsetMath("textasciicircum"));
index 851828c9481523126bb0af4c9bb43224040b5c6c..362b67193e3025d36588ee59b0957e5502a32718 100644 (file)
@@ -907,8 +907,22 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        return success_;
                }
 
-               else if (t.cat() == catOther)
-                       cell->push_back(MathAtom(new InsetMathChar(t.character())));
+               else if (t.cat() == catOther) {
+                       char_type c = t.character();
+                       if (c < 0x80 || mode_ & Parse::VERBATIM
+                           || !(mode_ & Parse::USETEXT)) {
+                               cell->push_back(MathAtom(new InsetMathChar(c)));
+                       } else {
+                               MathAtom at = createInsetMath("text");
+                               at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(t.character())));
+                               while (nextToken().cat() == catOther
+                                      && nextToken().character() >= 0x80) {
+                                       c = getToken().character();
+                                       at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
+                               }
+                               cell->push_back(at);
+                       }
+               }
 
                else if (t.cat() == catComment) {
                        docstring s;
index 41d5cd79820b4d0806572a0780e794df351218eb..06f864bd96ce63b7fca4eb670836ffc27a62c06f 100644 (file)
@@ -24,7 +24,9 @@ enum flags {
        /// Parse verbatim.
        VERBATIM = 0x02,
        /// Quiet operation (no warnigs or errors).
-       QUIET = 0x04
+       QUIET = 0x04,
+       /// Wrap unicode symbols in \text{}.
+       USETEXT = 0x08
 };