}
-void MathNestInset::drawSelection(PainterInfo & pi, int, int) const
+void MathNestInset::drawSelection(PainterInfo & pi, int x, int y) const
{
+ // FIXME: hack to get position cache warm
+ draw(pi, x, y);
+
// this should use the x/y values given, not the cached values
LCursor & cur = pi.base.bv->cursor();
if (!cur.selection())
}
-void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
+void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
{
//lyxerr << "MathNestInset: request: " << cmd << std::endl;
//CursorSlice sl = cur.current();
cur.message(_("Paste"));
replaceSelection(cur);
size_t n = 0;
- istringstream is(cmd.argument.c_str());
+ istringstream is(cmd.argument);
is >> n;
pasteSelection(cur, n);
cur.clearSelection(); // bug 393
cur.autocorrect() = false;
cur.clearTargetX();
cur.macroModeClose();
- else if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
+ if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
cur.pushLeft(*cur.nextAtom().nucleus());
cur.inset().idxFirst(cur);
} else if (cur.posRight() || idxRight(cur)
case LFUN_PRIORSEL:
case LFUN_PRIOR:
- case LFUN_BEGINNINGBUFSEL:
- case LFUN_BEGINNINGBUF:
cmd = FuncRequest(LFUN_FINISHED_LEFT);
break;
case LFUN_NEXTSEL:
case LFUN_NEXT:
- case LFUN_ENDBUFSEL:
- case LFUN_ENDBUF:
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
break;
lyxerr << "LFUN_SETXY broken!" << endl;
int x = 0;
int y = 0;
- istringstream is(cmd.argument.c_str());
+ istringstream is(cmd.argument);
is >> x >> y;
cur.setScreenPos(x, y);
break;
case LFUN_MATH_MODE:
#if 1
+ // ignore math-mode on when already in math mode
+ if (currentMode() == InsetBase::MATH_MODE && cmd.argument == "on")
+ break;
cur.macroModeClose();
selClearOrDel(cur);
cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv())));
}
default:
- MathDimInset::priv_dispatch(cur, cmd);
+ MathDimInset::doDispatch(cur, cmd);
break;
}
}
}
-InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y)
+InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) const
{
int idx_min = 0;
int dist_min = 1000000;
idx_min = i;
}
}
- MathArray & ar = cell(idx_min);
- cur.push(*this);
+ MathArray const & ar = cell(idx_min);
+ cur.push(const_cast<MathNestInset&>(*this));
cur.idx() = idx_min;
cur.pos() = ar.x2pos(x - ar.xo());
lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl;
if (ar[i]->covers(x, y))
return ar[i].nucleus()->editXY(cur, x, y);
}
- return this;
-}
-
-
-void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & 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;
- }
-
- if (cmd.button() == mouse_button::button2) {
- MathArray ar;
- asArray(cur.bv().getClipboard(), ar);
- cur.clearSelection();
- cur.setScreenPos(cmd.x, cmd.y);
- cur.insert(ar);
- cur.bv().update();
- return;
- }
-
- if (cmd.button() == mouse_button::button3) {
- // try to dispatch to enclosed insets first
- cur.bv().owner()->getDialogs().show("mathpanel");
- return;
- }
-
- cur.undispatched();
+ return const_cast<MathNestInset*>(this);
}
if (cmd.button() == mouse_button::button1) {
first_x = cmd.x;
first_y = cmd.y;
- //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
cur.resetAnchor();
cur.bv().cursor() = cur;
void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd)
{
// only select with button 1
- if (cmd.button() != mouse_button::button1)
+ if (cmd.button() == mouse_button::button1) {
+ LCursor & bvcur = cur.bv().cursor();
+ if (abs(cmd.x - first_x) + abs(cmd.y - first_y) > 4
+ && bvcur.anchor_.hasPart(cur)) {
+ first_x = cmd.x;
+ first_y = cmd.y;
+
+ bvcur.setCursor(cur);
+ bvcur.selection() = true;
+ }
+ }
+}
+
+
+void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd)
+{
+ lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
+
+ if (cmd.button() == mouse_button::button1) {
+ //cur.bv().stuffClipboard(cur.grabSelection());
return;
+ }
- if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
+ if (cmd.button() == mouse_button::button2) {
+ MathArray ar;
+ asArray(cur.bv().getClipboard(), ar);
+ cur.clearSelection();
+ cur.setScreenPos(cmd.x, cmd.y);
+ cur.insert(ar);
+ cur.bv().update();
return;
+ }
- first_x = cmd.x;
- first_y = cmd.y;
+ if (cmd.button() == mouse_button::button3) {
+ // try to dispatch to enclosed insets first
+ cur.bv().owner()->getDialogs().show("mathpanel");
+ return;
+ }
- cur.bv().cursor().setCursor(cur, true);
+ cur.undispatched();
}
// handle macroMode
if (cur.inMacroMode()) {
string name = cur.macroName();
- lyxerr << "interpret macro name: '" << name << "'" << endl;
/// are we currently typing '#1' or '#2' or...?
if (name == "\\#") {
cur.backspace();
cur.niceInsert(MathAtom(new MathCommentInset));
} else if (c == '#') {
- lyxerr << "setting name to " << name + c << endl;
BOOST_ASSERT(cur.activeMacro());
cur.activeMacro()->setName(name + c);
- lyxerr << "set name to " << name + c << endl;
} else {
cur.backspace();
cur.niceInsert(createMathInset(string(1, c)));
lyxerr << "converting prev atom " << endl;
cur.prevAtom() = MathAtom(new MathScriptInset(cur.prevAtom(), up));
}
- lyxerr << "new scriptinset 2: cur:\n" << cur << endl;
--cur.pos();
- lyxerr << "new scriptinset 3: cur:\n" << cur << endl;
MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset();
- lyxerr << "new scriptinset 3: inset:\n" << inset << endl;
cur.push(*inset);
cur.idx() = 1;
cur.pos() = 0;