From 6d5b9d7791838ebe41848def2b03d4158e1ad1c0 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Sun, 1 May 2005 16:15:32 +0000 Subject: [PATCH] Suppress a number of illegal things in text-within-math git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9892 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 8 ++++++- src/mathed/math_nestinset.C | 42 ++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index bc05fca1f2..c7a9f3f8ca 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,4 +1,10 @@ -2005-04-25 Martin Vermeer a +2005-05-01 Martin Vermeer + + * math_nestinset.C (getStatus): suppress math/text fonts, + subscripts etc. to prevent lyx access to latex-illegal stuff + in text-inside-math (mbox) + +2005-04-25 Martin Vermeer * math_gridinset.C (doDispatch): * math_hullInset.C (doDispatch): diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 1cf026cf3e..a978f21079 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -865,6 +865,7 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd, // the font related toggles //string tc = "mathnormal"; bool ret = true; + string const arg = cmd.argument; switch (cmd.action) { case LFUN_TABULAR_FEATURE: flag.enabled(false); @@ -924,7 +925,21 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd, case LFUN_MATH_EXTERN: flag.enabled(true); break; - + case LFUN_INSERT_MATH: { + bool const textarg = + arg == "\\textbf" || arg == "\\textsf" || + arg == "\\textrm" || arg == "\\textmd" || + arg == "\\textit" || arg == "\\textsc" || + arg == "\\textsl" || arg == "\\textup" || + arg == "\\texttt" || arg == "\\textbb" || + arg == "\\textnormal"; + flag.enabled((currentMode() == MATH_MODE && !textarg) + || (currentMode() == TEXT_MODE && textarg)); + break; + } + case LFUN_INSERT_MATRIX: + flag.enabled(currentMode() == MATH_MODE); + break; default: ret = false; break; @@ -1139,14 +1154,21 @@ bool MathNestInset::interpret(LCursor & cur, char c) return cur.pos() != cur.lastpos(); } - if (c == '_') { - script(cur, false); - return true; - } + // These shouldn't work in text mode: + if (currentMode() != MathInset::TEXT_MODE) { + if (c == '_') { + script(cur, false); + return true; + } - if (c == '^') { - script(cur, true); - return true; + if (c == '^') { + script(cur, true); + return true; + } + if (c == '~') { + cur.niceInsert(createMathInset("sim")); + return true; + } } if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' || c == '%') { @@ -1154,10 +1176,6 @@ bool MathNestInset::interpret(LCursor & cur, char c) return true; } - if (c == '~') { - cur.niceInsert(createMathInset("sim")); - return true; - } // try auto-correction //if (autocorrect() && hasPrevAtom() && math_autocorrect(prevAtom(), c))