remove unneded math specific stuff, use altered notifyCursorLeave

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8608 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-04-05 16:44:10 +00:00
parent 03b6d27f47
commit d473dff417
3 changed files with 14 additions and 55 deletions

View File

@ -1,3 +1,8 @@
2004-04-05 André Pönitz <poenitz@gmx.net>
* cursor.[Ch] (valign, halign...): remove unneeded functions
2004-04-05 Angus Leeming <leeming@lyx.org> 2004-04-05 Angus Leeming <leeming@lyx.org>
* lyxlength.[Ch] (unit_name et al.): const-correct. * lyxlength.[Ch] (unit_name et al.): const-correct.

View File

@ -203,7 +203,7 @@ bool LCursor::popLeft()
{ {
BOOST_ASSERT(!empty()); BOOST_ASSERT(!empty());
//lyxerr << "Leaving inset to the left" << endl; //lyxerr << "Leaving inset to the left" << endl;
inset().notifyCursorLeaves(idx()); inset().notifyCursorLeaves(*this);
if (depth() == 1) if (depth() == 1)
return false; return false;
pop(); pop();
@ -215,7 +215,7 @@ bool LCursor::popRight()
{ {
BOOST_ASSERT(!empty()); BOOST_ASSERT(!empty());
//lyxerr << "Leaving inset to the right" << endl; //lyxerr << "Leaving inset to the right" << endl;
inset().notifyCursorLeaves(idx()); inset().notifyCursorLeaves(*this);
if (depth() == 1) if (depth() == 1)
return false; return false;
pop(); pop();
@ -593,7 +593,6 @@ std::ostream & operator<<(std::ostream & os, LCursor const & cur)
#include "mathed/math_factory.h" #include "mathed/math_factory.h"
#include "mathed/math_gridinset.h" #include "mathed/math_gridinset.h"
#include "mathed/math_macroarg.h" #include "mathed/math_macroarg.h"
#include "mathed/math_macrotemplate.h"
#include "mathed/math_mathmlstream.h" #include "mathed/math_mathmlstream.h"
#include "mathed/math_scriptinset.h" #include "mathed/math_scriptinset.h"
#include "mathed/math_support.h" #include "mathed/math_support.h"
@ -665,7 +664,7 @@ void LCursor::plainErase()
void LCursor::markInsert() void LCursor::markInsert()
{ {
cell().insert(pos(), MathAtom(new MathCharInset(0))); insert(char(0));
} }
@ -684,7 +683,7 @@ void LCursor::plainInsert(MathAtom const & t)
void LCursor::insert(string const & str) void LCursor::insert(string const & str)
{ {
lyxerr << "LCursor::insert str '" << str << "'" << endl; //lyxerr << "LCursor::insert str '" << str << "'" << endl;
for (string::const_iterator it = str.begin(); it != str.end(); ++it) for (string::const_iterator it = str.begin(); it != str.end(); ++it)
insert(*it); insert(*it);
} }
@ -696,7 +695,7 @@ void LCursor::insert(char c)
BOOST_ASSERT(!empty()); BOOST_ASSERT(!empty());
if (inMathed()) { if (inMathed()) {
selClearOrDel(); selClearOrDel();
plainInsert(MathAtom(new MathCharInset(c))); insert(new MathCharInset(c));
} else { } else {
text()->insertChar(*this, c); text()->insertChar(*this, c);
} }
@ -709,6 +708,7 @@ void LCursor::insert(MathAtom const & t)
macroModeClose(); macroModeClose();
selClearOrDel(); selClearOrDel();
plainInsert(t); plainInsert(t);
lyxerr << "LCursor::insert MathAtom: cur:\n" << *this << endl;
} }
@ -785,6 +785,7 @@ bool LCursor::backspace()
if (pos() != 0 && prevAtom()->nargs() > 0) { if (pos() != 0 && prevAtom()->nargs() > 0) {
// let's require two backspaces for 'big stuff' and // let's require two backspaces for 'big stuff' and
// highlight on the first // highlight on the first
resetAnchor();
selection() = true; selection() = true;
--pos(); --pos();
} else { } else {
@ -823,7 +824,9 @@ bool LCursor::erase()
return true; return true;
} }
// 'clever' UI hack: only erase large items if previously slected
if (pos() != lastpos() && inset().nargs() > 0) { if (pos() != lastpos() && inset().nargs() > 0) {
resetAnchor();
selection() = true; selection() = true;
++pos(); ++pos();
} else { } else {
@ -938,28 +941,6 @@ MathUnknownInset * LCursor::activeMacro()
} }
bool LCursor::inMacroArgMode() const
{
return pos() > 0 && prevAtom()->getChar() == '#';
}
MathGridInset * LCursor::enclosingGrid(idx_type & idx) const
{
for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
MathInset * m = operator[](i).inset().asMathInset();
if (!m)
return 0;
MathGridInset * p = m->asGridInset();
if (p) {
idx = operator[](i).idx();
return p;
}
}
return 0;
}
void LCursor::pullArg() void LCursor::pullArg()
{ {
#ifdef WITH_WARNINGS #ifdef WITH_WARNINGS
@ -1011,22 +992,6 @@ void LCursor::normalize()
} }
char LCursor::valign()
{
idx_type idx;
MathGridInset * p = enclosingGrid(idx);
return p ? p->valign() : '\0';
}
char LCursor::halign()
{
idx_type idx;
MathGridInset * p = enclosingGrid(idx);
return p ? p->halign(idx % p->ncols()) : '\0';
}
bool LCursor::goUpDown(bool up) bool LCursor::goUpDown(bool up)
{ {
// Be warned: The 'logic' implemented in this function is highly // Be warned: The 'logic' implemented in this function is highly

View File

@ -24,7 +24,6 @@ class FuncRequest;
// these should go // these should go
class MathUnknownInset; class MathUnknownInset;
class MathGridInset;
class Encoding; class Encoding;
@ -250,8 +249,6 @@ public:
void setScreenPos(int x, int y); void setScreenPos(int x, int y);
/// in pixels from left of screen /// in pixels from left of screen
int targetX() const; int targetX() const;
/// return the next enclosing grid inset and the cursor's index in it
MathGridInset * enclosingGrid(idx_type & idx) const;
/// adjust anchor position after deletions/insertions /// adjust anchor position after deletions/insertions
void adjust(pos_type from, int diff); void adjust(pos_type from, int diff);
/// current offset in the top cell /// current offset in the top cell
@ -261,20 +258,12 @@ public:
bool inMacroMode() const; bool inMacroMode() const;
/// get access to the macro we are currently typing /// get access to the macro we are currently typing
MathUnknownInset * activeMacro(); MathUnknownInset * activeMacro();
/// are we currently typing '#1' or '#2' or...?
bool inMacroArgMode() const;
/// replace selected stuff with at, placing the former /// replace selected stuff with at, placing the former
// selection in given cell of atom // selection in given cell of atom
void handleNest(MathAtom const & at, int cell = 0); void handleNest(MathAtom const & at, int cell = 0);
/// remove this as soon as LyXFunc::getStatus is "localized"
//inline std::string getLastCode() { return "mathnormal"; }
/// ///
bool isInside(InsetBase const *); bool isInside(InsetBase const *);
///
char valign();
///
char halign();
/// make sure cursor position is valid /// make sure cursor position is valid
void normalize(); void normalize();