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); 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 MathInset;
class MathMacro; class MathMacro;
class Painter; class Painter;
class LaTeXFeatures;
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
@ -116,6 +117,8 @@ public:
void Write(std::ostream &, bool) const; void Write(std::ostream &, bool) const;
/// ///
void WriteNormal(std::ostream &) const; void WriteNormal(std::ostream &) const;
///
void Validate(LaTeXFeatures &) const;
private: private:
/// ///
typedef std::vector<unsigned char> buffer_type; 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; int x = int(xx) - 1;
y -= 2; y -= 2;
MathInset::workwidth = bv->workWidth(); MathInset::workwidth = bv->workWidth();
Painter & pain = bv->painter(); Painter & pain = bv->painter();
@ -130,22 +131,20 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &,
int w = par()->width(); int w = par()->width();
int h = par()->height(); int h = par()->height();
int a = par()->ascent(); 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 && mathcursor->formula() == this) {
if (mathcursor->formula() == this) { if (mathcursor->Selection()) {
if (mathcursor->Selection()) { int xp[10];
int xp[10]; int yp[10];
int yp[10]; int n;
int n; mathcursor->SelGetArea(xp, yp, n);
mathcursor->SelGetArea(xp, yp, n); pain.fillPolygon(xp, yp, n, LColor::selection);
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(); xx += par()->width();
setCursorVisible(false); setCursorVisible(false);

View File

@ -573,14 +573,14 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
break; break;
case LFUN_BACKSPACE: case LFUN_BACKSPACE:
if (!mathcursor->InMacroMode() && mathcursor->pos() == 0) { // if (!mathcursor->InMacroMode() && mathcursor->pos() == 0)
if (mathcursor->pos() == 0) {
bv->lockedInsetStoreUndo(Undo::DELETE); bv->lockedInsetStoreUndo(Undo::DELETE);
mathcursor->pullArg(); mathcursor->pullArg();
bv->updateInset(this, true); bv->updateInset(this, true);
break; break;
} }
if (!mathcursor->Left()) mathcursor->plainLeft();
break;
// fall through... // fall through...
case LFUN_DELETE: 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) bool MathCursor::Left(bool sel)
{ {
dump("Left 1"); dump("Left 1");
@ -165,8 +170,8 @@ bool MathCursor::Left(bool sel)
MacroModeClose(); MacroModeClose();
return true; return true;
} }
clearLastCode();
SelHandle(sel); SelHandle(sel);
clearLastCode();
bool result = false; bool result = false;
@ -214,9 +219,8 @@ bool MathCursor::Right(bool sel)
MacroModeClose(); MacroModeClose();
return true; return true;
} }
clearLastCode();
SelHandle(sel); SelHandle(sel);
clearLastCode();
bool result = false; bool result = false;
@ -322,9 +326,8 @@ void MathCursor::Home()
if (macro_mode) if (macro_mode)
MacroModeClose(); MacroModeClose();
clearLastCode(); clearLastCode();
if (!par_->idxHome(idx_, cursor_)) { if (!par_->idxHome(idx_, cursor_))
pop(); pop();
}
dump("Home 2"); dump("Home 2");
} }

View File

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

View File

@ -357,3 +357,9 @@ bool MathInset::covers(int x, int y) const
y >= yo_ - ascent_ && y >= yo_ - ascent_ &&
y <= yo_ + descent_; 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 { class MathInset {
public: public:
/** A math inset has a name (usually its LaTeX name), /** A math inset has a name (usually its LaTeX name),
@ -187,6 +189,8 @@ public:
void dump() const; void dump() const;
/// ///
void Validate(LaTeXFeatures & features) const;
/// ///
static int workwidth; static int workwidth;
protected: protected:

View File

@ -28,6 +28,7 @@
#include "math_macrotable.h" #include "math_macrotable.h"
#include "math_macrotemplate.h" #include "math_macrotemplate.h"
#include "Painter.h" #include "Painter.h"
#include "LaTeXFeatures.h"
using std::endl; using std::endl;
@ -183,3 +184,11 @@ bool MathMacro::idxRight(int &, int &) const
{ {
return false; 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; bool idxRight(int &, int &) const;
///
void Validate(LaTeXFeatures &) const;
private: private:
/// ///
MathMacroTemplate const * const tmplate_; 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(); features.amsstyle = ams();
@ -230,40 +230,11 @@ void MathMatrixInset::Validate(LaTeXFeatures & features)
//if (features.amsstyle) //if (features.amsstyle)
// return; // return;
//Validate1(features);
features.boldsymbol = true; features.boldsymbol = true;
features.binom = true; //features.binom = true;
}
/* MathInset::Validate(features);
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);
}
}
} else {
if (!features.boldsymbol && p->name() == "boldsymbol")
features.boldsymbol = true;
}
}
it.Next();
}
} }
*/
void MathMatrixInset::header_write(std::ostream & os) const void MathMatrixInset::header_write(std::ostream & os) const

View File

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