Unicode symbols entered or pasted in math are wrapped in \text{} by default.

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
This commit is contained in:
Enrico Forestieri 2009-04-05 01:14:10 +00:00
parent bd8a0686fb
commit 376f3f08bd
4 changed files with 31 additions and 6 deletions

View 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,

View 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"));

View 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;

View 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
};