]> git.lyx.org Git - features.git/commitdiff
support reading TeX's $$...$$ syntax
authorAndré Pönitz <poenitz@gmx.net>
Mon, 15 Oct 2001 14:19:16 +0000 (14:19 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 15 Oct 2001 14:19:16 +0000 (14:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2887 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_cursor.C
src/mathed/math_gridinset.C
src/mathed/math_macro.C
src/mathed/math_parser.C

index 99c7ec2d0a664283c88f94bbbd9ef420e7f63682..5c4840ba13a9247178693e3b0226886994de14ce 100644 (file)
@@ -308,7 +308,7 @@ bool MathCursor::left(bool sel)
                pushRight(prevAtom());
                return true;
        } 
-       
+
        return posLeft() || idxLeft() || popLeft() || selection_;
 }
 
@@ -1068,13 +1068,17 @@ void MathCursor::breakLine()
                for (col_type c = col() + 1; c < p->ncols(); ++c) {
                        const MathMatrixInset::idx_type i1 = p->index(r, c);
                        const MathMatrixInset::idx_type i2 = p->index(r + 1, c);        
-                       lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
+                       //lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
                        p->cell(i1).swap(p->cell(i2));
                }
 
                // split cell
                splitCell();
                p->cell(idx()).swap(p->cell(idx() + p->ncols() - 1));
+
+               // correct cursor position
+               --idx();
+               pos() = size();
        }
 }
 
index 074b76fbfe3f400d9476f0d1f2075cb337d5b01f..9957c17b82982dc2b9f06d1ac23a98f4107a6790 100644 (file)
@@ -464,20 +464,26 @@ void MathGridInset::idxDelete(idx_type & idx, bool & popit, bool & deleteit)
        popit    = false;
        deleteit = false;
 
-       // delete entire row if in first cell of empty row
-       if (col(idx) == 0 && nrows() > 1) {
+       // delete entire sequence of ncols() empty cells if possible
+       if (idx <= index(nrows() - 1, 0))       {
                bool deleterow = true;
                for (idx_type i = idx; i < idx + ncols(); ++i)
                        if (cell(i).size()) {
                                deleterow = false;
                                break;
                        }
-               if (deleterow) 
+
+               if (deleterow) {
+                       // move cells if necessary
+                       for (idx_type i = index(row(idx), 0); i < idx; ++i)
+                               cell(i).swap(cell(i + ncols()));
+                       
                        delRow(row(idx));
 
-               if (idx >= nargs())
-                       idx = nargs() - 1;
-               return;
+                       if (idx >= nargs())
+                               idx = nargs() - 1;
+                       return;
+               }
        }
 
        // undo effect of Ctrl-Tab (i.e. pull next cell)
index 5db4fe185a279a6cac82905a07484012386b4a02..afd872b9a789df704bad187e03996ef5b2f9bf63 100644 (file)
@@ -30,7 +30,6 @@
 #include "Painter.h"
 #include "LaTeXFeatures.h"
 
-using std::endl;
 
 MathMacro::MathMacro(string const & name)
        : MathNestInset(MathMacroTable::provide(name)->asMacroTemplate()->numargs()),
@@ -160,7 +159,6 @@ void MathMacro::dump() const
        lyxerr << "\n macro: '" << this << "'\n";
        lyxerr << " name: '" << name() << "'\n";
        lyxerr << " template: '"; tmplate_->write(lyxerr, false); lyxerr << "'\n";
-       lyxerr << endl;
 }
 
 
index 074ee0509b4b65be6ab2446fb87313b843a108f0..ba96a36feb9884b3682612b3e65ce08fa2535bf2 100644 (file)
@@ -535,12 +535,30 @@ bool Parser::parse_normal(MathAtom & matrix)
 
        Token const & t = getToken();
 
-       if (t.cat() == catMath || t.cs() == "(") {
+       if (t.cs() == "(") {
                matrix = MathAtom(new MathMatrixInset(LM_OT_SIMPLE));
                parse_into(matrix->cell(0), 0);
                return true;
        }
 
+       if (t.cat() == catMath) {
+               Token const & n = getToken();
+               if (n.cat() == catMath) {
+                       // TeX's $$...$$ syntax for displayed math
+                       matrix = MathAtom(new MathMatrixInset(LM_OT_EQUATION));
+                       MathMatrixInset * p = matrix->asMatrixInset();
+                       parse_into(p->cell(0), 0);
+                       p->numbered(0, curr_num_);
+                       p->label(0, curr_label_);
+               } else {
+                       // simple $...$  stuff
+                       putback();
+                       matrix = MathAtom(new MathMatrixInset(LM_OT_SIMPLE));
+                       parse_into(matrix->cell(0), 0);
+               }
+               return true;
+       }
+
        if (!t.cs().size()) {
                lyxerr << "start of math expected, got '" << t << "'\n";
                return false;
@@ -556,7 +574,7 @@ bool Parser::parse_normal(MathAtom & matrix)
                parse_into(p->cell(0), 0);
                p->numbered(0, curr_num_);
                p->label(0, curr_label_);
-               return p;
+               return true;
        }
 
        if (cs != "begin") {