1999-09-27 18:44:28 +00:00
|
|
|
/*
|
|
|
|
* File: math_inset.C
|
|
|
|
* Purpose: Implementation of insets for mathed
|
2001-02-14 12:02:08 +00:00
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
1999-09-27 18:44:28 +00:00
|
|
|
* Created: January 1996
|
2001-02-14 12:02:08 +00:00
|
|
|
* Description:
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Version: 0.8beta.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2001-02-13 13:28:32 +00:00
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_iter.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "array.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "math_inset.h"
|
|
|
|
#include "symbol_def.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/lstrings.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
2001-02-13 15:27:03 +00:00
|
|
|
#include "mathed/support.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::endl;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
const int SizeInset = sizeof(char*) + 2;
|
|
|
|
|
2001-02-13 15:27:03 +00:00
|
|
|
//extern int mathed_char_width(short type, int style, byte c);
|
|
|
|
//extern int mathed_string_width(short type, int style, string const & s);
|
|
|
|
//extern int mathed_char_height(short, int, byte, int &, int &);
|
|
|
|
|
|
|
|
|
|
|
|
MathedIter::MathedIter()
|
2001-02-17 16:43:31 +00:00
|
|
|
: flags(0), fcode_(0), pos(0), row(0), col(0), ncols(0), array(0)
|
2001-02-13 15:27:03 +00:00
|
|
|
{}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
void MathedIter::SetData(MathedArray * a)
|
|
|
|
{
|
|
|
|
array = a; Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathedArray * MathedIter::GetData() const
|
|
|
|
{
|
|
|
|
return array;
|
|
|
|
}
|
2001-02-14 12:02:08 +00:00
|
|
|
|
2001-02-17 16:43:31 +00:00
|
|
|
short MathedIter::fcode() const
|
|
|
|
{
|
|
|
|
return fcode_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathedIter::fcode(short c) const
|
|
|
|
{
|
|
|
|
fcode_ = c;
|
|
|
|
}
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
int MathedIter::Empty() const
|
|
|
|
{
|
|
|
|
return array->last() <= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathedIter::OK() const
|
|
|
|
{
|
|
|
|
return array && (pos < array->last());
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
void MathedIter::Reset()
|
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (array->last() > 0 && MathIsFont((*array)[0])) {
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode((*array)[0]);
|
2001-02-14 12:02:08 +00:00
|
|
|
pos = 1;
|
|
|
|
} else {
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(-1);
|
2001-02-14 12:02:08 +00:00
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
col = 0;
|
|
|
|
row = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
byte MathedIter::GetChar() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (IsFont()) {
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode((*array)[pos]);
|
2001-02-14 12:02:08 +00:00
|
|
|
++pos;
|
|
|
|
}
|
|
|
|
return (*array)[pos];
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const MathedIter::GetString() const
|
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (IsFont()) {
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode((*array)[++pos]);
|
2001-02-08 15:09:15 +00:00
|
|
|
++pos;
|
|
|
|
}
|
2001-02-14 12:02:08 +00:00
|
|
|
|
2001-02-08 15:09:15 +00:00
|
|
|
string s;
|
2001-02-12 08:55:14 +00:00
|
|
|
for (; (*array)[pos] >= ' ' && pos < array->last(); ++pos)
|
|
|
|
s += (*array)[pos];
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2001-02-08 15:09:15 +00:00
|
|
|
return s;
|
|
|
|
}
|
2001-02-12 08:55:14 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
MathedInset * MathedIter::GetInset() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (IsInset()) {
|
|
|
|
MathedInset * p;
|
|
|
|
array->raw_pointer_copy(&p, pos + 1);
|
|
|
|
return p;
|
|
|
|
} else {
|
|
|
|
lyxerr << "Math Error: This is not an inset["
|
|
|
|
<< (*array)[pos] << "]" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
2001-02-14 12:02:08 +00:00
|
|
|
// An active math inset MUST be derived from MathParInset because it
|
1999-09-27 18:44:28 +00:00
|
|
|
// must have at least one paragraph to edit
|
2000-09-14 17:53:12 +00:00
|
|
|
MathParInset * MathedIter::GetActiveInset() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (IsActive())
|
|
|
|
return reinterpret_cast<MathParInset*>(GetInset());
|
|
|
|
|
|
|
|
lyxerr << "Math Error: This is not an active inset" << endl;
|
|
|
|
return 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
bool MathedIter::Next()
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
|
|
|
if (!OK())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ((*array)[pos] < ' ') {
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(-1);
|
2001-02-14 12:02:08 +00:00
|
|
|
if (IsTab())
|
|
|
|
++col;
|
|
|
|
if (IsCR()) {
|
|
|
|
col = 0;
|
|
|
|
++row;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
if (IsInset())
|
|
|
|
pos += sizeof(char*) + 2;
|
|
|
|
else
|
|
|
|
++pos;
|
|
|
|
|
|
|
|
if (IsFont())
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode((*array)[pos++]);
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
return true;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathedIter::goNextCode(MathedTextCodes code)
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
|
|
|
while (Next()) {
|
|
|
|
if ((*array)[pos] == code)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedIter::goPosAbs(int p)
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
while (pos < p && Next())
|
|
|
|
;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-17 18:52:53 +00:00
|
|
|
void MathedIter::insert(byte c, MathedTextCodes t)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (c < ' ')
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (t == LM_TC_TAB && col >= ncols - 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// 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)[pos] == ' ' || (*array)[pos - 1] == ' '))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (IsFont() && (*array)[pos] == t) {
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(t);
|
2001-02-14 12:02:08 +00:00
|
|
|
++pos;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2001-02-17 16:43:31 +00:00
|
|
|
if (t != fcode() && pos > 0 && MathIsFont((*array)[pos - 1])) {
|
2001-02-14 12:02:08 +00:00
|
|
|
--pos;
|
|
|
|
int k = pos - 1;
|
|
|
|
for (; k >= 0 && (*array)[k] >= ' '; --k)
|
|
|
|
;
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode( (k >= 0 && MathIsFont((*array)[k])) ? (*array)[k] : -1 );
|
2001-02-14 12:02:08 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-02-14 12:02:08 +00:00
|
|
|
|
2001-02-17 16:43:31 +00:00
|
|
|
short const f = ((*array)[pos] < ' ') ? 0 : fcode();
|
|
|
|
int shift = (t == fcode()) ? 1 : ((f) ? 3 : 2);
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
if (t == LM_TC_TAB || t == LM_TC_CR) {
|
|
|
|
--shift;
|
|
|
|
c = t;
|
|
|
|
if (t == LM_TC_CR) {
|
|
|
|
++row;
|
|
|
|
col = 0;
|
|
|
|
} else
|
|
|
|
++col;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos < array->last())
|
|
|
|
array->move(pos, shift);
|
|
|
|
else {
|
|
|
|
array->need_size(array->last() + shift);
|
|
|
|
array->last(array->last() + shift);
|
|
|
|
(*array)[array->last()] = '\0';
|
|
|
|
}
|
|
|
|
|
2001-02-17 16:43:31 +00:00
|
|
|
if (t != fcode()) {
|
2001-02-14 12:02:08 +00:00
|
|
|
if (f)
|
2001-02-17 16:43:31 +00:00
|
|
|
(*array)[pos + shift - 1] = fcode();
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
if (c >= ' ') {
|
|
|
|
(*array)[pos++] = t;
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(t);
|
2001-02-14 12:02:08 +00:00
|
|
|
} else
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(0);
|
2001-02-14 12:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(*array)[pos++] = c;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Prepare to insert a non-char object
|
|
|
|
void MathedIter::split(int shift)
|
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (pos < array->last()) {
|
|
|
|
|
|
|
|
bool fg = false;
|
|
|
|
if ((*array)[pos] >= ' ') {
|
|
|
|
if (pos> 0 && MathIsFont((*array)[pos - 1]))
|
|
|
|
--pos;
|
|
|
|
else {
|
|
|
|
fg = true;
|
|
|
|
++shift;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
array->move(pos, shift);
|
|
|
|
|
|
|
|
if (fg)
|
2001-02-17 16:43:31 +00:00
|
|
|
(*array)[pos + shift - 1] = fcode();
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
array->need_size(array->last() + shift);
|
|
|
|
array->last(array->last() + shift);
|
|
|
|
}
|
|
|
|
|
|
|
|
(*array)[array->last()] = '\0';
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// I assume that both pos and pos2 are legal positions
|
|
|
|
void MathedIter::join(int pos2)
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
|
|
|
if (!OK() || pos2 <= pos)
|
|
|
|
return;
|
|
|
|
|
2001-02-17 16:43:31 +00:00
|
|
|
short f = fcode();
|
2001-02-14 12:02:08 +00:00
|
|
|
if (pos > 0 && (*array)[pos] >= ' ' && MathIsFont((*array)[pos - 1]))
|
|
|
|
--pos;
|
|
|
|
|
|
|
|
if (MathIsFont((*array)[pos2 - 1]))
|
|
|
|
--pos2;
|
|
|
|
|
|
|
|
if ((*array)[pos2] >= ' ') {
|
|
|
|
for (int p = pos2; p > 0; --p) {
|
|
|
|
if (MathIsFont((*array)[p])) {
|
|
|
|
f = (*array)[p];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(*array)[pos++] = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
array->move(pos2, pos - pos2);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
2001-02-17 18:52:53 +00:00
|
|
|
void MathedIter::insertInset(MathedInset * p, int type)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-17 18:52:53 +00:00
|
|
|
#if 0
|
|
|
|
if (!MathIsInset(type))
|
|
|
|
type = LM_TC_INSET;
|
|
|
|
|
|
|
|
array->insertInset(pos, p, type);
|
|
|
|
++pos;
|
|
|
|
fcode(-1);
|
|
|
|
#else
|
2001-02-14 12:02:08 +00:00
|
|
|
int const shift = SizeInset;
|
|
|
|
|
|
|
|
if (!MathIsInset(type))
|
|
|
|
type = LM_TC_INSET;
|
|
|
|
|
|
|
|
split(shift);
|
|
|
|
|
|
|
|
(*array)[pos] = type;
|
|
|
|
array->raw_pointer_insert(p, pos + 1, sizeof(p));
|
|
|
|
pos += SizeInset;
|
|
|
|
(*array)[pos - 1] = type;
|
|
|
|
(*array)[array->last()] = '\0';
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(-1);
|
2001-02-17 18:52:53 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathedIter::Delete()
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
|
|
|
if (!OK())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int shift = 0;
|
|
|
|
byte c = GetChar();
|
|
|
|
if (c >= ' ') {
|
|
|
|
|
|
|
|
if (MathIsFont((*array)[pos - 1]) && (*array)[pos + 1] < ' ') {
|
|
|
|
shift = 2;
|
|
|
|
pos--;
|
|
|
|
int i = pos - 1;
|
|
|
|
for (; i > 0 && !MathIsFont((*array)[i]); --i)
|
|
|
|
;
|
|
|
|
if (i > 0 && MathIsFont((*array)[i]))
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode((*array)[i]);
|
2001-02-14 12:02:08 +00:00
|
|
|
} else
|
|
|
|
shift = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (MathIsInset((*array)[pos]))
|
|
|
|
shift = sizeof(char*) + 2;
|
|
|
|
else if (c == LM_TC_TAB || c == LM_TC_CR) {
|
|
|
|
++shift;
|
|
|
|
// lyxerr <<"Es un tab.";
|
|
|
|
} else {
|
|
|
|
lyxerr << "Math Warning: expected inset." << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shift != 0) {
|
|
|
|
array->move(pos + shift, -shift);
|
|
|
|
if (pos >= array->last())
|
|
|
|
pos = (array->last() > 0) ? array->last() : 0;
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-19 14:16:57 +00:00
|
|
|
MathedArray * MathedIter::Copy()
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
return Copy(0, 10000);
|
|
|
|
#else
|
|
|
|
if (!array) {
|
|
|
|
// lyxerr << "Math error: Attempting to copy a void array." << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new MathedArray(*array);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
MathedArray * MathedIter::Copy(int pos1, int pos2)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (!array) {
|
|
|
|
// lyxerr << "Math error: Attempting to copy a void array." << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipush();
|
|
|
|
MathedArray * t = array;
|
|
|
|
MathedArray * a;
|
|
|
|
|
|
|
|
if (pos1 > 0 || pos2 <= array->last()) {
|
|
|
|
short fc = 0;
|
|
|
|
if (pos1 > 0 && (*array)[pos1] > ' ') {
|
|
|
|
for (int p = pos1; p >= 0; --p) {
|
|
|
|
if (MathIsFont((*array)[p])) {
|
|
|
|
if (p != pos1 - 1)
|
|
|
|
fc = (*array)[p];
|
|
|
|
else
|
|
|
|
--pos1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos2 > 0 && (*array)[pos2] >= ' '
|
|
|
|
&& MathIsFont((*array)[pos2 - 1]))
|
|
|
|
--pos2;
|
|
|
|
|
|
|
|
int dx = pos2 - pos1;
|
2001-02-19 10:18:21 +00:00
|
|
|
a = new MathedArray;
|
|
|
|
a->resize(dx + 1);
|
2001-02-14 12:02:08 +00:00
|
|
|
// lyxerr << "VA " << pos2 << " " << pos2 << " " << dx << endl;
|
|
|
|
array->strange_copy(a, (fc) ? 1 : 0, pos1, dx);
|
|
|
|
if (fc) {
|
|
|
|
(*a)[0] = fc;
|
|
|
|
++dx;
|
|
|
|
}
|
|
|
|
a->last(dx);
|
|
|
|
(*a)[dx] = '\0';
|
|
|
|
} else
|
|
|
|
a = new MathedArray(*array);
|
|
|
|
|
2001-02-19 14:16:57 +00:00
|
|
|
// this should be unnecessary and leak in some (most?) cases since
|
|
|
|
// a = new MathedArray(*array); makes already a deep copy...
|
|
|
|
// I guess it'll go soon... (Andre')
|
|
|
|
|
2001-02-14 12:02:08 +00:00
|
|
|
SetData(a);
|
|
|
|
while (OK()) {
|
|
|
|
if (IsInset()) {
|
|
|
|
MathedInset * inset = GetInset();
|
|
|
|
inset = inset->Clone();
|
|
|
|
array->raw_pointer_insert(inset, pos + 1, sizeof(inset));
|
|
|
|
}
|
|
|
|
Next();
|
|
|
|
}
|
|
|
|
array = t;
|
|
|
|
ipop();
|
|
|
|
return a;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedIter::Clear()
|
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
if (!array) {
|
|
|
|
lyxerr << "Math error: Attempting to clean a void array." << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reset();
|
|
|
|
while (OK()) {
|
|
|
|
if (IsInset()) {
|
|
|
|
MathedInset * inset = GetInset();
|
|
|
|
if (inset->GetType()!= LM_OT_MACRO_ARG)
|
|
|
|
delete inset;
|
|
|
|
Delete();
|
|
|
|
} else
|
|
|
|
Next();
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check consistency of tabs and crs
|
|
|
|
void MathedIter::checkTabs()
|
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
ipush();
|
|
|
|
|
|
|
|
// MathedIter:Reset();
|
|
|
|
while (OK()) {
|
|
|
|
if ((IsTab() && col >= ncols - 1) || (IsCR() && !(MthIF_CR & flags))) {
|
|
|
|
Delete();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsCR() && col < ncols - 2)
|
2001-02-17 18:52:53 +00:00
|
|
|
insert(' ', LM_TC_TAB);
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
MathedIter::Next();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
if (col < ncols - 2)
|
2001-02-17 18:52:53 +00:00
|
|
|
insert(' ', LM_TC_TAB);
|
2001-02-14 12:02:08 +00:00
|
|
|
|
|
|
|
ipop();
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Try to adjust tabs in the expected place, as used in eqnarrays
|
|
|
|
// Rules:
|
|
|
|
// - If there are a relation operator, put tabs around it
|
|
|
|
// - If tehre are not a relation operator, put everything in the
|
|
|
|
// 3rd column.
|
|
|
|
void MathedIter::adjustTabs()
|
2001-02-14 12:02:08 +00:00
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
bool MathedIter::IsInset() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
return MathIsInset((*array)[pos]);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2001-02-14 12:02:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
bool MathedIter::IsActive() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
return MathIsActive((*array)[pos]);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
bool MathedIter::IsFont() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
return MathIsFont((*array)[pos]);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
bool MathedIter::IsScript() const
|
2000-09-14 17:53:12 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
return MathIsScript((*array)[pos]);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
bool MathedIter::IsTab() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
return ((*array)[pos] == LM_TC_TAB);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
bool MathedIter::IsCR() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
return ((*array)[pos] == LM_TC_CR);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
MathedIter::MathedIter(MathedArray * d)
|
|
|
|
: array(d)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-14 12:02:08 +00:00
|
|
|
pos = 0;
|
|
|
|
row = 0;
|
|
|
|
col = 0;
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode( (array && IsFont()) ? (*array)[0] : 0 );
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
void MathedIter::ipush()
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
2001-02-17 16:43:31 +00:00
|
|
|
stck.fcode = fcode();
|
2001-02-14 12:02:08 +00:00
|
|
|
stck.pos = pos;
|
|
|
|
stck.row = row;
|
|
|
|
stck.col = col;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
void MathedIter::ipop()
|
2001-02-14 12:02:08 +00:00
|
|
|
{
|
2001-02-17 16:43:31 +00:00
|
|
|
fcode(stck.fcode);
|
2001-02-14 12:02:08 +00:00
|
|
|
pos = stck.pos;
|
|
|
|
row = stck.row;
|
|
|
|
col = stck.col;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|