save inset lock state in the .lyx file

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4828 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-01 15:53:46 +00:00
parent f7d8239dae
commit a92d23883e
17 changed files with 66 additions and 37 deletions

View File

@ -1500,7 +1500,7 @@ void MathCursor::setSelection(MathIterator const & where, size_type n)
void MathCursor::insetToggle()
{
if (hasNextAtom()) {
// toggle next inset ...
// toggle previous inset ...
nextAtom()->lock(!nextAtom()->lock());
} else if (popLeft() && hasNextAtom()) {
// ... or enclosing inset if we are in the last inset position

View File

@ -18,9 +18,7 @@
MathFontInset::MathFontInset(latexkeys const * key)
: MathNestInset(1), key_(key)
{
//lock(true);
}
{}
MathInset * MathFontInset::clone() const
@ -70,15 +68,9 @@ void MathFontInset::drawT(TextPainter & pain, int x, int y) const
}
void MathFontInset::write(WriteStream & os) const
string MathFontInset::name() const
{
os << '\\' << key_->name << '{' << cell(0) << '}';
}
void MathFontInset::normalize(NormalStream & os) const
{
os << "[font " << key_->name << " " << cell(0) << "]";
return key_->name;
}

View File

@ -23,6 +23,8 @@ public:
/// are we in math mode, text mode, or unsure?
mode_type currentMode() const;
///
string name() const;
///
void metrics(MathMetricsInfo & mi) const;
///
void draw(MathPainterInfo & pi, int x, int y) const;
@ -31,10 +33,6 @@ public:
///
void drawT(TextPainter & pi, int x, int y) const;
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
///
void validate(LaTeXFeatures & features) const;
///
void infoize(std::ostream & os) const;

View File

@ -75,30 +75,29 @@ void MathFracInset::write(WriteStream & os) const
{
if (atop_)
os << '{' << cell(0) << "\\atop " << cell(1) << '}';
else
os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
else // it's \\frac
MathNestInset::write(os);
}
void MathFracInset::normalize(NormalStream & os) const
string MathFracInset::name() const
{
if (atop_)
os << "[atop ";
else
os << "[frac ";
os << cell(0) << ' ' << cell(1) << ']';
return atop_ ? "atop" : "frac";
}
void MathFracInset::maplize(MapleStream & os) const
{
os << '(' << cell(0) << ")/(" << cell(1) << ')';
}
void MathFracInset::mathematicize(MathematicaStream & os) const
{
os << '(' << cell(0) << ")/(" << cell(1) << ')';
}
void MathFracInset::octavize(OctaveStream & os) const
{
os << '(' << cell(0) << ")/(" << cell(1) << ')';

View File

@ -27,12 +27,12 @@ public:
void drawT(TextPainter &, int x, int y) const;
///
MathFracInset * asFracInset();
///
string name() const;
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
///
void maplize(MapleStream &) const;
///
void mathematicize(MathematicaStream &) const;

View File

@ -319,6 +319,12 @@ string const & MathInset::getType() const
}
string MathInset::name() const
{
return "unknown";
}
string asString(MathArray const & ar)
{
std::ostringstream os;

View File

@ -291,6 +291,8 @@ public:
virtual void mutate(string const &) {}
/// how is the inset called in the .lyx file?
virtual string fileInsetLabel() const { return "Formula"; }
/// usually the latex name
virtual string name() const;
};
std::ostream & operator<<(std::ostream &, MathInset const &);

View File

@ -53,7 +53,7 @@ MathInset * MathMacro::clone() const
}
string const & MathMacro::name() const
string MathMacro::name() const
{
return tmplate_->asMacroTemplate()->name();
}

View File

@ -79,7 +79,7 @@ private:
///
void operator=(MathMacro const &);
///
string const & name() const;
string name() const;
///
bool defining() const;
///

View File

@ -59,7 +59,7 @@ void MathMacroTemplate::numargs(int numargs)
}
string const & MathMacroTemplate::name() const
string MathMacroTemplate::name() const
{
return name_;
}

View File

@ -34,7 +34,7 @@ public:
///
void numargs(int);
///
string const & name() const;
string name() const;
///
void draw(MathPainterInfo &, int x, int y) const;
///

View File

@ -302,6 +302,25 @@ MathArray MathNestInset::glue() const
}
void MathNestInset::write(WriteStream & os) const
{
os << '\\' << name().c_str();
for (unsigned i = 0; i < nargs(); ++i)
os << '{' << cell(i) << '}';
if (lock_ && !os.latex())
os << "\\lyxlock ";
}
void MathNestInset::normalize(NormalStream & os) const
{
os << '[' << name().c_str();
for (unsigned i = 0; i < nargs(); ++i)
os << ' ' << cell(i);
os << ']';
}
void MathNestInset::notifyCursorLeaves()
{
// Generate a preview only if previews are active and we are leaving

View File

@ -98,6 +98,11 @@ public:
/// is the cursor currently somewhere within this inset?
virtual bool editing() const;
/// writes \\, name(), and args in braces and '\\lyxlock' if necessary
void write(WriteStream & os) const;
/// writes [, name(), and args in []
void normalize(NormalStream & os) const;
protected:
/// we store the cells in a vector
typedef std::vector<MathXArray> cells_type;

View File

@ -675,6 +675,11 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
// control sequences
//
else if (t.cs() == "lyxlock") {
if (cell->size())
cell->back()->lock(true);
}
else if (t.cs() == "def" || t.cs() == "newcommand") {
string name;
int nargs = 0;

View File

@ -360,6 +360,9 @@ void MathScriptInset::write(WriteStream & os) const
if (hasUp() && up().size())
os << "^{" << up().data() << '}';
if (lock_ && !os.latex())
os << "\\lyxlock ";
}

View File

@ -21,15 +21,15 @@ MathInset * MathUnknownInset::clone() const
}
string const & MathUnknownInset::name() const
string MathUnknownInset::name() const
{
return name_;
}
string & MathUnknownInset::name()
void MathUnknownInset::setName(string const & name)
{
return name_;
name_ = name;
}

View File

@ -19,13 +19,13 @@ public:
///
MathInset * clone() const;
///
void metrics(MathMetricsInfo & st) const;
void metrics(MathMetricsInfo & mi) const;
///
void draw(MathPainterInfo &, int x, int y) const;
void draw(MathPainterInfo & pi, int x, int y) const;
///
string & name();
void setName(string const & name);
///
string const & name() const;
string name() const;
/// identifies UnknownInsets
MathUnknownInset const * asUnknownInset() const { return this; }
/// identifies UnknownInsets