+2001-02-09 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * array.h: made all variables private, removed friend, added new
+ methods: raw_pointer_insert, raw_pointer_copy, strange_copy, added
+ non const operator[] added setter for last and getter for maxsize.
+ changed name from LyxArrayBase to MathedArray.
+ changed name of some methods to start with lowerchar.
+ moved inline methods to array.C
+
+ * math_iter.C + several file: changes because of the above.
+
+ * array.C: new file with the prev inline methods.
+
2001-02-10 Dekel Tsur <dekelts@tau.ac.il>
* Many files: add support for the align environment from amsmath.
BOOST_INCLUDES = -I$(top_srcdir)/boost
INCLUDES = -I${top_srcdir}/images -I${srcdir}/../ $(SIGC_CFLAGS) $(BOOST_INCLUDES)
-libmathed_la_SOURCES = array.h \
+libmathed_la_SOURCES = \
+ array.C \
+ array.h \
formula.C \
formula.h \
formulamacro.C \
--- /dev/null
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "array.h"
+#include "math_defs.h"
+
+
+// Is this still needed? (Lgb)
+static inline
+void * my_memcpy(void * ps_in, void const * pt_in, size_t n)
+{
+ char * ps = static_cast<char *>(ps_in);
+ char const * pt = static_cast<char const *>(pt_in);
+ while (n--) *ps++ = *pt++;
+ return ps_in;
+}
+
+
+int MathedArray::empty() const
+{
+ return (last_ == 0);
+}
+
+
+int MathedArray::last() const
+{
+ return last_;
+}
+
+
+void MathedArray::last(int l)
+{
+ last_ = l;
+}
+
+
+int MathedArray::maxsize() const
+{
+ return maxsize_;
+}
+
+
+void MathedArray::resize(int newsize)
+{
+ if (newsize < ARRAY_MIN_SIZE)
+ newsize = ARRAY_MIN_SIZE;
+ newsize += ARRAY_STEP - (newsize % ARRAY_STEP);
+ bf_.resize(newsize);
+ if (last_ >= newsize) last_ = newsize - 1;
+ maxsize_ = newsize;
+ bf_[last_] = 0;
+}
+
+
+MathedArray::MathedArray(int size)
+{
+ maxsize_ = (size < ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE : size;
+ bf_.resize(maxsize_);
+ last_ = 0;
+}
+
+
+void MathedArray::move(int p, int shift)
+{
+ if (p <= last_) {
+ if (last_ + shift >= maxsize_) {
+ resize(last_ + shift);
+ }
+ memmove(&bf_[p + shift], &bf_[p], last_ - p);
+ last_ += shift;
+ bf_[last_] = 0;
+ }
+}
+
+
+void MathedArray::mergeF(MathedArray * a, int p, int dx)
+{
+ my_memcpy(&bf_[p], &a->bf_[0], dx);
+}
+
+
+void MathedArray::raw_pointer_copy(MathedInset ** p, int pos) const
+{
+ my_memcpy(p, &bf_[pos], sizeof(MathedInset*));
+}
+
+
+void MathedArray::raw_pointer_insert(void * p, int pos, int len)
+{
+ my_memcpy(&bf_[pos], &p, len);
+}
+
+
+void MathedArray::strange_copy(MathedArray * dest, int dpos,
+ int spos, int len)
+{
+ my_memcpy(&dest[dpos], &bf_[spos], len);
+}
+
+
+byte MathedArray::operator[](int i) const
+{
+ return bf_[i];
+}
+
+
+byte & MathedArray::operator[](int i)
+{
+ return bf_[i];
+}
+
+
+void MathedArray::insert(int pos, byte c)
+{
+ if (pos < 0) pos = last_;
+ if (pos >= maxsize_)
+ resize(maxsize_ + ARRAY_STEP);
+ bf_[pos] = c;
+ if (pos >= last_)
+ last_ = pos + 1;
+}
// -*- C++ -*-
/*
- * File: array.h
* Purpose: A general purpose resizable array.
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* the GNU General Public Licence version 2 or later.
*/
+#ifndef MATHEDARRAY_H
+#define MATHEDARRAY_H
+
#include <vector>
+
+class MathedInset;
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
#ifndef byte
#define byte unsigned char
#endif
-/** A resizable array.
+/** \class MathedArray
+ \brief A resizable array.
+
A general purpose resizable array.
- @author Alejandro Aguilar Sierra
- @version January 1996
+
+ \author Alejandro Aguilar Sierra
+ \author André Pönitz
+ \author Lars Gullik Bjønnes
+ \version February 2001
*/
-class LyxArrayBase {
+class MathedArray {
public:
///
- typedef std::vector<byte> buffer_type;
+ typedef std::vector<byte> buffer_type;
+ typedef byte value_type;
+ typedef buffer_type::size_type size_type;
///
enum {
///
///
explicit
- LyxArrayBase(int size = ARRAY_STEP);
+ MathedArray(int size = ARRAY_STEP);
///
- int empty() const { return (last == 0); }
+ int empty() const;
///
- int Last() { return last; }
+ int last() const;
+ ///
+ void last(int l);
- /// Make the allocated memory fit the needed size
- void Fit();
-
- /// Remove dx elements from position pos. Don't changes the size
- void Remove(int pos, int dx);
-
- /// Merge dx elements from array a at pos. Changes the size if necessary.
- void Merge(LyxArrayBase * a, int pos, int dx);
-
- /// Same as Merge but doesn't changes the size (dangerous)
- void MergeF(LyxArrayBase * a, int pos, int dx);
+ /// Merge \a dx elements from array \a a at \apos.
+ /// This doesn't changes the size (dangerous)
+ void mergeF(MathedArray * a, int pos, int dx);
- /// Copy dx byts from an array at position pos
- void Copy(void *, int pos, int dx);
+ /// Insert a character at position \a pos
+ void insert(int pos, byte);
- /// Constructs a new array with dx elements starting at pos
- LyxArrayBase * Extract(int pos, int dx);
-
- /// Insert a character at position pos
- void Insert(int pos, byte);
-
- /// Constructs a new array with dx elements starting at pos
- byte operator[](const int);
-
-protected:
///
- void Resize(int newsize);
+ void raw_pointer_copy(MathedInset ** p, int pos) const;
+ ///
+ void raw_pointer_insert(void * p, int pos, int len);
+ ///
+ void strange_copy(MathedArray * dest, int dpos, int spos, int len);
+ ///
+ byte operator[](int) const;
+ ///
+ byte & operator[](int i);
+
+ ///
+ void move(int p, int shift);
///
- bool Move(int p, int shift);
+ void resize(int newsize);
+ ///
+ int maxsize() const;
+private:
/// Buffer
- buffer_type bf;
+ buffer_type bf_;
/// Last position inserted.
- int last;
+ int last_;
/// Max size of the array.
- int maxsize;
-private:
- ///
- friend class MathedIter;
+ int maxsize_;
};
-
-
-
-/************************ Inline functions *****************************/
-
-inline // Hmmm, Hp-UX's CC can't handle this inline. Asger.
-void LyxArrayBase::Resize(int newsize)
-{
- if (newsize<ARRAY_MIN_SIZE)
- newsize = ARRAY_MIN_SIZE;
- newsize += ARRAY_STEP - (newsize % ARRAY_STEP);
- bf.resize(newsize);
- if (last >= newsize) last = newsize-1;
- maxsize = newsize;
- bf[last] = 0;
-}
-
-inline
-LyxArrayBase::LyxArrayBase(int size)
-{
- maxsize = (size<ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE: size;
- bf.resize(maxsize);
- last = 0;
-}
-
-inline
-bool LyxArrayBase::Move(int p, int shift)
-{
- bool result = false;
- if (p <= last) {
- if (last + shift >= maxsize) {
- Resize(last + shift);
- }
- memmove(&bf[p + shift], &bf[p], last - p);
- last += shift;
- bf[last] = 0;
- result = true;
- }
- return result;
-}
-
-inline
-void LyxArrayBase::Fit()
-{
- Resize(last);
-}
-
-inline
-void LyxArrayBase::Remove(int pos, int dx)
-{
- Move(pos + dx, -dx);
-}
-
-inline
-void LyxArrayBase::Merge(LyxArrayBase * a, int p, int dx)
-{
- Move(p, dx);
- memcpy(&bf[p], &a->bf[0], dx);
-}
-
-inline
-void LyxArrayBase::MergeF(LyxArrayBase * a, int p, int dx)
-{
- memcpy(&bf[p], &a->bf[0], dx);
-}
-
-inline
-void LyxArrayBase::Copy(void * a, int p, int dx)
-{
- memcpy(&bf[p], a, dx);
-}
-
-inline
-LyxArrayBase * LyxArrayBase::Extract(int, int dx)
-{
- LyxArrayBase * a = new LyxArrayBase(dx);
- a->Merge(this, 0, dx);
- return a;
-}
-
-inline
-byte LyxArrayBase::operator[](const int i)
-{
- return bf[i];
-}
-
-
-inline
-void LyxArrayBase::Insert(int pos, byte c)
-{
- if (pos < 0) pos = last;
- if (pos >= maxsize)
- Resize(maxsize + ARRAY_STEP);
- bf[pos] = c;
- if (pos >= last)
- last = pos + 1;
-}
+#endif
void InsetFormulaMacro::InsetUnlock(BufferView * bv)
{
opened = false;
- LyxArrayBase * tarray = tmacro->GetData();
+ MathedArray * tarray = tmacro->GetData();
MathedIter it(tarray);
it.Clear();
tmacro->SetData(par->GetData());
#include "LColor.h"
#include "Painter.h"
-static LyxArrayBase * selarray = 0;
+static MathedArray * selarray = 0;
using std::endl;
if (!p) {
return false;
}
- LyxArrayBase * a = p->GetData();
+ MathedArray * a = p->GetData();
p->SetData(0);
Delete();
if (a) {
///
MathedXIter cursel, * anchor;
///
-// LyxArrayBase *selarray;
+// MathedArray *selarray;
///
bool is_visible;
///
virtual void UserSetSize(short);
/// Data is stored in a LyXArray
- virtual void SetData(LyxArrayBase *);
+ virtual void SetData(MathedArray *);
///
- virtual LyxArrayBase * GetData() { return array; }
+ virtual MathedArray * GetData() { return array; }
/// Paragraph position
virtual void GetXY(int &, int &) const;
protected:
/// Paragraph data is stored here
- LyxArrayBase * array;
+ MathedArray * array;
/// Cursor start position
int xo;
///
///
friend class MathedCursor;
///
- friend LyxArrayBase * mathed_parse(unsigned flags = 0,
- LyxArrayBase * a = 0,
+ friend MathedArray * mathed_parse(unsigned flags = 0,
+ MathedArray * a = 0,
MathParInset ** p = 0);
};
///
void Metrics();
///
- void SetData(LyxArrayBase *);
+ void SetData(MathedArray *);
///
void SetAlign(char, string const &);
///
/************************* Prototypes **********************************/
///
-LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * data,
+MathedArray * mathed_parse(unsigned flags, MathedArray * data,
MathParInset ** mt);
///
void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
}
-void MathParInset::SetData(LyxArrayBase * a)
+void MathParInset::SetData(MathedArray * a)
{
array = a;
}
-void MathFracInset::SetData(LyxArrayBase * n, LyxArrayBase * d)
+void MathFracInset::SetData(MathedArray * n, MathedArray * d)
{
den->SetData(d);
MathParInset::SetData(n);
}
-void MathFracInset::SetData(LyxArrayBase * d)
+void MathFracInset::SetData(MathedArray * d)
{
if (idx == 0)
MathParInset::SetData(d);
}
-LyxArrayBase * MathFracInset::GetData()
+MathedArray * MathFracInset::GetData()
{
if (idx == 0)
return array;
// Check the number of tabs and crs
-void MathMatrixInset::SetData(LyxArrayBase * a)
+void MathMatrixInset::SetData(MathedArray * a)
{
if (!a) return;
MathedIter it(a);
///
void Metrics();
- /** This does the same that SetData(LyxArrayBase*) but for both
+ /** This does the same that SetData(MathedArray*) but for both
numerator and denominator at once.
*/
- void SetData(LyxArrayBase *, LyxArrayBase *);
+ void SetData(MathedArray *, MathedArray *);
///
- void SetData(LyxArrayBase *);
+ void SetData(MathedArray *);
///
void GetXY(int & x, int & y) const;
///
///
bool Inside(int, int);
///
- LyxArrayBase * GetData();
+ MathedArray * GetData();
///
bool setArgumentIdx(int i); // was bool Up/down(void);
///
extern int mathed_string_width(short type, int style, string const & s);
extern int mathed_char_height(short, int, byte, int &, int &);
-// the builtin memcpy() is broken in egcs and gcc 2.95.x on alpha
-// stations. We provide a hand-made version instead.
-static inline
-void my_memcpy( void * ps_in, void const * pt_in, size_t n )
-{
- char * ps = static_cast<char *>(ps_in);
- char const * pt = static_cast<char const *>(pt_in);
- /*
- for (size_t i = n; i--;)
- *ps++ = *pt++;
- */
- while (n--) *ps++ = *pt++;
-}
-
void MathedIter::Reset()
{
- if (array->last > 0 && MathIsFont(array->bf[0])) {
- fcode = array->bf[0];
+ if (array->last() > 0 && MathIsFont((*array)[0])) {
+ fcode = (*array)[0];
pos = 1;
} else {
fcode = -1;
byte MathedIter::GetChar() const
{
if (IsFont()) {
- fcode = array->bf[pos];
+ fcode = (*array)[pos];
++pos;
}
- return array->bf[pos];
+ return (*array)[pos];
}
string const MathedIter::GetString() const
{
if (IsFont()) {
- fcode = array->bf[++pos];
+ fcode = (*array)[++pos];
++pos;
}
string s;
- for ( ; array->bf[pos] >= ' ' && pos < array->last; ++pos)
- s += array->bf[pos];
+ for (; (*array)[pos] >= ' ' && pos < array->last(); ++pos)
+ s += (*array)[pos];
return s;
}
-
+
+
MathedInset * MathedIter::GetInset() const
{
if (IsInset()) {
MathedInset * p;
- my_memcpy(&p, &array->bf[pos + 1], sizeof(p));
+ array->raw_pointer_copy(&p, pos + 1);
return p;
} else {
lyxerr << "Math Error: This is not an inset["
- << array->bf[pos] << "]" << endl;
+ << (*array)[pos] << "]" << endl;
return 0;
}
}
+
// An active math inset MUST be derived from MathParInset because it
// must have at least one paragraph to edit
MathParInset * MathedIter::GetActiveInset() const
return 0;
}
+
bool MathedIter::Next()
{
if (!OK()) return false;
- if (array->bf[pos] < ' ') {
+ if ((*array)[pos] < ' ') {
fcode = -1;
if (IsTab()) ++col;
if (IsCR()) {
++pos;
if (IsFont()) {
- fcode = array->bf[pos++];
+ fcode = (*array)[pos++];
}
return true;
bool MathedIter::goNextCode(MathedTextCodes code)
{
while (Next()) {
- if (array->bf[pos] == code)
+ if ((*array)[pos] == code)
return true;
}
// Never more than one space // array->bf[pos-1] gives error from purify:
// Reading 1 byte from 0x47b857 in the heap.
// Address 0x47b857 is 1 byte before start of malloc'd block at 0x47b858 of 16 bytes.
- if (c == ' ' && (array->bf[pos] == ' ' || array->bf[pos - 1] == ' '))
+ if (c == ' ' && ((*array)[pos] == ' ' || (*array)[pos - 1] == ' '))
return;
- if (IsFont() && array->bf[pos] == t) {
+ if (IsFont() && (*array)[pos] == t) {
fcode = t;
++pos;
} else
- if (t != fcode && pos > 0 && MathIsFont(array->bf[pos - 1])) {
+ if (t != fcode && pos > 0 && MathIsFont((*array)[pos - 1])) {
--pos;
int k = pos - 1;
- for (; k >= 0 && array->bf[k] >= ' '; --k);
- fcode = (k >= 0 && MathIsFont(array->bf[k])) ? array->bf[k] : -1;
+ for (; k >= 0 && (*array)[k] >= ' '; --k);
+ fcode = (k >= 0 && MathIsFont((*array)[k])) ? (*array)[k] : -1;
}
- short const f = (array->bf[pos] < ' ') ? 0 : fcode;
+ short const f = ((*array)[pos] < ' ') ? 0 : fcode;
int shift = (t == fcode) ? 1 : ((f) ? 3 : 2);
if (t == LM_TC_TAB || t == LM_TC_CR) {
++col;
}
- if (pos < array->last)
- array->Move(pos, shift);
+ if (pos < array->last())
+ array->move(pos, shift);
else {
- if (array->last+shift >= array->maxsize) {
- array->Resize(array->last+shift);
+ if (array->last() + shift >= array->maxsize()) {
+ array->resize(array->last() + shift);
}
- array->last += shift;
- array->bf[array->last] = '\0';
+ array->last(array->last() + shift);
+ (*array)[array->last()] = '\0';
}
if (t != fcode) {
if (f)
- array->bf[pos + shift - 1] = fcode;
+ (*array)[pos + shift - 1] = fcode;
if (c >= ' ') {
- array->bf[pos++] = t;
+ (*array)[pos++] = t;
fcode = t;
} else {
fcode = 0;
}
- }
- array->bf[pos++] = c;
+ }
+ (*array)[pos++] = c;
}
// Prepare to insert a non-char object
void MathedIter::split(int shift)
{
- if (pos < array->last) {
+ if (pos < array->last()) {
bool fg = false;
- if (array->bf[pos] >= ' ') {
- if (pos> 0 && MathIsFont(array->bf[pos - 1]))
+ if ((*array)[pos] >= ' ') {
+ if (pos> 0 && MathIsFont((*array)[pos - 1]))
--pos;
else {
- fg = true;
+ fg = true;
++shift;
}
}
- array->Move(pos, shift);
- if (fg) array->bf[pos + shift - 1] = fcode;
+ array->move(pos, shift);
+ if (fg) (*array)[pos + shift - 1] = fcode;
} else {
- if (array->last + shift >= array->maxsize) {
- array->Resize(array->last + shift);
+ if (array->last() + shift >= array->maxsize()) {
+ array->resize(array->last() + shift);
}
- array->last += shift;
+ array->last(array->last() + shift);
}
- array->bf[array->last] = '\0';
+ (*array)[array->last()] = '\0';
}
// I assume that both pos and pos2 are legal positions
void MathedIter::join(int pos2)
{
- if (!OK() || pos2<= pos)
+ if (!OK() || pos2 <= pos)
return;
short f = fcode;
- if (pos > 0 && array->bf[pos] >= ' ' && MathIsFont(array->bf[pos - 1]))
+ if (pos > 0 && (*array)[pos] >= ' ' && MathIsFont((*array)[pos - 1]))
--pos;
- if (MathIsFont(array->bf[pos2 - 1]))
+ if (MathIsFont((*array)[pos2 - 1]))
--pos2;
- if (array->bf[pos2] >= ' ') {
+ if ((*array)[pos2] >= ' ') {
for (int p = pos2; p > 0; --p)
- if (MathIsFont(array->bf[p])) {
- f = array->bf[p];
+ if (MathIsFont((*array)[p])) {
+ f = (*array)[p];
break;
}
- array->bf[pos++] = f;
+ (*array)[pos++] = f;
}
- array->Move(pos2, pos - pos2);
+ array->move(pos2, pos - pos2);
}
+
void MathedIter::Insert(MathedInset * p, int type)
{
int const shift = SizeInset;
if (!MathIsInset(type))
type = LM_TC_INSET;
split(shift);
- array->bf[pos] = type;
- my_memcpy(&array->bf[pos + 1], &p, sizeof(p));
+ (*array)[pos] = type;
+ array->raw_pointer_insert(p, pos + 1, sizeof(p));
pos += SizeInset;
- array->bf[pos - 1] = type;
- array->bf[array->last] = '\0';
+ (*array)[pos - 1] = type;
+ (*array)[array->last()] = '\0';
fcode = -1;
}
int shift = 0;
byte c = GetChar();
- if (c >= ' ') {
- if (MathIsFont(array->bf[pos - 1]) && array->bf[pos + 1] < ' ') {
+ if (c >= ' ') {
+ if (MathIsFont((*array)[pos - 1]) && (*array)[pos + 1] < ' ') {
shift = 2;
pos--;
int i = pos - 1;
- for (; i > 0 && !MathIsFont(array->bf[i]); --i);
- if (i > 0 && MathIsFont(array->bf[i]))
- fcode = array->bf[i];
+ for (; i > 0 && !MathIsFont((*array)[i]); --i);
+ if (i > 0 && MathIsFont((*array)[i]))
+ fcode = (*array)[i];
} else
- shift = 1;
+ shift = 1;
} else {
- if (MathIsInset(array->bf[pos]))
+ if (MathIsInset((*array)[pos]))
shift = sizeof(char*) + 2;
else if (c == LM_TC_TAB || c == LM_TC_CR) {
++shift;
}
if (shift != 0) {
- array->Move(pos + shift, -shift);
- if (pos >= array->last)
- pos = (array->last > 0) ? array->last : 0;
+ array->move(pos + shift, -shift);
+ if (pos >= array->last())
+ pos = (array->last() > 0) ? array->last() : 0;
return true;
} else
return false;
}
-LyxArrayBase * MathedIter::Copy(int pos1, int pos2)
+MathedArray * MathedIter::Copy(int pos1, int pos2)
{
if (!array) {
// lyxerr << "Math error: Attempting to copy a void array." << endl;
return 0;
}
-// int posx = pos;
ipush();
- LyxArrayBase * t = array, * a;
+ MathedArray * t = array;
+ MathedArray * a;
- if (pos1 > 0 || pos2 <= array->last) {
+ if (pos1 > 0 || pos2 <= array->last()) {
short fc = 0;
- if (pos1 > 0 && array->bf[pos1] > ' ') {
+ if (pos1 > 0 && (*array)[pos1] > ' ') {
for (int p = pos1; p >= 0; --p)
- if (MathIsFont(array->bf[p])) {
+ if (MathIsFont((*array)[p])) {
if (p != pos1 - 1)
- fc = array->bf[p];
+ fc = (*array)[p];
else
--pos1;
break;
}
}
- if (pos2 > 0 && array->bf[pos2] >= ' '
- && MathIsFont(array->bf[pos2 - 1]))
+ if (pos2 > 0 && (*array)[pos2] >= ' '
+ && MathIsFont((*array)[pos2 - 1]))
--pos2;
int dx = pos2 - pos1;
- a = new LyxArrayBase(dx + LyxArrayBase::ARRAY_MIN_SIZE);
+ a = new MathedArray(dx + MathedArray::ARRAY_MIN_SIZE);
// lyxerr << "VA " << pos2 << " " << pos2 << " " << dx << endl;
- my_memcpy(&a->bf[(fc) ? 1 : 0], &array->bf[pos1], dx);
+ array->strange_copy(a, (fc) ? 1 : 0, pos1, dx);
if (fc) {
- a->bf[0] = fc;
+ (*a)[0] = fc;
++dx;
}
- a->last = dx;
- a->bf[dx] = '\0';
+ a->last(dx);
+ (*a)[dx] = '\0';
} else
- a = new LyxArrayBase(*array);
+ a = new MathedArray(*array);
SetData(a);
while (OK()) {
if (IsInset()) {
MathedInset * inset = GetInset();
inset = inset->Clone();
- my_memcpy(&array->bf[pos + 1], &inset, sizeof(inset));
+ array->raw_pointer_insert(inset, pos + 1, sizeof(inset));
}
Next();
}
-// pos = posx;
array = t;
ipop();
return a;
if (!array) {
lyxerr << "Math error: Attempting to clean a void array." << endl;
return;
- }
+ }
Reset();
while (OK()) {
if (IsInset()) {
}
ipop();
- if (pos2 <= array->Last()) {
+ if (pos2 <= array->last()) {
pos = pos1;
join(pos2);
checkTabs();
}
-void MathedXIter::Merge(LyxArrayBase * a0)
+void MathedXIter::Merge(MathedArray * a0)
{
if (!a0) {
lyxerr[Debug::MATHED]
}
// All insets must be clonned
MathedIter it(a0);
- LyxArrayBase * a = it.Copy();
+ MathedArray * a = it.Copy();
// make room for the data
- split(a->Last());
- array->MergeF(a, pos, a->Last());
+ split(a->last());
+ array->mergeF(a, pos, a->last());
int pos1 = pos;
- int pos2 = pos + a->Last();
- // int pos3 = 0;
+ int pos2 = pos + a->last();
goPosAbs(pos1);
}
}
+
void MathedXIter::SetData(MathParInset * pp)
{
p = pp;
y = crow->getBaseline();
}
if (!array) {
- array = new LyxArrayBase; // this leaks
+ array = new MathedArray; // this leaks
p->SetData(array);
}
size = p->GetStyle();
}
}
+
void MathedXIter::GoLast()
{
while (Next());
if (row == 0) return false;
int xp = x;
int rowp = row;
- int colp= col;
+ int colp = col;
GoBegin();
while (row < rowp - 1) Next();
while (x < xp && OK() && !IsCR()) {
checkTabs();
}
+
void MathedXIter::ipush()
{
MathedIter::ipush();
}
///
explicit
- MathedIter(LyxArrayBase *);
+ MathedIter(MathedArray *);
///
virtual ~MathedIter() {}
///
///
void goPosAbs(int);
///
- int Empty() const { return array->Last()<= 1; }
+ int Empty() const { return array->last() <= 1; }
///
- int OK() const { return array && (pos < array->Last()); }
+ int OK() const { return array && (pos < array->last()); }
///
int IsFirst() const { return (pos == 0); }
///
///
void setNumCols(int n) { ncols = n; }
///
- void SetData(LyxArrayBase * a) { array = a; Reset(); }
+ void SetData(MathedArray * a) { array = a; Reset(); }
///
- LyxArrayBase * GetData() const { return array; }
+ MathedArray * GetData() const { return array; }
/// Copy every object from position p1 to p2
- LyxArrayBase * Copy(int p1 = 0, int p2 = 10000);
+ MathedArray * Copy(int p1 = 0, int p2 = 10000);
/// Delete every object from position p1 to p2
void Clear();
///
int row, col, ncols;
///
- LyxArrayBase * array;
+ MathedArray * array;
// one element stack
struct MIState {
///
///
void setTab(int, int);
/// Merge the array at current position
- void Merge(LyxArrayBase *);
+ void Merge(MathedArray *);
/// Delete every object from current position to pos2
void Clean(int pos2);
///
inline
-MathedIter::MathedIter(LyxArrayBase * d)
+MathedIter::MathedIter(MathedArray * d)
: array(d)
{
pos = 0;
row = col = 0;
fcode = (array && IsFont()) ? (*array)[0]: 0;
}
-
+
inline
void MathedIter::ipush()
{
if (p)
p->GetXY(xx, yy);
- else
- { xx = 0; yy = 0; }
+ else {
+ xx = 0;
+ yy = 0;
+ }
xx += x; yy += y;
}
+
inline
int MathedXIter::GetX() const
{
return xx;
}
+
inline
int MathedXIter::GetY() const
{
inline
void MathedXIter::GetIncPos(int & xx, int & yy) const
{
- xx = x; yy = y;
+ xx = x;
+ yy = y;
}
args[i].row = 0;
/* int k = tmplate->getMacroPar(i)->GetColumns();
if (k>0) {
- args[i].array = new LyxArrayBase;
+ args[i].array = new MathedArray;
for (int j= 0; j<k-1; ++j) args[i].array->Insert(j, LM_TC_TAB);
}*/
}
}
-void MathMacroTemplate::setArgument(LyxArrayBase * a, int i)
+void MathMacroTemplate::setArgument(MathedArray * a, int i)
{
args[i].SetData(a);
}
{
MathedIter iter;
MathParInset * inset;// *arg;
- LyxArrayBase * array2;
+ MathedArray * array2;
built = true;
// This macro doesn't have arguments
MathMacroTemplate * m = new MathMacroTemplate("notin"); // this leaks
addTemplate(m);
- LyxArrayBase * array = new LyxArrayBase; // this leaks
+ MathedArray * array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not)); // this leaks
m->SetData(array);
// These two are only while we are still with LyX 2.x
m = new MathMacroTemplate("emptyset"); // this leaks
addTemplate(m);
- array = new LyxArrayBase; // this leaks
+ array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(new MathAccentInset('O', LM_TC_RM, LM_not)); // this leaks
m->SetData(array);
m = new MathMacroTemplate("perp"); // this leaks
addTemplate(m);
- array = new LyxArrayBase; // this leaks
+ array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(LM_bot, LM_TC_BOP);
m->SetData(array);
// binom has two arguments
m = new MathMacroTemplate("binom", 2);
addTemplate(m);
- array = new LyxArrayBase;
+ array = new MathedArray;
m->SetData(array);
iter.SetData(array);
inset = new MathDelimInset('(', ')');
iter.Insert(inset, LM_TC_ACTIVE_INSET);
- array = new LyxArrayBase;
+ array = new MathedArray;
iter.SetData(array);
MathFracInset *frac = new MathFracInset(LM_OT_ATOP);
iter.Insert(frac, LM_TC_ACTIVE_INSET);
inset->SetData(array);
- array = new LyxArrayBase;
- array2 = new LyxArrayBase;
+ array = new MathedArray;
+ array2 = new MathedArray;
iter.SetData(array);
iter.Insert(m->getMacroPar(0));
iter.SetData(array2);
// Cases has 1 argument
m = new MathMacroTemplate("cases", 1, MMF_Env); // this leaks
addTemplate(m);
- array = new LyxArrayBase; // this leaks
+ array = new MathedArray; // this leaks
iter.SetData(array);
arg = new MathMatrixInset(2, 1); // this leaks
iter.Insert(arg, LM_TC_ACTIVE_INSET);
inset = new MathDelimInset('{', '.'); // this leaks
inset->SetData(array);
- array = new LyxArrayBase; // this leaks
+ array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(inset, LM_TC_ACTIVE_INSET);
m->SetData(array);
arg = new MathMatrixInset(1, 1); // this leaks
m->setArgument(arg);
arg->SetType(LM_OT_MACRO);
- array = new LyxArrayBase; // this leaks
+ array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(arg, LM_TC_ACTIVE_INSET);
m->SetData(array);*/
///
typedef MathParInset * MathParInsetP;
///
-typedef LyxArrayBase * LyxArrayBaseP;
+typedef MathedArray * MathedArrayP;
class MathMacroTemplate;
///
void SetFocus(int, int);
///
- LyxArrayBase * GetData();
+ MathedArray * GetData();
///
MathedRowSt * getRowSt() const { return args[idx].row; }
///
- void SetData(LyxArrayBase *);
+ void SetData(MathedArray *);
///
MathedTextCodes getTCode() const { return tcode; }
///
///
MathedRowSt * row;
///
- LyxArrayBase * array;
+ MathedArray * array;
///
MacroArgumentBase() { x = y = 0; array = 0; row = 0; }
};
///
MathedTextCodes getTCode() const { return tcode; }
///
- void setArgument(LyxArrayBase *, int i= 0);
+ void setArgument(MathedArray *, int i= 0);
/// Number of arguments
int getNoArgs() const { return nargs; }
///
inline
-LyxArrayBase * MathMacro::GetData()
+MathedArray * MathMacro::GetData()
{
return args[idx].array;
}
inline
-void MathMacro::SetData(LyxArrayBase * a)
+void MathMacro::SetData(MathedArray * a)
{
args[idx].array = a;
}
}
-LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
+MathedArray * mathed_parse(unsigned flags, MathedArray * array,
MathParInset ** mtx)
{
int t = yylex();
MathedRowSt * crow = (mt) ? mt->getRowSt() : 0;
++plevel;
- if (!array) array = new LyxArrayBase;
+ if (!array) array = new MathedArray;
MathedIter data(array);
while (t) {
if ((flags & FLAG_BRACE) && t != LM_TK_OPEN) {
case '^':
{
MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
- LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
+ MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
p->SetData(ar);
// lyxerr << "UP[" << p->GetStyle() << "]" << endl;
data.Insert (p, LM_TC_UP);
case '_':
{
MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
- LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
+ MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
p->SetData(ar);
data.Insert (p, LM_TC_DOWN);
break;
case LM_TK_FRAC:
{
MathFracInset * fc = new MathFracInset(fractype);
- LyxArrayBase * num = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
- LyxArrayBase * den = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
+ MathedArray * num = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
+ MathedArray * den = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
fc->SetData(num, den);
data.Insert(fc, LM_TC_ACTIVE_INSET);
break;
if (lfd == LM_TK_SYM || lfd == LM_TK_STR || lfd == LM_TK_BOP|| lfd == LM_TK_SPECIAL)
lfd = (lfd == LM_TK_SYM) ? yylval.l->id: yylval.i;
// lyxerr << "L[" << lfd << " " << lfd << "]";
- LyxArrayBase * a = mathed_parse(FLAG_RIGHT);
+ MathedArray * a = mathed_parse(FLAG_RIGHT);
int rgd = yylex();
// lyxerr << "R[" << rgd << "]";
if (rgd == LM_TK_SYM || rgd == LM_TK_STR || rgd == LM_TK_BOP || rgd == LM_TK_SPECIAL)
}
-void MathRootInset::SetData(LyxArrayBase * d)
+void MathRootInset::SetData(MathedArray * d)
{
if (idx == 1)
MathParInset::SetData(d);
}
-LyxArrayBase * MathRootInset::GetData()
+MathedArray * MathRootInset::GetData()
{
if (idx == 1)
return array;
///
void SetFocus(int, int);
///
- void SetData(LyxArrayBase *);
+ void SetData(MathedArray *);
///
void GetXY(int & x, int & y) const;
///
- LyxArrayBase * GetData();
+ MathedArray * GetData();
///
bool setArgumentIdx(int i);
///