prepare re-enabling LaTeX feature validation

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2240 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-07-13 14:54:56 +00:00
parent cec0dd19d0
commit 61529b136e
12 changed files with 61 additions and 53 deletions

View File

@ -339,3 +339,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);
}

View File

@ -26,6 +26,7 @@
class MathInset;
class MathMacro;
class Painter;
class LaTeXFeatures;
#ifdef __GNUG__
#pragma interface
@ -116,6 +117,8 @@ public:
void Write(std::ostream &, bool) const;
///
void WriteNormal(std::ostream &) const;
///
void Validate(LaTeXFeatures &) const;
private:
///
typedef std::vector<unsigned char> buffer_type;

View File

@ -123,6 +123,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
{
int x = int(xx) - 1;
y -= 2;
MathInset::workwidth = bv->workWidth();
Painter & pain = bv->painter();
@ -130,10 +131,9 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
int w = par()->width();
int h = par()->height();
int a = par()->ascent();
pain.fillRectangle(int(x), y - a, w, h, LColor::mathbg);
pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
if (mathcursor) {
if (mathcursor->formula() == this) {
if (mathcursor && mathcursor->formula() == this) {
if (mathcursor->Selection()) {
int xp[10];
int yp[10];
@ -141,11 +141,10 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
mathcursor->SelGetArea(xp, yp, n);
pain.fillPolygon(xp, yp, n, LColor::selection);
}
pain.rectangle(int(x), y - a, w, h, LColor::mathframe);
}
pain.rectangle(x, y - a, w, h, LColor::mathframe);
}
par()->draw(pain, int(x), y);
par()->draw(pain, x, y);
xx += par()->width();
setCursorVisible(false);

View File

@ -573,14 +573,14 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
break;
case LFUN_BACKSPACE:
if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) {
// if (!mathcursor->InMacroMode() && mathcursor->pos() == 0)
if (mathcursor->pos() == 0) {
bv->lockedInsetStoreUndo(Undo::DELETE);
mathcursor->pullArg();
bv->updateInset(this, true);
break;
}
if (!mathcursor->Left())
break;
mathcursor->plainLeft();
// fall through...
case LFUN_DELETE:

View File

@ -153,6 +153,11 @@ bool MathCursor::isInside(MathInset * p) const
}
bool MathCursor::plainLeft()
{
return array().prev(cursor_);
}
bool MathCursor::Left(bool sel)
{
dump("Left 1");
@ -165,8 +170,8 @@ bool MathCursor::Left(bool sel)
MacroModeClose();
return true;
}
clearLastCode();
SelHandle(sel);
clearLastCode();
bool result = false;
@ -214,9 +219,8 @@ bool MathCursor::Right(bool sel)
MacroModeClose();
return true;
}
clearLastCode();
SelHandle(sel);
clearLastCode();
bool result = false;
@ -322,9 +326,8 @@ void MathCursor::Home()
if (macro_mode)
MacroModeClose();
clearLastCode();
if (!par_->idxHome(idx_, cursor_)) {
if (!par_->idxHome(idx_, cursor_))
pop();
}
dump("Home 2");
}

View File

@ -56,6 +56,8 @@ public:
/// Put the cursor in the last position
void last();
///
bool plainLeft();
///
bool plainRight();
///
void Delete();

View File

@ -357,3 +357,9 @@ bool MathInset::covers(int x, int y) const
y >= yo_ - ascent_ &&
y <= yo_ + descent_;
}
void MathInset::Validate(LaTeXFeatures & features) const
{
for (int i = 0; i < nargs(); ++i)
cell(i).Validate(features);
}

View File

@ -39,6 +39,8 @@
*/
class LaTeXFeatures;
class MathInset {
public:
/** A math inset has a name (usually its LaTeX name),
@ -187,6 +189,8 @@ public:
void dump() const;
///
void Validate(LaTeXFeatures & features) const;
///
static int workwidth;
protected:

View File

@ -28,6 +28,7 @@
#include "math_macrotable.h"
#include "math_macrotemplate.h"
#include "Painter.h"
#include "LaTeXFeatures.h"
using std::endl;
@ -183,3 +184,11 @@ bool MathMacro::idxRight(int &, int &) const
{
return false;
}
void MathMacro::Validate(LaTeXFeatures & features) const
{
if (name_ == "binom")
features.binom = true;
MathInset::Validate(features);
}

View File

@ -62,6 +62,9 @@ public:
///
bool idxRight(int &, int &) const;
///
void Validate(LaTeXFeatures &) const;
private:
///
MathMacroTemplate const * const tmplate_;

View File

@ -221,7 +221,7 @@ bool MathMatrixInset::numberedType() const
}
void MathMatrixInset::Validate(LaTeXFeatures & features)
void MathMatrixInset::Validate(LaTeXFeatures & features) const
{
features.amsstyle = ams();
@ -230,40 +230,11 @@ void MathMatrixInset::Validate(LaTeXFeatures & features)
//if (features.amsstyle)
// return;
//Validate1(features);
features.boldsymbol = true;
features.binom = true;
}
//features.binom = true;
/*
void MathMatrixInset::Validate1(LaTeXFeatures & features)
{
MathIter it(cell());
while (it.OK() && !(features.binom && features.boldsymbol)) {
MathInset * p = it.nextInset();
if (p) {
p = it.GetActiveInset();
if (p) {
if (!features.binom && p->GetType() == LM_OT_MACRO &&
p->name() == "binom") {
features.binom = true;
} else {
for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) {
p->setArgumentIdx(i);
Validate1(features, p);
MathInset::Validate(features);
}
}
} else {
if (!features.boldsymbol && p->name() == "boldsymbol")
features.boldsymbol = true;
}
}
it.Next();
}
}
*/
void MathMatrixInset::header_write(std::ostream & os) const

View File

@ -49,7 +49,7 @@ public:
///
std::vector<string> const getLabelList() const;
///
void Validate(LaTeXFeatures & features);
void Validate(LaTeXFeatures & features) const;
///
void addRow(int);