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