fix crash due to invalid cursor position after deleting more than one cell

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2925 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-10-23 13:48:52 +00:00
parent 229ddc5929
commit 616955adb2
3 changed files with 66 additions and 1 deletions

View File

@ -315,7 +315,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
return result;
}
#if 0
void InsetFormula::handleExtern(const string & arg)
{
// where are we?
@ -357,7 +357,54 @@ void InsetFormula::handleExtern(const string & arg)
mathed_parse_cell(ar, is);
mathcursor->end();
}
#endif
void InsetFormula::handleExtern(const string & arg)
{
// where are we?
if (!mathcursor)
return;
MathArray ar;
if (mathcursor->selection())
mathcursor->selGet(ar);
else
ar = mathcursor->cursor().cell();
// parse args
string lang;
string extra;
istringstream iss(arg.c_str());
iss >> lang >> extra;
if (extra.empty())
extra = "noextra";
// strip last '=' and everything behind
stripFromLastEqualSign(ar);
// create normalized expression
//string outfile = lyx::tempName("maple.out");
string outfile = "/tmp/lyx2" + lang + ".out";
ostringstream os;
os << "[" << extra << ' ';
ar.writeNormal(os);
os << "]";
string code = os.str().c_str();
// run external sript
string script = "lyx2" + arg + " '" + code + "' " + outfile;
lyxerr << "calling: " << script << endl;
Systemcalls cmd(Systemcalls::System, script, 0);
// append a '='
//ar.push_back(MathAtom(new MathCharInset('=')));
// append result
MathArray br;
ifstream is(outfile.c_str());
mathed_parse_cell(br, is);
mathcursor->insert(br);
}
bool InsetFormula::display() const
{

View File

@ -557,6 +557,9 @@ void MathCursor::delLine()
if (par()->nrows() > 1)
par()->delRow(row());
if (pos() > size())
pos() = size();
}
@ -699,6 +702,7 @@ void MathCursor::selDel()
seldump("selDel");
if (selection_) {
theSelection.erase(*this);
pos() = 0;
selClear();
}
}
@ -743,6 +747,18 @@ void MathCursor::selClear()
}
void MathCursor::selGet(MathArray & ar)
{
seldump("selGet");
if (selection_)
return;
theSelection.grab(*this);
ar = theSelection.glue();
}
void MathCursor::drawSelection(Painter & pain) const
{
if (!selection_)

View File

@ -165,6 +165,8 @@ public:
///
void selClear();
///
void selGet(MathArray & ar);
///
void drawSelection(Painter & pain) const;
///
void handleFont(MathTextCodes t);