more lfun shuffling

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4972 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-14 16:43:16 +00:00
parent 69a1e730ae
commit f84e3d1296
7 changed files with 86 additions and 131 deletions

View File

@ -271,16 +271,6 @@ InsetFormula::localDispatch(FuncRequest const & ev)
break;
}
case LFUN_MATH_EXTERN:
{
bv->lockedInsetStoreUndo(Undo::EDIT);
if (mathcursor)
mathcursor->handleExtern(ev.argument);
// re-compute inset dimension
metrics(bv);
updateLocal(bv, true);
break;
}
case LFUN_MATH_DISPLAY:
{
@ -319,19 +309,6 @@ bool InsetFormula::display() const
}
MathHullInset const * InsetFormula::hull() const
{
lyx::Assert(par_->asHullInset());
return par_->asHullInset();
}
MathHullInset * InsetFormula::hull()
{
lyx::Assert(par_->asHullInset());
return par_.nucleus()->asHullInset();
}
Inset::Code InsetFormula::lyxCode() const
{
return Inset::MATH_CODE;

View File

@ -93,12 +93,6 @@ private:
bool display() const;
/// available in AMS only?
bool ams() const;
/// access to hull
MathHullInset const * hull() const;
/// access to hull
MathHullInset * hull();
///
void handleExtern(string const & arg);
/// contents
MathAtom par_;

View File

@ -428,6 +428,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
case LFUN_BREAKLINE:
case LFUN_DELETE_LINE_FORWARD:
case LFUN_INSERT_LABEL:
case LFUN_MATH_EXTERN:
bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->dispatch(ev);
updateLocal(bv, true);

View File

@ -750,19 +750,6 @@ MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
}
MathHullInset * MathCursor::enclosingHull(MathCursor::idx_type & idx) const
{
for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
MathHullInset * p = Cursor_[i].par_->asHullInset();
if (p) {
idx = Cursor_[i].idx_;
return p;
}
}
return 0;
}
void MathCursor::popToHere(MathInset const * p)
{
while (depth() && Cursor_.back().par_ != p)
@ -1077,14 +1064,6 @@ bool MathCursor::bruteFind
}
bool MathCursor::idxLineFirst()
{
idx() -= idx() % par()->ncols();
pos() = 0;
return true;
}
bool MathCursor::idxLineLast()
{
idx() -= idx() % par()->ncols();
@ -1514,82 +1493,6 @@ MathCursorPos MathCursor::normalAnchor() const
}
void MathCursor::handleExtern(const string & arg)
{
string lang;
string extra;
istringstream iss(arg.c_str());
iss >> lang >> extra;
if (extra.empty())
extra = "noextra";
if (selection()) {
MathArray ar;
selGet(ar);
lyxerr << "use selection: " << ar << "\n";
insert(pipeThroughExtern(lang, extra, ar));
return;
}
MathArray eq;
eq.push_back(MathAtom(new MathCharInset('=')));
popToEnclosingHull();
idx_type idx = 0;
MathHullInset * hull = enclosingHull(idx);
lyx::Assert(hull);
idxLineFirst();
if (hull->getType() == "simple") {
MathArray::size_type pos = cursor().cell().find_last(eq);
MathArray ar;
if (pos == size()) {
ar = array();
lyxerr << "use whole cell: " << ar << "\n";
} else {
ar = MathArray(array().begin() + pos + 1, array().end());
lyxerr << "use partial cell form pos: " << pos << "\n";
}
end();
insert(eq);
insert(pipeThroughExtern(lang, extra, ar));
return;
}
if (hull->getType() == "equation") {
lyxerr << "use equation inset\n";
hull->mutate("eqnarray");
MathArray & ar = cursor().cell();
lyxerr << "use cell: " << ar << "\n";
idxRight();
cursor().cell() = eq;
idxRight();
cursor().cell() = pipeThroughExtern(lang, extra, ar);
idxLineLast();
return;
}
{
lyxerr << "use eqnarray\n";
idxLineLast();
MathArray ar = cursor().cell();
lyxerr << "use cell: " << ar << "\n";
#ifdef WITH_WARNINGS
#warning temporarily disabled
#endif
//breakLine();
//idxRight();
cursor().cell() = eq;
//idxRight();
cursor().cell() = pipeThroughExtern(lang, extra, ar);
idxLineLast();
}
}
MathInset::result_type MathCursor::dispatch(FuncRequest const & cmd)
{
// try to dispatch to adajcent items if they are not editable

View File

@ -107,8 +107,6 @@ public:
MathInset * par() const;
/// return the next enclosing grid inset and the cursor's index in it
MathGridInset * enclosingGrid(idx_type & idx) const;
/// return the next enclosing hull inset and the cursor's index in it
MathHullInset * enclosingHull(idx_type & idx) const;
/// go up to enclosing grid
void popToEnclosingGrid();
/// go up to the hull inset
@ -243,7 +241,7 @@ public:
/// hack for reveal codes
void markInsert();
void markErase();
void handleExtern(string const & arg);
//void handleExtern(string const & arg);
///
friend class Selection;
@ -256,8 +254,6 @@ private:
bool idxLeft();
/// moves cursor index one cell to the right
bool idxRight();
/// moves cursor to beginning first cell of current line
bool idxLineFirst();
/// moves cursor to end of last cell of current line
bool idxLineLast();
/// moves cursor position one cell to the left

View File

@ -8,6 +8,8 @@
#include "math_mathmlstream.h"
#include "math_streamstr.h"
#include "math_support.h"
#include "math_extern.h"
#include "math_charinset.h"
#include "debug.h"
#include "textpainter.h"
#include "funcrequest.h"
@ -653,6 +655,82 @@ void MathHullInset::check() const
}
void MathHullInset::doExtern
(FuncRequest const & func, idx_type & idx, pos_type & pos)
{
string lang;
string extra;
istringstream iss(func.argument.c_str());
iss >> lang >> extra;
if (extra.empty())
extra = "noextra";
#ifdef WITH_WARNINGS
#warning temporarily disabled
//if (selection()) {
// MathArray ar;
// selGet(ar);
// lyxerr << "use selection: " << ar << "\n";
// insert(pipeThroughExtern(lang, extra, ar));
// return;
//}
#endif
MathArray eq;
eq.push_back(MathAtom(new MathCharInset('=')));
// go to first item in line
idx -= idx % ncols();
pos = 0;
if (getType() == "simple") {
size_type pos = cell(idx).find_last(eq);
MathArray ar;
if (pos == cell(idx).size()) {
ar = cell(idx);
lyxerr << "use whole cell: " << ar << "\n";
} else {
ar = MathArray(cell(idx).begin() + pos + 1, cell(idx).end());
lyxerr << "use partial cell form pos: " << pos << "\n";
}
cell(idx).append(eq);
cell(idx).append(pipeThroughExtern(lang, extra, ar));
pos = cell(idx).size();
return;
}
if (getType() == "equation") {
lyxerr << "use equation inset\n";
mutate("eqnarray");
MathArray & ar = cell(idx);
lyxerr << "use cell: " << ar << "\n";
cell(idx + 1) = eq;
cell(idx + 2) = pipeThroughExtern(lang, extra, ar);
// move to end of line
idx += 2;
pos = cell(idx).size();
return;
}
{
lyxerr << "use eqnarray\n";
idx -= idx % ncols();
idx += 2;
pos = 0;
MathArray ar = cell(idx);
lyxerr << "use cell: " << ar << "\n";
#ifdef WITH_WARNINGS
#warning temporarily disabled
#endif
addRow(row(idx));
cell(idx + 2) = eq;
cell(idx + 3) = pipeThroughExtern(lang, extra, ar);
idx += 3;
pos = cell(idx).size();
}
}
MathInset::result_type MathHullInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
@ -726,6 +804,10 @@ MathInset::result_type MathHullInset::dispatch
// we explicitly don't want the default behaviour here
return UNDISPATCHED;
case LFUN_MATH_EXTERN:
doExtern(cmd, idx, pos);
return DISPATCHED_POP;
default:
return MathGridInset::dispatch(cmd, idx, pos);

View File

@ -101,6 +101,8 @@ private:
///
string nicelabel(row_type row) const;
///
void doExtern(FuncRequest const & func, idx_type & idx, pos_type & pos);
///
void glueall();
///
char const * standardFont() const;