]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/array.C
fix pullArg when pressing <Delete> at the end of an cell
[lyx.git] / src / mathed / array.C
index 7141bb79dc7281d3529086f4617c64721fb8637e..a15ec82dedc3a38db7b14c4cb9c65aeb5c1070e8 100644 (file)
@@ -1,13 +1,11 @@
 
-#include <config.h>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
+#include "math_inset.h"
 #include "debug.h"
 #include "array.h"
-#include "math_inset.h"
 #include "math_scriptinset.h"
 #include "math_parser.h"
 #include "mathed/support.h"
@@ -22,7 +20,7 @@ MathArray::MathArray()
 MathArray::~MathArray()
 {
        for (int pos = 0; pos < size(); next(pos)) 
-               if (MathIsInset(pos)) 
+               if (isInset(pos)) 
                        delete nextInset(pos);
 }
 
@@ -35,6 +33,14 @@ MathArray::MathArray(MathArray const & array)
                        replace(pos, nextInset(pos)->clone());
 }
 
+MathArray::MathArray(MathArray const & array, int from, int to)
+       : bf_(array.bf_.begin() + from, array.bf_.begin() + to)
+{
+       for (int pos = 0; pos < size(); next(pos)) 
+               if (isInset(pos)) 
+                       replace(pos, nextInset(pos)->clone());
+}
+
 
 bool MathArray::next(int & pos) const
 {
@@ -108,7 +114,7 @@ MathInset * MathArray::prevInset(int pos) const
        return nextInset(pos);
 }
 
-byte MathArray::GetChar(int pos) const
+unsigned char MathArray::GetChar(int pos) const
 {
        return pos < size() ? bf_[pos + 1] : '\0';
 }
@@ -153,7 +159,7 @@ void MathArray::replace(int pos, MathInset * p)
        memcpy(&bf_[pos + 1], &p, sizeof(p));
 }
 
-void MathArray::insert(int pos, byte b, MathTextCodes t)
+void MathArray::insert(int pos, unsigned char b, MathTextCodes t)
 {
        bf_.insert(bf_.begin() + pos, 3, t);
        bf_[pos + 1] = b;
@@ -174,7 +180,7 @@ void MathArray::push_back(MathInset * p)
        insert(size(), p);
 }
 
-void MathArray::push_back(byte b, MathTextCodes c)
+void MathArray::push_back(unsigned char b, MathTextCodes c)
 {
        insert(size(), b, c);
 }
@@ -211,6 +217,12 @@ int MathArray::size() const
 }
 
 
+void MathArray::erase()
+{
+       erase(0, size());
+}
+
+
 void MathArray::erase(int pos)
 {
        if (pos < static_cast<int>(bf_.size()))
@@ -228,7 +240,7 @@ bool MathArray::isInset(int pos) const
 {
        if (pos >= size())
                return false;
-       return MathIsInset(bf_[pos]);
+       return MathIsInset(static_cast<MathTextCodes>(bf_[pos]));
 }
 
 
@@ -286,7 +298,7 @@ void MathArray::Write(ostream & os, bool fragile) const
                } else {
 
                        MathTextCodes fcode = GetCode(pos);
-                       byte c = GetChar(pos);
+                       unsigned char c = GetChar(pos);
 
                        if (MathIsSymbol(fcode)) {
                                latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
@@ -341,3 +353,11 @@ void MathArray::WriteNormal(ostream & os) const
        Write(os, true);
 }
 
+
+void MathArray::Validate(LaTeXFeatures & features) const
+{
+       for (int pos = 0; pos < size(); next(pos)) 
+               if (isInset(pos)) 
+                       nextInset(pos)->Validate(features);
+}
+