mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
fix mathed crash
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8414 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fb7248979d
commit
67f9c9fdae
26
src/cursor.C
26
src/cursor.C
@ -253,6 +253,8 @@ void LCursor::getDim(int & asc, int & des) const
|
||||
{
|
||||
BOOST_ASSERT(!cursor_.empty());
|
||||
if (inMathed()) {
|
||||
BOOST_ASSERT(inset());
|
||||
BOOST_ASSERT(inset()->asMathInset());
|
||||
//inset()->asMathInset()->getCursorDim(asc, des);
|
||||
asc = 10;
|
||||
des = 10;
|
||||
@ -269,10 +271,14 @@ void LCursor::getPos(int & x, int & y) const
|
||||
BOOST_ASSERT(!cursor_.empty());
|
||||
x = 0;
|
||||
y = 0;
|
||||
if (cursor_.size() <= 1) {
|
||||
if (cursor_.size() == 1) {
|
||||
x = bv_->text()->cursorX(cursor_.front());
|
||||
y = bv_->text()->cursorY(cursor_.front());
|
||||
} else {
|
||||
if (!inset()) {
|
||||
lyxerr << "#### LCursor::getPos: " << *this << endl;
|
||||
BOOST_ASSERT(inset());
|
||||
}
|
||||
inset()->getCursorPos(cursor_.back(), x, y);
|
||||
// getCursorPos gives _screen_ coordinates. We need to add
|
||||
// top_y to get document coordinates. This is hidden in cached_y_.
|
||||
@ -467,14 +473,14 @@ LyXText * LCursor::text() const
|
||||
|
||||
Paragraph & LCursor::paragraph()
|
||||
{
|
||||
BOOST_ASSERT(!inMathed());
|
||||
BOOST_ASSERT(inTexted());
|
||||
return current_ ? current().paragraph() : *bv_->text()->getPar(par());
|
||||
}
|
||||
|
||||
|
||||
Paragraph const & LCursor::paragraph() const
|
||||
{
|
||||
BOOST_ASSERT(!inMathed());
|
||||
BOOST_ASSERT(inTexted());
|
||||
return current_ ? current().paragraph() : *bv_->text()->getPar(par());
|
||||
}
|
||||
|
||||
@ -1205,9 +1211,11 @@ int LCursor::targetX() const
|
||||
|
||||
MathHullInset * LCursor::formula() const
|
||||
{
|
||||
for (int i = cursor_.size() - 1; i >= 1; --i)
|
||||
if (cursor_[i].inset()->lyxCode() == InsetBase::MATH_CODE)
|
||||
return static_cast<MathHullInset *>(cursor_[i].inset());
|
||||
for (int i = cursor_.size() - 1; i >= 1; --i) {
|
||||
MathInset * inset = cursor_[i].inset()->asMathInset();
|
||||
if (inset && inset->asHullInset())
|
||||
return static_cast<MathHullInset *>(inset);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1794,6 +1802,12 @@ bool LCursor::inMathed() const
|
||||
}
|
||||
|
||||
|
||||
bool LCursor::inTexted() const
|
||||
{
|
||||
return !formula();
|
||||
}
|
||||
|
||||
|
||||
InsetBase * LCursor::nextInset()
|
||||
{
|
||||
if (pos() == lastpos())
|
||||
|
@ -416,6 +416,8 @@ public:
|
||||
void releaseMathCursor();
|
||||
/// are we in mathed?
|
||||
bool inMathed() const;
|
||||
/// are we in texted?
|
||||
bool inTexted() const;
|
||||
|
||||
/// display a message
|
||||
void message(std::string const & msg) const;
|
||||
|
@ -147,8 +147,11 @@ void LyXView::updateLayoutChoice()
|
||||
current_layout = buffer()->params().getLyXTextClass().defaultLayoutName();
|
||||
}
|
||||
|
||||
if (bufferview_->cursor().inMathed())
|
||||
return;
|
||||
|
||||
string const & layout =
|
||||
bufferview_->getLyXText()->cursorPar()->layout()->name();
|
||||
bufferview_->cursor().paragraph().layout()->name();
|
||||
|
||||
if (layout != current_layout) {
|
||||
toolbar_->setLayout(layout);
|
||||
|
@ -307,7 +307,7 @@ void InsetText::edit(LCursor & cur, int x, int y)
|
||||
text_.edit(cur, x, y);
|
||||
//sanitizeEmptyText(cur.bv());
|
||||
//updateLocal(cur);
|
||||
//cur.bv().updateParagraphDialog();
|
||||
//dispatch(cur, FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,9 +146,9 @@ public:
|
||||
void addPreview(lyx::graphics::PreviewLoader &) const;
|
||||
|
||||
///
|
||||
void edit(LCursor & cur, bool);
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
void edit(LCursor & cur, int, int);
|
||||
void edit(LCursor & cur, int x, int y);
|
||||
|
||||
///
|
||||
int numParagraphs() const { return 1; }
|
||||
|
@ -261,6 +261,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
{
|
||||
FuncStatus flag;
|
||||
Buffer * buf = owner->buffer();
|
||||
LCursor & cur = view()->cursor();
|
||||
|
||||
if (ev.action == LFUN_NOACTION) {
|
||||
setStatusMessage(N_("Nothing to do"));
|
||||
@ -310,9 +311,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableInset * tli = view()->cursor().inset()
|
||||
? view()->cursor().inset()->asUpdatableInset() : 0;
|
||||
InsetTabular * tab = view()->cursor().innerInsetTabular();
|
||||
UpdatableInset * tli = cur.inset() ? cur.inset()->asUpdatableInset() : 0;
|
||||
InsetTabular * tab = cur.innerInsetTabular();
|
||||
|
||||
// I would really like to avoid having this switch and rather try to
|
||||
// encode this in the function itself.
|
||||
@ -333,7 +333,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
if (tab && tab->hasSelection())
|
||||
disable = false;
|
||||
else
|
||||
disable = !view()->cursor().inMathed() && !view()->cursor().selection();
|
||||
disable = cur.inTexted() && !cur.selection();
|
||||
break;
|
||||
|
||||
case LFUN_RUNCHKTEX:
|
||||
@ -345,7 +345,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
disable = !view()->cursor().innerInsetTabular();
|
||||
disable = !cur.innerInsetTabular();
|
||||
break;
|
||||
|
||||
case LFUN_DEPTH_MIN:
|
||||
@ -357,19 +357,19 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT:
|
||||
case LFUN_LAYOUT_PARAGRAPH: {
|
||||
InsetOld * inset = view()->getLyXText()->cursorPar()->inInset();
|
||||
disable = inset && inset->forceDefaultParagraphs(inset);
|
||||
case LFUN_LAYOUT_PARAGRAPH:
|
||||
disable = cur.inset()
|
||||
&& cur.inset()->forceDefaultParagraphs(cur.inset());
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_OPTARG:
|
||||
disable = (view()->getLyXText()->cursorPar()->layout()->optionalargs == 0);
|
||||
disable = cur.inMathed()
|
||||
|| cur.paragraph().layout()->optionalargs == 0;
|
||||
break;
|
||||
|
||||
case LFUN_TABULAR_FEATURE:
|
||||
#if 0
|
||||
if (view()->cursor().inMathed()) {
|
||||
if (cur.inMathed()) {
|
||||
// FIXME: check temporarily disabled
|
||||
// valign code
|
||||
char align = mathcursor::valign();
|
||||
@ -411,7 +411,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
if (tli) {
|
||||
FuncStatus ret;
|
||||
//ret.disabled(true);
|
||||
InsetTabular * tab = view()->cursor().innerInsetTabular();
|
||||
InsetTabular * tab = cur.innerInsetTabular();
|
||||
if (tab) {
|
||||
ret = tab->getStatus(ev.argument);
|
||||
flag |= ret;
|
||||
@ -460,9 +460,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
|
||||
case LFUN_INSET_SETTINGS: {
|
||||
disable = true;
|
||||
UpdatableInset * inset = view()->cursor().inset()
|
||||
? view()->cursor().inset()->asUpdatableInset() : 0;
|
||||
|
||||
if (!cur.inset())
|
||||
break;
|
||||
UpdatableInset * inset = cur.inset()->asUpdatableInset();
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
@ -501,7 +501,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
}
|
||||
|
||||
case LFUN_MATH_MUTATE:
|
||||
if (view()->cursor().inMathed())
|
||||
if (cur.inMathed())
|
||||
//flag.setOnOff(mathcursor::formula()->hullType() == ev.argument);
|
||||
flag.setOnOff(false);
|
||||
else
|
||||
@ -515,7 +515,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
case LFUN_MATH_NONUMBER:
|
||||
case LFUN_MATH_NUMBER:
|
||||
case LFUN_MATH_EXTERN:
|
||||
disable = !view()->cursor().inMathed();
|
||||
disable = cur.inTexted();
|
||||
break;
|
||||
|
||||
case LFUN_DIALOG_SHOW: {
|
||||
@ -533,7 +533,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
disable = !Exporter::IsExportable(*buf, "dvi") ||
|
||||
lyxrc.print_command == "none";
|
||||
} else if (name == "character") {
|
||||
InsetBase * inset = view()->cursor().inset();
|
||||
InsetBase * inset = cur.inset();
|
||||
disable = inset && inset->lyxCode() == InsetOld::ERT_CODE;
|
||||
} else if (name == "vclog") {
|
||||
disable = !buf->lyxvc().inUse();
|
||||
@ -674,11 +674,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
break;
|
||||
case LFUN_SPACE_INSERT:
|
||||
// slight hack: we know this is allowed in math mode
|
||||
if (!view()->cursor().inMathed())
|
||||
if (cur.inTexted())
|
||||
code = InsetOld::SPACE_CODE;
|
||||
break;
|
||||
case LFUN_INSET_DIALOG_SHOW: {
|
||||
InsetBase * inset = view()->cursor().nextInset();
|
||||
InsetBase * inset = cur.nextInset();
|
||||
disable = !inset;
|
||||
if (inset) {
|
||||
code = inset->lyxCode();
|
||||
@ -709,7 +709,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
flag.setOnOff(buf->isReadonly());
|
||||
break;
|
||||
case LFUN_APPENDIX:
|
||||
flag.setOnOff(view()->getLyXText()->cursorPar()->params().startOfAppendix());
|
||||
flag.setOnOff(cur.inTexted()
|
||||
&& cur.paragraph().params().startOfAppendix());
|
||||
break;
|
||||
case LFUN_SWITCHBUFFER:
|
||||
// toggle on the current buffer, but do not toggle off
|
||||
@ -726,8 +727,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
|
||||
|
||||
#ifdef LOCK
|
||||
// the font related toggles
|
||||
if (!view()->cursor().inMathed()) {
|
||||
LyXFont const & font = view()->getLyXText()->real_current_font;
|
||||
if (cur.inTexted()) {
|
||||
LyXFont const & font = cur.text()->real_current_font;
|
||||
switch (ev.action) {
|
||||
case LFUN_EMPH:
|
||||
flag.setOnOff(font.emph() == LyXFont::ON);
|
||||
|
@ -1046,7 +1046,7 @@ void MathGridInset::splitCell(LCursor & cur)
|
||||
DispatchResult
|
||||
MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "*** MathGridInset: request: " << cmd << endl;
|
||||
//lyxerr << "*** MathGridInset: request: " << cmd << endl;
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
@ -1054,7 +1054,7 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
// GridInsetMailer(*this).showDialog();
|
||||
// return DispatchResult(true, true);
|
||||
//}
|
||||
return DispatchResult(false);
|
||||
return MathNestInset::priv_dispatch(cur, cmd);
|
||||
|
||||
case LFUN_INSET_DIALOG_UPDATE:
|
||||
GridInsetMailer(*this).updateDialog(&cur.bv());
|
||||
@ -1070,8 +1070,8 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
//}
|
||||
if (nrows() > 1)
|
||||
delRow(cur.row());
|
||||
if (cur.idx() >= nargs())
|
||||
cur.idx() = nargs() - 1;
|
||||
if (cur.idx() > cur.lastidx())
|
||||
cur.idx() = cur.lastidx();
|
||||
if (cur.pos() > cur.lastpos())
|
||||
cur.pos() = cur.lastpos();
|
||||
return DispatchResult(true, FINISHED);
|
||||
|
@ -907,17 +907,6 @@ string MathHullInset::fileInsetLabel() const
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// local global
|
||||
int first_x;
|
||||
int first_y;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
int MathHullInset::ylow() const
|
||||
{
|
||||
return yo_ - dim_.asc;
|
||||
@ -1021,131 +1010,6 @@ void MathHullInset::getCursorDim(int & asc, int & desc) const
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathHullInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (!cur.inMathed())
|
||||
return DispatchResult(false);
|
||||
cur.bv().update();
|
||||
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
// try to dispatch to enclosed insets first
|
||||
if (!cur.dispatch(cmd).dispatched()) {
|
||||
// launch math panel for right mouse button
|
||||
lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
|
||||
cur.bv().owner()->getDialogs().show("mathpanel");
|
||||
}
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
MathArray ar;
|
||||
asArray(cur.bv().getClipboard(), ar);
|
||||
cur.selClear();
|
||||
cur.setScreenPos(cmd.x, cmd.y);
|
||||
cur.insert(ar);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// try to dispatch to enclosed insets first
|
||||
cur.dispatch(cmd);
|
||||
cur.bv().stuffClipboard(cur.grabSelection());
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
return DispatchResult(false);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathHullInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (!cur.inMathed() || cur.formula() != this) {
|
||||
lyxerr[Debug::MATHED] << "re-create cursor" << endl;
|
||||
cur.releaseMathCursor();
|
||||
cur.idx() = 0;
|
||||
//metrics(bv);
|
||||
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
cur.dispatch(cmd);
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
cur.selClear();
|
||||
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
cur.dispatch(cmd);
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathHullInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
if (!cur.inMathed())
|
||||
return DispatchResult(true, true);
|
||||
|
||||
if (cur.dispatch(FuncRequest(cmd)).dispatched())
|
||||
return DispatchResult(true, true);
|
||||
|
||||
// only select with button 1
|
||||
if (cmd.button() != mouse_button::button1)
|
||||
return DispatchResult(true, true);
|
||||
|
||||
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
|
||||
return DispatchResult(true, true);
|
||||
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
|
||||
if (!cur.selection())
|
||||
cur.selBegin();
|
||||
|
||||
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
void MathHullInset::edit(LCursor & cur, bool left)
|
||||
{
|
||||
lyxerr << "Called FormulaBase::edit" << endl;
|
||||
cur.push(this);
|
||||
cur.idx() = left ? 0 : cur.lastidx();
|
||||
cur.pos() = left ? 0 : cur.lastpos();
|
||||
cur.resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void MathHullInset::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
lyxerr << "Called MathHullInset::edit with '" << x << ' ' << y << "'" << endl;
|
||||
cur.push(this);
|
||||
//cur.idx() = left ? 0 : cur.lastidx();
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
cur.setScreenPos(x + xo_, y + yo_);
|
||||
// if that is removed, we won't get the magenta box when entering an
|
||||
// inset for the first time
|
||||
cur.bv().update();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void MathHullInset::revealCodes(LCursor & cur) const
|
||||
{
|
||||
if (!cur.inMathed())
|
||||
|
@ -191,8 +191,6 @@ public:
|
||||
///
|
||||
bool display() const;
|
||||
///
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
Code lyxCode() const;
|
||||
|
||||
private:
|
||||
@ -200,13 +198,6 @@ private:
|
||||
void handleAccent(BufferView & bv, std::string const & arg,
|
||||
std::string const & name);
|
||||
|
||||
/// lfun handler
|
||||
DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
|
||||
|
||||
protected:
|
||||
|
||||
/** Find the PreviewLoader, add a LaTeX snippet to it and
|
||||
|
@ -46,6 +46,17 @@ using std::string;
|
||||
using std::istringstream;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// local global
|
||||
int first_x;
|
||||
int first_y;
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
|
||||
|
||||
MathNestInset::MathNestInset(idx_type nargs)
|
||||
: cells_(nargs), lock_(false)
|
||||
{}
|
||||
@ -377,9 +388,17 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
return dispatch(cur, FuncRequest(LFUN_PASTE, cur.bv().getClipboard()));
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
if (cmd.button() == mouse_button::button2)
|
||||
return priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
|
||||
return DispatchResult(false);
|
||||
//lyxerr << "Mouse single press" << endl;
|
||||
return lfunMousePress(cur, cmd);
|
||||
case LFUN_MOUSE_MOTION:
|
||||
//lyxerr << "Mouse motion" << endl;
|
||||
return lfunMouseMotion(cur, cmd);
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
//lyxerr << "Mouse single release" << endl;
|
||||
return lfunMouseRelease(cur, cmd);
|
||||
case LFUN_MOUSE_DOUBLE:
|
||||
//lyxerr << "Mouse double" << endl;
|
||||
return dispatch(cur, FuncRequest(LFUN_WORDSEL));
|
||||
|
||||
case LFUN_RIGHTSEL:
|
||||
cur.selection() = true; // fall through...
|
||||
@ -507,18 +526,6 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
bool remove_inset = false;
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
//lyxerr << "Mouse single press" << endl;
|
||||
return lfunMousePress(cur, cmd);
|
||||
case LFUN_MOUSE_MOTION:
|
||||
//lyxerr << "Mouse motion" << endl;
|
||||
return lfunMouseMotion(cur, cmd);
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
//lyxerr << "Mouse single release" << endl;
|
||||
return lfunMouseRelease(cur, cmd);
|
||||
case LFUN_MOUSE_DOUBLE:
|
||||
//lyxerr << "Mouse double" << endl;
|
||||
return dispatch(cur, FuncRequest(LFUN_WORDSEL));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -794,10 +801,20 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
|
||||
void MathNestInset::edit(LCursor & cur, bool left)
|
||||
{
|
||||
lyxerr << "XXX Called MathNestInset::edit" << endl;
|
||||
cur.push(this);
|
||||
cur.idx() = left ? 0 : cur.lastidx();
|
||||
cur.pos() = left ? 0 : cur.lastpos();
|
||||
cur.resetAnchor();
|
||||
}
|
||||
|
||||
|
||||
void MathNestInset::edit(LCursor & cur, int x, int y)
|
||||
{
|
||||
lyxerr << "Called MathNestInset::edit with '" << x << ' ' << y << "'" << endl;
|
||||
cur.push(this);
|
||||
lyxerr << "XXX Called MathNestInset::edit with '"
|
||||
<< x << ' ' << y << "'" << endl;
|
||||
int idx_min = 0;
|
||||
int dist_min = 1000000;
|
||||
for (idx_type i = 0; i < nargs(); ++i) {
|
||||
@ -819,3 +836,82 @@ void MathNestInset::edit(LCursor & cur, int x, int y)
|
||||
ar[i].nucleus()->edit(cur, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
|
||||
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// try to dispatch to enclosed insets first
|
||||
//cur.bv().stuffClipboard(cur.grabSelection());
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
MathArray ar;
|
||||
asArray(cur.bv().getClipboard(), ar);
|
||||
cur.selClear();
|
||||
cur.setScreenPos(cmd.x, cmd.y);
|
||||
cur.insert(ar);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
// try to dispatch to enclosed insets first
|
||||
cur.bv().owner()->getDialogs().show("mathpanel");
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
return DispatchResult(false);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
cur.selClear();
|
||||
//cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
|
||||
cur.bv().cursor() = cur;
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
return priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
|
||||
}
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
|
||||
{
|
||||
// only select with button 1
|
||||
if (cmd.button() != mouse_button::button1)
|
||||
return DispatchResult(true, true);
|
||||
|
||||
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
|
||||
return DispatchResult(true, true);
|
||||
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
|
||||
if (!cur.selection())
|
||||
cur.selBegin();
|
||||
|
||||
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
|
||||
cur.bv().update();
|
||||
return DispatchResult(true, true);
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ public:
|
||||
/// get cursor position
|
||||
void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
|
||||
///
|
||||
void edit(LCursor & cur, int, int);
|
||||
void edit(LCursor & cur, bool left);
|
||||
///
|
||||
void edit(LCursor & cur, int x, int y);
|
||||
|
||||
/// order of movement through the cells when pressing the left key
|
||||
bool idxLeft(LCursor &) const;
|
||||
@ -96,6 +98,7 @@ public:
|
||||
void write(WriteStream & os) const;
|
||||
/// writes [, name(), and args in []
|
||||
void normalize(NormalStream & os) const;
|
||||
|
||||
protected:
|
||||
///
|
||||
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
||||
@ -105,6 +108,16 @@ protected:
|
||||
///
|
||||
void handleFont2(LCursor & cur, std::string const & arg);
|
||||
|
||||
|
||||
private:
|
||||
/// lfun handler
|
||||
DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
|
||||
///
|
||||
DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
|
||||
|
||||
protected:
|
||||
/// we store the cells in a vector
|
||||
typedef std::vector<MathArray> cells_type;
|
||||
/// thusly:
|
||||
|
Loading…
Reference in New Issue
Block a user