]> git.lyx.org Git - features.git/commitdiff
code shuffle, part 2
authorAndré Pönitz <poenitz@gmx.net>
Tue, 22 Oct 2002 11:13:40 +0000 (11:13 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 22 Oct 2002 11:13:40 +0000 (11:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5466 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/formulabase.C
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_fracbase.C

index f4aa659db5f9916453f2846a5f33dcd8967615df..d4869ad8a91f1f1666bf301c22fecb1df73d25b7 100644 (file)
@@ -621,7 +621,7 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_GREEK:
                handleFont(bv, cmd.argument, "lyxgreek1");
                if (cmd.argument.size())
-                       mathcursor->interpret(cmd.argument);
+                       mathcursor->insert(asArray(cmd.argument));
                break;
 
        case LFUN_MATH_MODE:
@@ -644,13 +644,22 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
 #endif
                break;
 
-       case LFUN_INSERT_MATRIX:
-               if (!cmd.argument.empty()) {
-                       bv->lockedInsetStoreUndo(Undo::EDIT);
-                       mathcursor->interpret("matrix " + cmd.argument);
+       case LFUN_INSERT_MATRIX: {
+               bv->lockedInsetStoreUndo(Undo::EDIT);
+               unsigned int m = 1;
+               unsigned int n = 1;
+               string v_align;
+               string h_align;
+               istringstream is(argument);
+               is >> m >> n >> v_align >> h_align;
+               m = max(1u, m);
+               n = max(1u, n);
+               v_align += 'c';
+               mathcursor->niceInsert(
+                       MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
                        updateLocal(bv, true);
-               }
                break;
+       }
 
        case LFUN_SUPERSCRIPT:
        case LFUN_SUBSCRIPT:
@@ -707,15 +716,23 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                argument = "\n";
                // fall through
 
-       case -1:
+// FIXME: We probably should swap parts of "math-insert" and "self-insert"
+// handling such that "self-insert" works on "arbitrary stuff" too, and
+// math-insert only handles special math things like "matrix".
        case LFUN_INSERT_MATH:
+               bv->lockedInsetStoreUndo(Undo::EDIT);
+               mathcursor->insert(asArray(argument));
+               updateLocal(bv, true);
+               break;
+       
+       case -1:
        case LFUN_SELFINSERT:
                if (!argument.empty()) {
                        bv->lockedInsetStoreUndo(Undo::EDIT);
                        if (argument.size() == 1)
                                result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT;
                        else
-                               result = mathcursor->interpret(argument) ? DISPATCHED : FINISHED_RIGHT;
+                               mathcursor->insert(asArray(argument));
                        updateLocal(bv, true);
                }
                break;
index 0fea05418e74693858700314273c8cff65935c62..757462e861d8b7b2fed1fa34cf282c6a56e30d7b 100644 (file)
 #include "formulabase.h"
 #include "funcrequest.h"
 #include "math_autocorrect.h"
-#include "math_arrayinset.h"
 #include "math_braceinset.h"
 #include "math_commentinset.h"
 #include "math_charinset.h"
 #include "math_extern.h"
 #include "math_factory.h"
-#include "math_hullinset.h"
+#include "math_gridinset.h"
 #include "math_iterator.h"
 #include "math_macroarg.h"
 #include "math_macrotemplate.h"
@@ -431,20 +430,6 @@ void MathCursor::backspace()
                }
        }
 
-/*
-       if (prevAtom()->asScriptInset()) {
-               // simply enter nucleus
-               left();
-               return;
-       }
-
-       if (inNucleus()) {
-               // we are in nucleus
-               if (pos() == 1) {
-               }
-       }
-*/
-
        --pos();
        plainErase();
 }
@@ -472,29 +457,6 @@ void MathCursor::erase()
                return;
        }
 
-/*
-       // if we are standing in front of a script inset, grab item before us and
-       // move it into nucleus
-       // and remove first thing.
-       if (hasNextAtom() && nextAtom()->asScriptInset()) {
-               if (hasPrevAtom()) {
-                       MathAtom at = prevAtom();
-                       --pos();
-                       array().erase(pos());
-                       pushLeft(nextAtom());
-                       if (array().empty())
-                               array().push_back(at);
-                       else
-                               array()[0] = at;
-                       pos() = 1;
-               } else {
-                       pushLeft(nextAtom());
-                       array().clear();
-               }
-               return;
-       }
-*/
-
        plainErase();
 }
 
@@ -536,8 +498,19 @@ void MathCursor::macroModeClose()
        string s = p->name();
        --pos();
        array().erase(pos());
-       if (s != "\\")
-               interpret(s);
+
+       // do nothing if the macro name is empty
+       if (s == "\\")
+               return;
+
+       string name = s.substr(1);
+
+       // prevent entering of recursive macros
+       if (formula()->lyxCode() == Inset::MATHMACRO_CODE
+                       && formula()->getInsetName() == name)
+               lyxerr << "can't enter recursive macro\n";
+
+       niceInsert(createMathInset(name));
 }
 
 
@@ -1111,68 +1084,6 @@ bool MathCursor::idxRight()
 }
 
 
-bool MathCursor::interpret(string const & s)
-{
-       //lyxerr << "interpret 1: '" << s << "'\n";
-       if (s.empty())
-               return true;
-
-       //lyxerr << "char: '" << s[0] << "'  int: " << int(s[0]) << endl;
-       //owner_->getIntl()->getTransManager().TranslateAndInsert(s[0], lt);
-       //lyxerr << "trans: '" << s[0] << "'  int: " << int(s[0]) << endl;
-
-       if (s.size() >= 6 && s.substr(0, 6) == "matrix") {
-               unsigned int m = 1;
-               unsigned int n = 1;
-               string v_align;
-               string h_align;
-               istringstream is(s.substr(6).c_str());
-               is >> m >> n >> v_align >> h_align;
-               m = max(1u, m);
-               n = max(1u, n);
-               v_align += 'c';
-               niceInsert(MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
-               return true;
-       }
-
-       if (s.size() >= 7 && s.substr(0, 7) == "replace") {
-               ReplaceData rep;
-               istringstream is(s.substr(7).c_str());
-               string from, to;
-               is >> from >> to;
-               mathed_parse_cell(rep.from, from);
-               mathed_parse_cell(rep.to, to);
-               lyxerr << "replacing '" << from << "' with '" << to << "'\n";
-               par()->replace(rep);
-               return true;
-       }
-
-       string name = s.substr(1);
-
-       if (name == "over" || name == "choose" || name == "atop") {
-               MathAtom t(createMathInset(name));
-               t.nucleus()->asNestInset()->cell(0) = array();
-               array().clear();
-               pos() = 0;
-               niceInsert(t);
-               popRight();
-               left();
-               return true;
-       }
-
-       // prevent entering of recursive macros
-       if (formula()->lyxCode() == Inset::MATHMACRO_CODE
-               && formula()->getInsetName() == name)
-       {
-               lyxerr << "can't enter recursive macro\n";
-               return true;
-       }
-
-       niceInsert(createMathInset(name));
-       return true;
-}
-
-
 bool MathCursor::script(bool up)
 {
        // Hack to get \\^ and \\_ working
@@ -1548,3 +1459,4 @@ void releaseMathCursor(BufferView * bv)
        delete mathcursor;
        mathcursor = 0;
 }
+
index 0ef9dd555e9652626eb346c9a14d8a625c41a711..3e2bcf501c4a7c0934d6296e93ad554c593dd57f 100644 (file)
@@ -123,8 +123,6 @@ public:
        size_type size() const;
        ///
        bool script(bool);
-       ///
-       bool interpret(string const &);
        /// 
        bool interpret(char);
        /// interpret name a name of a macro
index a8d6e2dd701198e99c3f01e3941a0c8f560b0c1a..ef0ca38f4613510c5afc6d2d0f9d2008c4ae5172 100644 (file)
@@ -3,7 +3,6 @@
 #endif
 
 #include "math_fracbase.h"
-#include "math_mathmlstream.h"
 
 
 MathFracbaseInset::MathFracbaseInset()