fix the fix

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4399 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
José Matox 2002-06-14 10:48:27 +00:00
parent e89ed285ad
commit cfa1446531
5 changed files with 72 additions and 25 deletions

View File

@ -185,10 +185,10 @@ Selection theSelection;
}
MathCursor::MathCursor(InsetFormulaBase * formula, bool left)
MathCursor::MathCursor(InsetFormulaBase * formula, bool front)
: formula_(formula), autocorrect_(false), selection_(false)
{
left ? first() : last();
front ? first() : last();
}
@ -268,6 +268,9 @@ bool MathCursor::openable(MathAtom const & t, bool sel) const
if (!t->isActive())
return false;
if (t->lock())
return false;
if (t->asScriptInset())
return false;
@ -304,7 +307,7 @@ bool MathCursor::left(bool sel)
{
dump("Left 1");
autocorrect_ = false;
targetx_ = false;
targetx_ = -1; // "no target"
if (inMacroMode()) {
macroModeClose();
return true;
@ -324,7 +327,7 @@ bool MathCursor::right(bool sel)
{
dump("Right 1");
autocorrect_ = false;
targetx_ = false;
targetx_ = -1; // "no target"
if (inMacroMode()) {
macroModeClose();
return true;
@ -343,14 +346,16 @@ bool MathCursor::right(bool sel)
void MathCursor::first()
{
Cursor_.clear();
pushLeft(formula_->par());
push(formula_->par());
par()->idxFirst(idx(), pos());
}
void MathCursor::last()
{
first();
end();
Cursor_.clear();
push(formula_->par());
par()->idxLast(idx(), pos());
}
@ -465,10 +470,11 @@ void MathCursor::niceInsert(MathAtom const & t)
{
selCut();
insert(t); // inserting invalidates the pointer!
MathAtom const & p = prevAtom();
if (p->nargs()) {
posLeft();
right(); // do not push for e.g. MathSymbolInset
MathAtom & p = prevAtom();
// enter the new inset and move the contents of the selection if possible
if (p->isActive()) {
push(p);
par()->idxLast(idx(), pos());
selPaste();
}
}
@ -1175,10 +1181,10 @@ bool MathCursor::goUpDown(bool up)
getPos(xo, yo);
// check if we had something else in mind, if not, this is the future goal
if (targetx_)
xo = targetx_;
else
if (targetx_ == -1)
targetx_ = xo;
else
xo = targetx_;
// try neigbouring script insets
// try left
@ -1423,7 +1429,7 @@ bool MathCursor::inMathMode() const
bool MathCursor::interpret(char c)
{
//lyxerr << "interpret 2: '" << c << "'\n";
targetx_ = false;
targetx_ = -1; // "no target"
if (inMacroArgMode()) {
--pos();
plainErase();

View File

@ -41,6 +41,7 @@ void MathFontInset::metrics(MathMetricsInfo & mi) const
void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
{
//lyxerr << "MathFontInset::draw\n";
MathNestInset::draw(pi, x, y);
MathFontSetChanger dummy(pi.base, name_.c_str());
xcell(0).draw(pi, x, y);
}

View File

@ -6,6 +6,7 @@
#include "math_cursor.h"
#include "math_mathmlstream.h"
#include "debug.h"
#include "frontends/Painter.h"
MathNestInset::MathNestInset(idx_type nargs)
@ -144,6 +145,17 @@ void MathNestInset::dump() const
}
void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const
{
lyxerr << "MathNestInset::draw()\n";
if (lock_) {
lyxerr << "MathNestInset::draw background\n";
pi.pain.fillRectangle(x, y - ascent(), width(), height(),
LColor::mathlockbg);
}
}
void MathNestInset::validate(LaTeXFeatures & features) const
{
for (idx_type i = 0; i < nargs(); ++i)
@ -198,5 +210,5 @@ void MathNestInset::lock(bool l)
bool MathNestInset::isActive() const
{
return !lock_ && nargs() > 0;
return nargs() > 0;
}

View File

@ -9,7 +9,7 @@
/** Abstract base class for all math objects that contain nested items.
This is basically everything that is not a single character or a
single symbol
single symbol.
*/
@ -21,7 +21,9 @@ public:
explicit MathNestInset(idx_type ncells);
/// the size is usuall some sort of convex hull of the cells
void metrics(MathMetricsInfo const & st) const;
void metrics(MathMetricsInfo const & mi) const;
/// draw background if locked
void draw(MathPainterInfo & pi, int x, int y) const;
/// appends itself with macro arguments substituted
void substitute(MathMacro const & macro);
/// identifies NestInsets
@ -77,7 +79,7 @@ public:
/// debug helper
void dump() const;
///
/// is the cursor currently somewhere within this inset?
virtual bool editing() const;
protected:
@ -85,7 +87,7 @@ protected:
typedef std::vector<MathXArray> cells_type;
/// thusly:
cells_type cells_;
/// if the inset is locked, it can't be enter with the cursor
/// if the inset is locked, it can't be entered with the cursor
bool lock_;
};

View File

@ -8,6 +8,8 @@
#include "graphics/GraphicsTypes.h"
#include "graphics/GraphicsImage.h"
#include "graphics/GraphicsImageXPM.h"
#include "graphics/GraphicsCacheItem.h"
#include "graphics/GraphicsCache.h"
#include <fstream>
#include <map>
@ -23,14 +25,34 @@ namespace {
// cache for computed previews
previews_map thePreviews;
// cache for scedule previews
// cache for scheduled previews
vector<string> theSchedule;
}
void imageLoaded()
{
}
#if 0
class PreviewCallbackLoaded {
public:
///
PreviewCallbackLoaded(string const & filename)
: image_(grfx::GImageXPM::newImage())
{
lyxerr[Debug::GRAPHICS] << "Loading image." << endl;
grfx::GImage::SignalTypePtr s(new grfx::GImage::SignalType(&PreviewCallbackLoaded::imageLoaded));
image_->load(filename, s);
}
///
void imageLoaded(bool result)
{
lyxerr << "Image loaded with result: " << result << endl;
}
grfx::ImagePtr image_;
};
#endif
grfx::ImagePtr preview(string const & str)
@ -41,7 +63,7 @@ grfx::ImagePtr preview(string const & str)
return it->second;
// constructing new item
grfx::ImagePtr & im = thePreviews[str];
//grfx::ImagePtr & im = thePreviews[str];
lyxerr << "writing: " << str << endl;
std::ofstream of("/tmp/previewlyx.tex");
@ -61,6 +83,9 @@ grfx::ImagePtr preview(string const & str)
sc2.startscript(Systemcall::Wait,
"(cd /tmp ; convert previewlyx.ps previewlyx.xpm)");
//PreviewCallbackLoaded cb("/tmp/previewlyx.xpm");
#if 0
//grfx::SignalLoadTypePtr on_finish;
//on_finish.reset(new SignalLoadType);
//on_finish->connect(SigC::slot(this, &imageLoaded));
@ -102,5 +127,6 @@ grfx::ImagePtr preview(string const & str)
}
return im;
#endif
}