return string();
if (mathcursor)
- return mathcursor->info(*bv);
+ return mathcursor->info(bv->fullCursor());
ostringstream state;
}
-void LCursor::cell(int idx)
-{
- BOOST_ASSERT(!cursor_.empty());
- cursor_.back().idx_ = idx;
-}
-
-
-int LCursor::cell() const
+void LCursor::resetAnchor()
{
- BOOST_ASSERT(!cursor_.empty());
- return cursor_.back().idx_;
+ anchor_ = cursor_;
}
-void LCursor::resetAnchor()
+BufferView & LCursor::bv() const
{
- anchor_ = cursor_;
+ return *bv_;
}
typedef CursorSlice::par_type par_type;
/// type for cursor positions within a cell
typedef CursorSlice::pos_type pos_type;
+ /// type for row indices
+ typedef CursorSlice::row_type row_type;
+ /// type for col indices
+ typedef CursorSlice::col_type col_type;
/// create 'empty' cursor. REMOVE ME
LCursor();
- /// create 'empty' cursor
+ /// create the cursor of a BufferView
explicit LCursor(BufferView & bv);
/// dispatch from innermost inset upwards
DispatchResult dispatch(FuncRequest const & cmd);
CursorSlice & top() { return cursor_.back(); }
/// access to cursor 'tip'
CursorSlice const & top() const { return cursor_.back(); }
+ /// how many nested insets do we have?
+ size_t depth() const { return cursor_.size(); }
+
+ /// access to the topmost slice
+ /// the current inset
+ InsetBase * inset() const { return top().inset(); }
+ /// return the text-ed cell this cursor is in
+ idx_type idx() const { return top().idx(); }
+ /// return the text-ed cell this cursor is in
+ idx_type & idx() { return top().idx(); }
+ /// return the mathed cell this cursor is in
+ MathArray const & cell() const { return top().cell(); }
+ /// return the mathed cell this cursor is in
+ MathArray & cell() { return top().cell(); }
+ /// return the paragraph this cursor is in
+ par_type par() const { return top().par(); }
+ /// return the paragraph this cursor is in
+ par_type & par() { return top().par(); }
+ /// return the position within the paragraph
+ pos_type pos() const { return top().pos(); }
+ /// return the position within the paragraph
+ pos_type & pos() { return top().pos(); }
+ /// return the last position within the paragraph
+ pos_type lastpos() const { return top().lastpos(); }
+ /// return the number of embedded cells
+ size_t nargs() const { return top().nargs(); }
+ /// return the number of embedded cells
+ size_t ncols() const { return top().ncols(); }
+ /// return the number of embedded cells
+ size_t nrows() const { return top().nrows(); }
+ /// return the grid row of the current cell
+ row_type row() const { return top().row(); }
+ /// return the grid row of the current cell
+ col_type col() const { return top().col(); }
- /// set the cell the cursor is in
- void cell(int);
- /// return the cell this cursor is in
- int cell() const;
///
UpdatableInset * innerInset() const;
///
void updatePos();
/// sets anchor to cursor position
void resetAnchor();
- /// sets anchor to cursor position
+ /// access to owning BufferView
BufferView & bv() const;
///
friend std::ostream & operator<<(std::ostream &, LCursor const &);
CursorSlice::row_type CursorSlice::row() const
{
BOOST_ASSERT(asMathInset());
- asMathInset()->row(idx_);
+ return asMathInset()->row(idx_);
}
CursorSlice::col_type CursorSlice::col() const
{
BOOST_ASSERT(asMathInset());
- asMathInset()->col(idx_);
+ return asMathInset()->col(idx_);
}
tablemode = true;
bv.fullCursor(theTempCursor);
bv.fullCursor().push(this);
- bv.fullCursor().cell(cell);
+ bv.fullCursor().idx() = cell;
} else {
tablemode = false;
setPos(bv, cmd.x, cmd.y);
bv.fullCursor(theTempCursor);
- bv.fullCursor().cell(cell);
+ bv.fullCursor().idx() = cell;
}
lyxerr << bv.cursor() << endl;
setSelection(actcell, actcell);
bv.setSelection();
} else {
- bv.cursor().idx(actcell);
+ bv.cursor().idx() = actcell;
setSelection(sel_cell_start, actcell);
tablemode = (sel_cell_start != actcell);
}
resetPos(bv);
bv.fitCursor();
bv.fullCursor().push(this);
- bv.fullCursor().cell(cell);
+ bv.fullCursor().idx() = cell;
lyxerr << bv.cursor() << endl;
}
void InsetFormulaBase::handleFont
- (BufferView & bv, string const & arg, string const & font)
+ (LCursor & cur, string const & arg, string const & font)
{
// this whole function is a hack and won't work for incremental font
// changes...
- recordUndo(bv, Undo::ATOMIC);
+ recordUndo(cur.bv(), Undo::ATOMIC);
- if (bv.cursor().inset()->asMathInset()->name() == font)
- mathcursor->handleFont(bv, font);
+ if (cur.inset()->asMathInset()->name() == font)
+ mathcursor->handleFont(cur, font);
else {
- mathcursor->handleNest(bv, createMathInset(font));
- mathcursor->insert(bv, arg);
+ mathcursor->handleNest(cur, createMathInset(font));
+ mathcursor->insert(cur, arg);
}
}
-void InsetFormulaBase::handleFont2(BufferView & bv, string const & arg)
+void InsetFormulaBase::handleFont2(LCursor & cur, string const & arg)
{
- recordUndo(bv, Undo::ATOMIC);
+ recordUndo(cur.bv(), Undo::ATOMIC);
LyXFont font;
bool b;
bv_funcs::string2font(arg, font, b);
if (font.color() != LColor::inherit) {
MathAtom at = createMathInset("color");
asArray(lcolor.getGUIName(font.color()), at.nucleus()->cell(0));
- mathcursor->handleNest(bv, at, 1);
+ mathcursor->handleNest(cur, at, 1);
}
}
void InsetFormulaBase::insetUnlock(BufferView & bv)
{
if (mathcursor) {
- if (mathcursor->inMacroMode(bv))
- mathcursor->macroModeClose(bv);
+ if (mathcursor->inMacroMode(bv.fullCursor()))
+ mathcursor->macroModeClose(bv.fullCursor());
releaseMathCursor(bv);
}
if (bv.buffer())
}
-void InsetFormulaBase::getCursor(BufferView & bv, int & x, int & y) const
-{
- mathcursor->getScreenPos(bv, x, y);
-}
-
-
void InsetFormulaBase::getCursorPos(BufferView & bv, int & x, int & y) const
{
if (mathcursor) {
- mathcursor->getScreenPos(bv, x, y);
- x = mathcursor->targetX(bv);
+ mathcursor->getScreenPos(bv.fullCursor(), x, y);
+ x = mathcursor->targetX(bv.fullCursor());
x -= xo_;
y -= yo_;
lyxerr << "InsetFormulaBase::getCursorPos: " << x << ' ' << y << endl;
}
-void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
-{
- if (mathcursor)
- bv->update();
-}
-
-
DispatchResult
InsetFormulaBase::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
{
if (cmd.button() == mouse_button::button3) {
// try to dispatch to enclosed insets first
- if (!mathcursor->dispatch(bv, cmd).dispatched()) {
+ if (!mathcursor->dispatch(bv.fullCursor(), cmd).dispatched()) {
// launch math panel for right mouse button
lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
bv.owner()->getDialogs().show("mathpanel");
if (cmd.button() == mouse_button::button2) {
MathArray ar;
asArray(bv.getClipboard(), ar);
- mathcursor->selClear(bv);
- mathcursor->setScreenPos(bv, cmd.x + xo_, cmd.y + yo_);
- mathcursor->insert(bv, ar);
+ mathcursor->selClear(bv.fullCursor());
+ mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
+ mathcursor->insert(bv.fullCursor(), ar);
bv.update();
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button1) {
// try to dispatch to enclosed insets first
- mathcursor->dispatch(bv, cmd);
- bv.stuffClipboard(mathcursor->grabSelection(bv));
+ mathcursor->dispatch(bv.fullCursor(), cmd);
+ bv.stuffClipboard(mathcursor->grabSelection(bv.fullCursor()));
// try to set the cursor
//delete mathcursor;
//mathcursor = new MathCursor(bv, this, x == 0);
releaseMathCursor(bv);
mathcursor = new MathCursor(&bv, this, cmd.x == 0);
//metrics(bv);
- mathcursor->setScreenPos(bv, cmd.x + xo_, cmd.y + yo_);
+ mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
}
if (cmd.button() == mouse_button::button3) {
- mathcursor->dispatch(bv, cmd);
+ mathcursor->dispatch(bv.fullCursor(), cmd);
return DispatchResult(true, true);
}
if (cmd.button() == mouse_button::button1) {
first_x = cmd.x;
first_y = cmd.y;
- mathcursor->selClear(bv);
- mathcursor->setScreenPos(bv, cmd.x + xo_, cmd.y + yo_);
- mathcursor->dispatch(bv, cmd);
+ mathcursor->selClear(bv.fullCursor());
+ mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
+ mathcursor->dispatch(bv.fullCursor(), cmd);
return DispatchResult(true, true);
}
if (!mathcursor)
return DispatchResult(true, true);
- if (mathcursor->dispatch(bv, FuncRequest(cmd)).dispatched())
+ if (mathcursor->dispatch(bv.fullCursor(), FuncRequest(cmd)).dispatched())
return DispatchResult(true, true);
// only select with button 1
first_y = cmd.y;
if (!mathcursor->selection())
- mathcursor->selStart(bv);
+ mathcursor->selStart(bv.fullCursor());
- mathcursor->setScreenPos(bv, cmd.x + xo_, cmd.y + yo_);
+ mathcursor->setScreenPos(bv.fullCursor(), cmd.x + xo_, cmd.y + yo_);
bv.update();
return DispatchResult(true, true);
}
releaseMathCursor(*bv);
mathcursor = new MathCursor(bv, this, true);
//metrics(bv);
- mathcursor->setScreenPos(*bv, x + xo_, y + yo_);
+ mathcursor->setScreenPos(bv->fullCursor(), x + xo_, y + yo_);
bv->fullCursor().push(this);
// if that is removed, we won't get the magenta box when entering an
// inset for the first time
// delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
bool remove_inset = false;
+ LCursor & cur = bv.fullCursor();
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
DispatchResult result(true);
string argument = cmd.argument;
bool sel = false;
- bool was_macro = mathcursor->inMacroMode(bv);
- bool was_selection = mathcursor->selection();
+ bool was_macro = mathcursor->inMacroMode(cur);
- mathcursor->normalize(bv);
+ mathcursor->normalize(cur);
mathcursor->touch();
switch (cmd.action) {
case LFUN_PASTESELECTION:
case LFUN_MATH_LIMITS:
recordUndo(bv, Undo::ATOMIC);
- mathcursor->dispatch(bv, cmd);
+ mathcursor->dispatch(cur, cmd);
break;
case LFUN_RIGHTSEL:
sel = true; // fall through...
case LFUN_RIGHT:
- result = mathcursor->right(bv, sel) ?
+ result = mathcursor->right(cur, sel) ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
//lyxerr << "calling scroll 20" << endl;
//scroll(&bv, 20);
case LFUN_LEFTSEL:
sel = true; // fall through
case LFUN_LEFT:
- result = mathcursor->left(bv, sel) ?
+ result = mathcursor->left(cur, sel) ?
DispatchResult(true, true) : DispatchResult(false, FINISHED);
break;
case LFUN_UPSEL:
sel = true; // fall through
case LFUN_UP:
- result = mathcursor->up(bv, sel) ?
+ result = mathcursor->up(cur, sel) ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
break;
case LFUN_DOWNSEL:
sel = true; // fall through
case LFUN_DOWN:
- result = mathcursor->down(bv, sel) ?
+ result = mathcursor->down(cur, sel) ?
DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
break;
case LFUN_WORDSEL:
- mathcursor->home(bv, false);
- mathcursor->end(bv, true);
+ mathcursor->home(cur, false);
+ mathcursor->end(cur, true);
break;
case LFUN_UP_PARAGRAPHSEL:
sel = true; // fall through
case LFUN_HOME:
case LFUN_WORDLEFT:
- result = mathcursor->home(bv, sel)
+ result = mathcursor->home(cur, sel)
? DispatchResult(true, true) : DispatchResult(true, FINISHED);
break;
sel = true; // fall through
case LFUN_END:
case LFUN_WORDRIGHT:
- result = mathcursor->end(bv, sel)
+ result = mathcursor->end(cur, sel)
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
break;
break;
case LFUN_CELL_FORWARD:
- mathcursor->idxNext(bv);
+ mathcursor->idxNext(cur);
break;
case LFUN_CELL_BACKWARD:
- mathcursor->idxPrev(bv);
+ mathcursor->idxPrev(cur);
break;
case LFUN_DELETE_WORD_BACKWARD:
case LFUN_BACKSPACE:
recordUndo(bv, Undo::ATOMIC);
- if (!mathcursor->backspace(bv)) {
+ if (!mathcursor->backspace(cur)) {
result = DispatchResult(true, FINISHED);
remove_inset = true;
}
case LFUN_DELETE_WORD_FORWARD:
case LFUN_DELETE:
recordUndo(bv, Undo::ATOMIC);
- if (!mathcursor->erase(bv)) {
+ if (!mathcursor->erase(cur)) {
result = DispatchResult(true, FINISHED);
remove_inset = true;
}
int y = 0;
istringstream is(cmd.argument.c_str());
is >> x >> y;
- mathcursor->setScreenPos(bv, x, y);
+ mathcursor->setScreenPos(cur, x, y);
break;
}
istringstream is(cmd.argument.c_str());
is >> n;
if (was_macro)
- mathcursor->macroModeClose(bv);
+ mathcursor->macroModeClose(cur);
recordUndo(bv, Undo::ATOMIC);
- mathcursor->selPaste(bv, n);
+ mathcursor->selPaste(cur, n);
break;
}
case LFUN_CUT:
recordUndo(bv, Undo::DELETE);
- mathcursor->selCut(bv);
+ mathcursor->selCut(cur);
break;
case LFUN_COPY:
- mathcursor->selCopy(bv);
+ mathcursor->selCopy(cur);
break;
// do superscript if LyX handles
// deadkeys
recordUndo(bv, Undo::ATOMIC);
- mathcursor->script(bv, true);
+ mathcursor->script(cur, true);
}
break;
// Math fonts
case LFUN_FREEFONT_APPLY:
case LFUN_FREEFONT_UPDATE:
- handleFont2(bv, cmd.argument);
+ handleFont2(cur, cmd.argument);
break;
- case LFUN_BOLD: handleFont(bv, cmd.argument, "mathbf"); break;
- case LFUN_SANS: handleFont(bv, cmd.argument, "mathsf"); break;
- case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break;
- case LFUN_ROMAN: handleFont(bv, cmd.argument, "mathrm"); break;
- case LFUN_CODE: handleFont(bv, cmd.argument, "texttt"); break;
- case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break;
- case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break;
- case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break;
- //case LFUN_FREEFONT_APPLY: handleFont(bv, cmd.argument, "textrm"); break;
- case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
+ case LFUN_BOLD: handleFont(cur, cmd.argument, "mathbf"); break;
+ case LFUN_SANS: handleFont(cur, cmd.argument, "mathsf"); break;
+ case LFUN_EMPH: handleFont(cur, cmd.argument, "mathcal"); break;
+ case LFUN_ROMAN: handleFont(cur, cmd.argument, "mathrm"); break;
+ case LFUN_CODE: handleFont(cur, cmd.argument, "texttt"); break;
+ case LFUN_FRAK: handleFont(cur, cmd.argument, "mathfrak"); break;
+ case LFUN_ITAL: handleFont(cur, cmd.argument, "mathit"); break;
+ case LFUN_NOUN: handleFont(cur, cmd.argument, "mathbb"); break;
+ //case LFUN_FREEFONT_APPLY: handleFont(cur, cmd.argument, "textrm"); break;
+ case LFUN_DEFAULT: handleFont(cur, cmd.argument, "textnormal"); break;
case LFUN_MATH_MODE:
- if (mathcursor->currentMode(bv) == MathInset::TEXT_MODE)
- mathcursor->niceInsert(bv, MathAtom(new MathHullInset("simple")));
+ if (mathcursor->currentMode(cur) == MathInset::TEXT_MODE)
+ mathcursor->niceInsert(cur, MathAtom(new MathHullInset("simple")));
else
- handleFont(bv, cmd.argument, "textrm");
- //bv.owner()->message(_("math text mode toggled"));
+ handleFont(cur, cmd.argument, "textrm");
+ //cur.owner()->message(_("math text mode toggled"));
break;
case LFUN_MATH_SIZE:
m = max(1u, m);
n = max(1u, n);
v_align += 'c';
- mathcursor->niceInsert(bv,
+ mathcursor->niceInsert(cur,
MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
break;
}
if (rs.empty())
rs = ')';
recordUndo(bv, Undo::ATOMIC);
- mathcursor->handleNest(bv, MathAtom(new MathDelimInset(ls, rs)));
+ mathcursor->handleNest(cur, MathAtom(new MathDelimInset(ls, rs)));
break;
}
case LFUN_SPACE_INSERT:
case LFUN_MATH_SPACE:
recordUndo(bv, Undo::ATOMIC);
- mathcursor->insert(bv, MathAtom(new MathSpaceInset(",")));
+ mathcursor->insert(cur, MathAtom(new MathSpaceInset(",")));
break;
case LFUN_UNDO:
case LFUN_INSET_ERT:
// interpret this as if a backslash was typed
recordUndo(bv, Undo::ATOMIC);
- mathcursor->interpret(bv, '\\');
+ mathcursor->interpret(cur, '\\');
break;
case LFUN_BREAKPARAGRAPH:
// math-insert only handles special math things like "matrix".
case LFUN_INSERT_MATH:
recordUndo(bv, Undo::ATOMIC);
- mathcursor->niceInsert(bv, argument);
+ mathcursor->niceInsert(cur, argument);
break;
case -1:
if (!argument.empty()) {
recordUndo(bv, Undo::ATOMIC);
if (argument.size() == 1)
- result = mathcursor->interpret(bv, argument[0])
+ result = mathcursor->interpret(cur, argument[0])
? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
else
- mathcursor->insert(bv, argument);
+ mathcursor->insert(cur, argument);
}
break;
case LFUN_ESCAPE:
if (mathcursor->selection())
- mathcursor->selClear(bv);
+ mathcursor->selClear(cur);
else
result = DispatchResult(false);
break;
case LFUN_INSET_TOGGLE:
- mathcursor->insetToggle(bv);
+ mathcursor->insetToggle(cur);
break;
case LFUN_DIALOG_SHOW:
} else {
MathArray ar;
if (createMathInset_fromDialogStr(cmd.argument, ar)) {
- mathcursor->insert(bv, ar);
+ mathcursor->insert(cur, ar);
result = DispatchResult(true, true);
} else {
result = DispatchResult(false);
if (result == DispatchResult(true, true))
bv.update();
- mathcursor->normalize(bv);
+ mathcursor->normalize(cur);
mathcursor->touch();
BOOST_ASSERT(mathcursor);
- if (mathcursor->selection() || was_selection)
- toggleInsetSelection(&bv);
-
if (result.dispatched()) {
revealCodes(bv);
- bv.stuffClipboard(mathcursor->grabSelection(bv));
+ bv.stuffClipboard(mathcursor->grabSelection(cur));
} else {
releaseMathCursor(bv);
if (remove_inset)
{
if (!mathcursor)
return;
- bv.owner()->message(mathcursor->info(bv));
+ bv.owner()->message(mathcursor->info(bv.fullCursor()));
/*
// write something to the minibuffer
// translate to latex
delete mathcursor;
mathcursor = new MathCursor(bv, this, true);
//metrics(bv);
- mathcursor->setSelection(*bv, it, ar.size());
+ mathcursor->setSelection(bv->fullCursor(), it, ar.size());
current = it;
top.pos_ += ar.size();
bv->update();
string InsetFormulaBase::selectionAsString(BufferView & bv) const
{
- return mathcursor ? mathcursor->grabSelection(bv) : string();
+ return mathcursor ? mathcursor->grabSelection(bv.fullCursor()) : string();
}
/////////////////////////////////////////////////////////////////////
class BufferView;
class MathAtom;
class CursorSlice;
+class LCursor;
/// An abstract base class for all math related LyX insets
virtual InsetOld::Code lyxCode() const;
/// what appears in the minibuffer when opening
virtual std::string const editMessage() const;
- ///
+ /// get the absolute document x,y of the cursor
virtual void getCursorPos(BufferView & bv, int & x, int & y) const;
///
virtual void getCursorDim(int &, int &) const;
- /// get the absolute document x,y of the cursor
- virtual void getCursor(BufferView & bv, int & x, int & y) const;
- ///
- virtual void toggleInsetSelection(BufferView * bv);
///
virtual void insetUnlock(BufferView & bv);
virtual void generatePreview(Buffer const &) const {}
///
- void handleFont(BufferView & bv, std::string const & arg, std::string const & font);
+ void handleFont(LCursor &, std::string const & arg, std::string const & font);
///
- void handleFont2(BufferView & bv, std::string const & arg);
+ void handleFont2(LCursor &, std::string const & arg);
};
// We don't really mess want around with mathed stuff outside mathed.
MathCursor::MathCursor(BufferView * bv, InsetFormulaBase * formula, bool front)
: formula_(formula), autocorrect_(false), selection_(false)
{
- front ? first(*bv) : last(*bv);
+ front ? first(bv->fullCursor()) : last(bv->fullCursor());
}
}
-void MathCursor::push(BufferView & bv, MathAtom & t)
+void MathCursor::push(LCursor & cur, MathAtom & t)
{
- bv.fullCursor().push(t.nucleus());
+ cur.push(t.nucleus());
}
-void MathCursor::pushLeft(BufferView & bv, MathAtom & t)
+void MathCursor::pushLeft(LCursor & cur, MathAtom & t)
{
//lyxerr << "Entering atom " << t << " left" << endl;
- push(bv, t);
- t->idxFirst(bv);
+ push(cur, t);
+ t->idxFirst(cur);
}
-void MathCursor::pushRight(BufferView & bv, MathAtom & t)
+void MathCursor::pushRight(LCursor & cur, MathAtom & t)
{
//lyxerr << "Entering atom " << t << " right" << endl;
- posLeft(bv);
- push(bv, t);
- t->idxLast(bv);
+ posLeft(cur);
+ push(cur, t);
+ t->idxLast(cur);
}
-bool MathCursor::popLeft(BufferView & bv)
+bool MathCursor::popLeft(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
//lyxerr << "Leaving atom to the left" << endl;
- if (depth(bv) <= 1) {
- if (depth(bv) == 1)
+ if (cur.depth() <= 1) {
+ if (cur.depth() == 1)
cur.inset()->asMathInset()->notifyCursorLeaves(cur.idx());
return false;
}
cur.inset()->asMathInset()->notifyCursorLeaves(cur.idx());
- bv.fullCursor().pop();
+ cur.pop();
return true;
}
-bool MathCursor::popRight(BufferView & bv)
+bool MathCursor::popRight(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
//lyxerr << "Leaving atom "; bv.inset->asMathInset()->write(cerr, false); cerr << " right" << endl;
- if (depth(bv) <= 1) {
- if (depth(bv) == 1)
+ if (cur.depth() <= 1) {
+ if (cur.depth() == 1)
cur.inset()->asMathInset()->notifyCursorLeaves(cur.idx());
return false;
}
cur.inset()->asMathInset()->notifyCursorLeaves(cur.idx());
- bv.fullCursor().pop();
- posRight(bv);
+ cur.pop();
+ posRight(cur);
return true;
}
void MathCursor::dump(char const * what) const
{
lyxerr << "MC: " << what << endl;
- lyxerr << " Cursor: " << depth() << endl;
- for (unsigned i = 0; i < depth(); ++i)
+ lyxerr << " Cursor: " << cur.depth() << endl;
+ for (unsigned i = 0; i < cur.depth(); ++i)
lyxerr << " i: " << i << ' ' << Cursor_[i] << endl;
lyxerr << " Anchor: " << Anchor_.size() << endl;
for (unsigned i = 0; i < Anchor_.size(); ++i)
{
#warning FIXME
/*
- for (unsigned i = 0; i < depth(); ++i)
+ for (unsigned i = 0; i < cur.depth(); ++i)
if (Cursor_[i].asMathInset() == p)
return true;
*/
#if 0
if (sel) {
// we can't move into anything new during selection
- if (depth() == Anchor_.size())
+ if (cur.depth() == Anchor_.size())
return false;
- if (t.operator->() != Anchor_[depth()].asMathInset())
+ if (t.operator->() != Anchor_[cur.depth()].asMathInset())
return false;
}
#else
}
-bool MathCursor::inNucleus(BufferView & bv) const
+bool MathCursor::inNucleus(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
return cur.inset()->asMathInset()->asScriptInset() && cur.idx() == 2;
}
-bool MathCursor::posLeft(BufferView & bv)
+bool MathCursor::posLeft(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() == 0)
return false;
--cur.pos();
}
-bool MathCursor::posRight(BufferView & bv)
+bool MathCursor::posRight(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() == cur.lastpos())
return false;
++cur.pos();
}
-bool MathCursor::left(BufferView & bv, bool sel)
+bool MathCursor::left(LCursor & cur, bool sel)
{
dump("Left 1");
autocorrect_ = false;
- bv.x_target(-1); // "no target"
- if (inMacroMode(bv)) {
- macroModeClose(bv);
+ cur.bv().x_target(-1); // "no target"
+ if (inMacroMode(cur)) {
+ macroModeClose(cur);
return true;
}
- selHandle(bv, sel);
+ selHandle(cur, sel);
- if (hasPrevAtom(bv) && openable(prevAtom(bv), sel)) {
- pushRight(bv, prevAtom(bv));
+ if (hasPrevAtom(cur) && openable(prevAtom(cur), sel)) {
+ pushRight(cur, prevAtom(cur));
return true;
}
- return posLeft(bv) || idxLeft(bv) || popLeft(bv) || selection_;
+ return posLeft(cur) || idxLeft(cur) || popLeft(cur) || selection_;
}
-bool MathCursor::right(BufferView & bv, bool sel)
+bool MathCursor::right(LCursor & cur, bool sel)
{
dump("Right 1");
autocorrect_ = false;
- bv.x_target(-1); // "no target"
- if (inMacroMode(bv)) {
- macroModeClose(bv);
+ cur.bv().x_target(-1); // "no target"
+ if (inMacroMode(cur)) {
+ macroModeClose(cur);
return true;
}
- selHandle(bv, sel);
+ selHandle(cur, sel);
- if (hasNextAtom(bv) && openable(nextAtom(bv), sel)) {
- pushLeft(bv, nextAtom(bv));
+ if (hasNextAtom(cur) && openable(nextAtom(cur), sel)) {
+ pushLeft(cur, nextAtom(cur));
return true;
}
- return posRight(bv) || idxRight(bv) || popRight(bv) || selection_;
+ return posRight(cur) || idxRight(cur) || popRight(cur) || selection_;
}
-void MathCursor::first(BufferView & bv)
+void MathCursor::first(LCursor & cur)
{
#warning FIXME
//Cursor_.clear();
- push(bv, formula_->par());
- bv.cursor().inset()->asMathInset()->idxFirst(bv);
- bv.resetAnchor();
+ push(cur, formula_->par());
+ cur.inset()->asMathInset()->idxFirst(cur);
+ cur.resetAnchor();
}
-void MathCursor::last(BufferView & bv)
+void MathCursor::last(LCursor & cur)
{
#warning FIXME
//Cursor_.clear();
- push(bv, formula_->par());
- bv.cursor().inset()->asMathInset()->idxLast(bv);
- bv.resetAnchor();
+ push(cur, formula_->par());
+ cur.inset()->asMathInset()->idxLast(cur);
+ cur.resetAnchor();
}
}
-void MathCursor::setScreenPos(BufferView & bv, int x, int y)
+void MathCursor::setScreenPos(LCursor & cur, int x, int y)
{
dump("setScreenPos 1");
- bool res = bruteFind(bv, x, y,
+ bool res = bruteFind(cur, x, y,
formula()->xlow(), formula()->xhigh(),
formula()->ylow(), formula()->yhigh());
if (!res) {
// this can happen on creation of "math-display"
dump("setScreenPos 1.5");
- first(bv);
+ first(cur);
}
- bv.x_target(-1); // "no target"
+ cur.bv().x_target(-1); // "no target"
dump("setScreenPos 2");
}
-bool MathCursor::home(BufferView & bv, bool sel)
+bool MathCursor::home(LCursor & cur, bool sel)
{
dump("home 1");
autocorrect_ = false;
- selHandle(bv, sel);
- macroModeClose(bv);
- if (!bv.cursor().inset()->asMathInset()->idxHome(bv))
- return popLeft(bv);
+ selHandle(cur, sel);
+ macroModeClose(cur);
+ if (!cur.inset()->asMathInset()->idxHome(cur))
+ return popLeft(cur);
dump("home 2");
- bv.x_target(-1); // "no target"
+ cur.bv().x_target(-1); // "no target"
return true;
}
-bool MathCursor::end(BufferView & bv, bool sel)
+bool MathCursor::end(LCursor & cur, bool sel)
{
dump("end 1");
autocorrect_ = false;
- selHandle(bv, sel);
- macroModeClose(bv);
- if (!bv.cursor().inset()->asMathInset()->idxEnd(bv))
- return popRight(bv);
+ selHandle(cur, sel);
+ macroModeClose(cur);
+ if (!cur.inset()->asMathInset()->idxEnd(cur))
+ return popRight(cur);
dump("end 2");
- bv.x_target(-1); // "no target"
+ cur.bv().x_target(-1); // "no target"
return true;
}
-void MathCursor::plainErase(BufferView & bv)
+void MathCursor::plainErase(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
cur.cell().erase(cur.pos());
}
-void MathCursor::markInsert(BufferView & bv)
+void MathCursor::markInsert(LCursor & cur)
{
//lyxerr << "inserting mark" << endl;
- CursorSlice & cur = cursorTip(bv);
cur.cell().insert(cur.pos(), MathAtom(new MathCharInset(0)));
}
-void MathCursor::markErase(BufferView & bv)
+void MathCursor::markErase(LCursor & cur)
{
//lyxerr << "deleting mark" << endl;
- CursorSlice & cur = cursorTip(bv);
cur.cell().erase(cur.pos());
}
-void MathCursor::plainInsert(BufferView & bv, MathAtom const & t)
+void MathCursor::plainInsert(LCursor & cur, MathAtom const & t)
{
dump("plainInsert");
- CursorSlice & cur = cursorTip(bv);
cur.cell().insert(cur.pos(), t);
++cur.pos();
}
-void MathCursor::insert2(BufferView & bv, string const & str)
+void MathCursor::insert2(LCursor & cur, string const & str)
{
MathArray ar;
asArray(str, ar);
- insert(bv, ar);
+ insert(cur, ar);
}
-void MathCursor::insert(BufferView & bv, string const & str)
+void MathCursor::insert(LCursor & cur, string const & str)
{
//lyxerr << "inserting '" << str << "'" << endl;
- selClearOrDel(bv);
+ selClearOrDel(cur);
for (string::const_iterator it = str.begin(); it != str.end(); ++it)
- plainInsert(bv, MathAtom(new MathCharInset(*it)));
+ plainInsert(cur, MathAtom(new MathCharInset(*it)));
}
-void MathCursor::insert(BufferView & bv, char c)
+void MathCursor::insert(LCursor & cur, char c)
{
//lyxerr << "inserting '" << c << "'" << endl;
- selClearOrDel(bv);
- plainInsert(bv, MathAtom(new MathCharInset(c)));
+ selClearOrDel(cur);
+ plainInsert(cur, MathAtom(new MathCharInset(c)));
}
-void MathCursor::insert(BufferView & bv, MathAtom const & t)
+void MathCursor::insert(LCursor & cur, MathAtom const & t)
{
- macroModeClose(bv);
- selClearOrDel(bv);
- plainInsert(bv, t);
+ macroModeClose(cur);
+ selClearOrDel(cur);
+ plainInsert(cur, t);
}
-void MathCursor::niceInsert(BufferView & bv, string const & t)
+void MathCursor::niceInsert(LCursor & cur, string const & t)
{
MathArray ar;
asArray(t, ar);
if (ar.size() == 1)
- niceInsert(bv, ar[0]);
+ niceInsert(cur, ar[0]);
else
- insert(bv, ar);
+ insert(cur, ar);
}
-void MathCursor::niceInsert(BufferView & bv, MathAtom const & t)
+void MathCursor::niceInsert(LCursor & cur, MathAtom const & t)
{
- macroModeClose(bv);
- string safe = grabAndEraseSelection(bv);
- plainInsert(bv, t);
+ macroModeClose(cur);
+ string safe = grabAndEraseSelection(cur);
+ plainInsert(cur, t);
// enter the new inset and move the contents of the selection if possible
if (t->isActive()) {
- posLeft(bv);
- pushLeft(bv, nextAtom(bv));
- paste(bv, safe);
+ posLeft(cur);
+ pushLeft(cur, nextAtom(cur));
+ paste(cur, safe);
}
}
-void MathCursor::insert(BufferView & bv, MathArray const & ar)
+void MathCursor::insert(LCursor & cur, MathArray const & ar)
{
- CursorSlice & cur = cursorTip(bv);
- macroModeClose(bv);
+ macroModeClose(cur);
if (selection_)
- eraseSelection(bv);
+ eraseSelection(cur);
cur.cell().insert(cur.pos(), ar);
cur.pos() += ar.size();
}
-void MathCursor::paste(BufferView & bv, string const & data)
+void MathCursor::paste(LCursor & cur, string const & data)
{
- dispatch(bv, FuncRequest(LFUN_PASTE, data));
+ dispatch(cur, FuncRequest(LFUN_PASTE, data));
}
-bool MathCursor::backspace(BufferView & bv)
+bool MathCursor::backspace(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
autocorrect_ = false;
if (selection_) {
- selDel(bv);
+ selDel(cur);
return true;
}
if (cur.pos() == 0) {
if (cur.inset()->asMathInset()->nargs() == 1 &&
- depth(bv) == 1 &&
+ cur.depth() == 1 &&
cur.lastpos() == 0)
return false;
- pullArg(bv);
+ pullArg(cur);
return true;
}
- if (inMacroMode(bv)) {
- MathUnknownInset * p = activeMacro(bv);
+ if (inMacroMode(cur)) {
+ MathUnknownInset * p = activeMacro(cur);
if (p->name().size() > 1) {
p->setName(p->name().substr(0, p->name().size() - 1));
return true;
}
}
- if (hasPrevAtom(bv) && prevAtom(bv)->nargs() > 0) {
+ if (hasPrevAtom(cur) && prevAtom(cur)->nargs() > 0) {
// let's require two backspaces for 'big stuff' and
// highlight on the first
- left(bv, true);
+ left(cur, true);
} else {
--cur.pos();
- plainErase(bv);
+ plainErase(cur);
}
return true;
}
-bool MathCursor::erase(BufferView & bv)
+bool MathCursor::erase(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
autocorrect_ = false;
- if (inMacroMode(bv))
+ if (inMacroMode(cur))
return true;
if (selection_) {
- selDel(bv);
+ selDel(cur);
return true;
}
// special behaviour when in last position of cell
if (cur.pos() == cur.lastpos()) {
bool one_cell = cur.inset()->asMathInset()->nargs() == 1;
- if (one_cell && depth(bv) == 1 && cur.lastpos() == 0)
+ if (one_cell && cur.depth() == 1 && cur.lastpos() == 0)
return false;
// remove markup
if (one_cell)
- pullArg(bv);
+ pullArg(cur);
else
cur.inset()->asMathInset()->idxGlue(cur.idx());
return true;
}
- if (hasNextAtom(bv) && nextAtom(bv)->nargs() > 0)
- right(bv, true);
+ if (hasNextAtom(cur) && nextAtom(cur)->nargs() > 0)
+ right(cur, true);
else
- plainErase(bv);
+ plainErase(cur);
return true;
}
-bool MathCursor::up(BufferView & bv, bool sel)
+bool MathCursor::up(LCursor & cur, bool sel)
{
dump("up 1");
- macroModeClose(bv);
- selHandle(bv, sel);
+ macroModeClose(cur);
+ selHandle(cur, sel);
#warning FIXME
#if 0
CursorBase save = Cursor_;
}
-bool MathCursor::down(BufferView & bv, bool sel)
+bool MathCursor::down(LCursor & cur, bool sel)
{
dump("down 1");
- macroModeClose(bv);
- selHandle(bv, sel);
+ macroModeClose(cur);
+ selHandle(cur, sel);
#warning FIXME
#if 0
CursorBase save = Cursor_;
}
-void MathCursor::macroModeClose(BufferView & bv)
+void MathCursor::macroModeClose(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
- if (!inMacroMode(bv))
+ if (!inMacroMode(cur))
return;
- MathUnknownInset * p = activeMacro(bv);
+ MathUnknownInset * p = activeMacro(cur);
p->finalize();
string s = p->name();
--cur.pos();
&& formula()->getInsetName() == name)
lyxerr << "can't enter recursive macro" << endl;
- niceInsert(bv, createMathInset(name));
+ niceInsert(cur, createMathInset(name));
}
-string MathCursor::macroName(BufferView & bv) const
+string MathCursor::macroName(LCursor & cur) const
{
- return inMacroMode(bv) ? activeMacro(bv)->name() : string();
+ return inMacroMode(cur) ? activeMacro(cur)->name() : string();
}
-void MathCursor::selClear(BufferView & bv)
+void MathCursor::selClear(LCursor & cur)
{
- bv.resetAnchor();
- bv.clearSelection();
+ cur.resetAnchor();
+ cur.bv().clearSelection();
}
-void MathCursor::selCopy(BufferView & bv)
+void MathCursor::selCopy(LCursor & cur)
{
dump("selCopy");
if (selection_) {
- theCutBuffer.push(grabSelection(bv));
+ theCutBuffer.push(grabSelection(cur));
selection_ = false;
} else {
//theCutBuffer.erase();
}
-void MathCursor::selCut(BufferView & bv)
+void MathCursor::selCut(LCursor & cur)
{
dump("selCut");
- theCutBuffer.push(grabAndEraseSelection(bv));
+ theCutBuffer.push(grabAndEraseSelection(cur));
}
-void MathCursor::selDel(BufferView & bv)
+void MathCursor::selDel(LCursor & cur)
{
dump("selDel");
if (selection_) {
- eraseSelection(bv);
+ eraseSelection(cur);
selection_ = false;
}
}
-void MathCursor::selPaste(BufferView & bv, size_t n)
+void MathCursor::selPaste(LCursor & cur, size_t n)
{
dump("selPaste");
- selClearOrDel(bv);
+ selClearOrDel(cur);
if (n < theCutBuffer.size())
- paste(bv, theCutBuffer[n]);
- //grabSelection(bv);
+ paste(cur, theCutBuffer[n]);
+ //grabSelection(cur);
selection_ = false;
}
-void MathCursor::selHandle(BufferView & bv, bool sel)
+void MathCursor::selHandle(LCursor & cur, bool sel)
{
if (sel == selection_)
return;
//clear();
- bv.resetAnchor();
+ cur.resetAnchor();
selection_ = sel;
}
-void MathCursor::selStart(BufferView & bv)
+void MathCursor::selStart(LCursor & cur)
{
dump("selStart 1");
//clear();
- bv.resetAnchor();
+ cur.resetAnchor();
selection_ = true;
dump("selStart 2");
}
-void MathCursor::selClearOrDel(BufferView & bv)
+void MathCursor::selClearOrDel(LCursor & cur)
{
if (lyxrc.auto_region_delete)
- selDel(bv);
+ selDel(cur);
else
selection_ = false;
}
return;
CursorSlice i1;
CursorSlice i2;
- getSelection(*pi.base.bv, i1, i2);
+ getSelection(pi.base.bv->fullCursor(), i1, i2);
i1.asMathInset()->drawSelection(pi, i1.idx_, i1.pos_, i2.idx_, i2.pos_);
}
-void MathCursor::handleNest(BufferView & bv, MathAtom const & a, int c)
+void MathCursor::handleNest(LCursor & cur, MathAtom const & a, int c)
{
MathAtom at = a;
- asArray(grabAndEraseSelection(bv), at.nucleus()->cell(c));
- insert(bv, at);
- pushRight(bv, prevAtom(bv));
+ asArray(grabAndEraseSelection(cur), at.nucleus()->cell(c));
+ insert(cur, at);
+ pushRight(cur, prevAtom(cur));
}
-void MathCursor::getScreenPos(BufferView & bv, int & x, int & y) const
+void MathCursor::getScreenPos(LCursor & cur, int & x, int & y) const
{
- CursorSlice & cur = cursorTip(bv);
cur.inset()->asMathInset()->getScreenPos(cur.idx(), cur.pos(), x, y);
}
-int MathCursor::targetX(BufferView & bv) const
+int MathCursor::targetX(LCursor & cur) const
{
- if (bv.x_target() != -1)
- return bv.x_target();
+ if (cur.bv().x_target() != -1)
+ return cur.bv().x_target();
int x = 0;
int y = 0;
- getScreenPos(bv, x, y);
+ getScreenPos(cur, x, y);
return x;
}
}
-void MathCursor::adjust(BufferView & bv, pos_type from, difference_type diff)
+void MathCursor::adjust(LCursor & cur, pos_type from, difference_type diff)
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() > from)
cur.pos() += diff;
#warning FIXME
// just to be on the safe side
// theoretically unecessary
#endif
- normalize(bv);
+ normalize(cur);
}
-bool MathCursor::inMacroMode(BufferView & bv) const
+bool MathCursor::inMacroMode(LCursor & cur) const
{
- if (!hasPrevAtom(bv))
+ if (!hasPrevAtom(cur))
return false;
- MathUnknownInset const * p = prevAtom(bv)->asUnknownInset();
+ MathUnknownInset const * p = prevAtom(cur)->asUnknownInset();
return p && !p->final();
}
-MathUnknownInset * MathCursor::activeMacro(BufferView & bv)
+MathUnknownInset * MathCursor::activeMacro(LCursor & cur)
{
- return inMacroMode(bv) ? prevAtom(bv).nucleus()->asUnknownInset() : 0;
+ return inMacroMode(cur) ? prevAtom(cur).nucleus()->asUnknownInset() : 0;
}
-MathUnknownInset const * MathCursor::activeMacro(BufferView & bv) const
+MathUnknownInset const * MathCursor::activeMacro(LCursor & cur) const
{
- return inMacroMode(bv) ? prevAtom(bv)->asUnknownInset() : 0;
+ return inMacroMode(cur) ? prevAtom(cur)->asUnknownInset() : 0;
}
-bool MathCursor::inMacroArgMode(BufferView & bv) const
+bool MathCursor::inMacroArgMode(LCursor & cur) const
{
- return bv.cursor().pos() > 0 && prevAtom(bv)->getChar() == '#';
+ return cur.pos() > 0 && prevAtom(cur)->getChar() == '#';
}
}
-MathGridInset * MathCursor::enclosingGrid
- (BufferView &, MathCursor::idx_type &) const
+MathGridInset *
+MathCursor::enclosingGrid(LCursor & cur, MathCursor::idx_type & idx) const
{
-#warning FIXME
-#if 0
- for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
- MathGridInset * p = Cursor_[i].asMathInset()->asGridInset();
+ for (MathInset::difference_type i = cur.depth() - 1; i >= 0; --i) {
+ MathInset * m = cur.cursor_[i].inset()->asMathInset();
+ if (!m)
+ return 0;
+ MathGridInset * p = m->asGridInset();
if (p) {
- idx = Cursor_[i].idx_;
+ idx = cur.cursor_[i].idx_;
return p;
}
}
-#endif
return 0;
}
-void MathCursor::popToHere(BufferView & bv, MathInset const * p)
+void MathCursor::popToHere(LCursor & cur, MathInset const * p)
{
- while (depth(bv) && bv.cursor().asMathInset() != p)
- bv.fullCursor().cursor_.pop_back();
+ while (cur.depth() && cur.inset()->asMathInset() != p)
+ cur.pop();
}
-void MathCursor::popToEnclosingGrid(BufferView & bv)
+void MathCursor::popToEnclosingGrid(LCursor & cur)
{
- while (depth(bv) && !bv.cursor().asMathInset()->asGridInset())
- bv.fullCursor().cursor_.pop_back();
+ while (cur.depth() && !cur.inset()->asMathInset()->asGridInset())
+ cur.pop();
}
-void MathCursor::popToEnclosingHull(BufferView & bv)
+void MathCursor::popToEnclosingHull(LCursor & cur)
{
- while (depth(bv) && !bv.cursor().asMathInset()->asGridInset())
- bv.fullCursor().cursor_.pop_back();
+ while (cur.depth() && !cur.inset()->asMathInset()->asGridInset())
+ cur.pop();
}
-void MathCursor::pullArg(BufferView & bv)
+void MathCursor::pullArg(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
dump("pullarg");
MathArray ar = cur.cell();
- if (popLeft(bv)) {
- plainErase(bv);
+ if (popLeft(cur)) {
+ plainErase(cur);
cur.cell().insert(cur.pos(), ar);
- bv.resetAnchor();
+ cur.resetAnchor();
} else {
formula()->mutateToText();
}
}
-void MathCursor::normalize(BufferView & bv)
+void MathCursor::normalize(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
if (cur.idx() >= cur.nargs()) {
lyxerr << "this should not really happen - 1: "
<< cur.idx() << ' ' << cur.nargs()
}
-bool MathCursor::hasPrevAtom(BufferView & bv) const
+bool MathCursor::hasPrevAtom(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
return cur.pos() > 0;
}
-bool MathCursor::hasNextAtom(BufferView & bv) const
+bool MathCursor::hasNextAtom(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
return cur.pos() < cur.lastpos();
}
-MathAtom const & MathCursor::prevAtom(BufferView & bv) const
+MathAtom const & MathCursor::prevAtom(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
BOOST_ASSERT(cur.pos() > 0);
return cur.cell()[cur.pos() - 1];
}
-MathAtom & MathCursor::prevAtom(BufferView & bv)
+MathAtom & MathCursor::prevAtom(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
BOOST_ASSERT(cur.pos() > 0);
return cur.cell()[cur.pos() - 1];
}
-MathAtom const & MathCursor::nextAtom(BufferView & bv) const
+MathAtom const & MathCursor::nextAtom(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
BOOST_ASSERT(cur.pos() < cur.lastpos());
return cur.cell()[cur.pos()];
}
-MathAtom & MathCursor::nextAtom(BufferView & bv)
+MathAtom & MathCursor::nextAtom(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
BOOST_ASSERT(cur.pos() < cur.lastpos());
return cur.cell()[cur.pos()];
}
-void MathCursor::idxNext(BufferView & bv)
+void MathCursor::idxNext(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
- cur.inset()->asMathInset()->idxNext(bv);
+ cur.inset()->asMathInset()->idxNext(cur);
}
-void MathCursor::idxPrev(BufferView & bv)
+void MathCursor::idxPrev(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
- cur.inset()->asMathInset()->idxPrev(bv);
+ cur.inset()->asMathInset()->idxPrev(cur);
}
-char MathCursor::valign(BufferView & bv) const
+char MathCursor::valign(LCursor & cur) const
{
idx_type idx;
- MathGridInset * p = enclosingGrid(bv, idx);
+ MathGridInset * p = enclosingGrid(cur, idx);
return p ? p->valign() : '\0';
}
-char MathCursor::halign(BufferView & bv) const
+char MathCursor::halign(LCursor & cur) const
{
idx_type idx;
- MathGridInset * p = enclosingGrid(bv, idx);
+ MathGridInset * p = enclosingGrid(cur, idx);
return p ? p->halign(idx % p->ncols()) : '\0';
}
-void MathCursor::getSelection(BufferView & bv,
+void MathCursor::getSelection(LCursor & cur,
CursorSlice & i1, CursorSlice & i2) const
{
- CursorSlice anc = normalAnchor(bv);
- if (anc < bv.cursor()) {
+ CursorSlice anc = normalAnchor(cur);
+ if (anc < cur.top()) {
i1 = anc;
- i2 = bv.cursor();
+ i2 = cur.top();
} else {
- i1 = bv.cursor();
+ i1 = cur.top();
i2 = anc;
}
}
-bool MathCursor::goUpDown(BufferView & bv, bool up)
+bool MathCursor::goUpDown(LCursor & cur, bool up)
{
// Be warned: The 'logic' implemented in this function is highly fragile.
// A distance of one pixel or a '<' vs '<=' _really_ matters.
// So fiddle around with it only if you know what you are doing!
int xo = 0;
int yo = 0;
- getScreenPos(bv, xo, yo);
+ getScreenPos(cur, xo, yo);
// check if we had something else in mind, if not, this is the future goal
- if (bv.x_target() == -1)
- bv.x_target(xo);
+ if (cur.bv().x_target() == -1)
+ cur.bv().x_target(xo);
else
- xo = bv.x_target();
+ xo = cur.bv().x_target();
// try neigbouring script insets
if (!selection()) {
// try left
- if (hasPrevAtom(bv)) {
- MathScriptInset const * p = prevAtom(bv)->asScriptInset();
+ if (hasPrevAtom(cur)) {
+ MathScriptInset const * p = prevAtom(cur)->asScriptInset();
if (p && p->has(up)) {
- --bv.cursor().pos();
- push(bv, nextAtom(bv));
- bv.cursor().idx() = up; // the superscript has index 1
- bv.cursor().pos() = bv.cursor().lastpos();
+ --cur.pos();
+ push(cur, nextAtom(cur));
+ cur.idx() = up; // the superscript has index 1
+ cur.pos() = cur.lastpos();
//lyxerr << "updown: handled by scriptinset to the left" << endl;
return true;
}
}
// try right
- if (hasNextAtom(bv)) {
- MathScriptInset const * p = nextAtom(bv)->asScriptInset();
+ if (hasNextAtom(cur)) {
+ MathScriptInset const * p = nextAtom(cur)->asScriptInset();
if (p && p->has(up)) {
- push(bv, nextAtom(bv));
- bv.cursor().idx() = up;
- bv.cursor().pos() = 0;
+ push(cur, nextAtom(cur));
+ cur.idx() = up;
+ cur.pos() = 0;
//lyxerr << "updown: handled by scriptinset to the right" << endl;
return true;
}
}
// try current cell for e.g. text insets
- if (bv.cursor().inset()->asMathInset()->idxUpDown2(bv, up, bv.x_target()))
+ if (cur.inset()->asMathInset()->idxUpDown2(cur, up, cur.bv().x_target()))
return true;
//xarray().boundingBox(xlow, xhigh, ylow, yhigh);
while (1) {
//lyxerr << "updown: We are in " << inset() << " idx: " << idx() << endl;
// ask inset first
- if (bv.cursor().inset()->asMathInset()->idxUpDown(bv, up, bv.x_target())) {
+ if (cur.inset()->asMathInset()->idxUpDown(cur, up, cur.bv().x_target())) {
// try to find best position within this inset
if (!selection())
- bruteFind2(bv, xo, yo);
+ bruteFind2(cur, xo, yo);
return true;
}
// no such inset found, just take something "above"
//lyxerr << "updown: handled by strange case" << endl;
- if (!popLeft(bv))
+ if (!popLeft(cur))
return
- bruteFind(bv, xo, yo,
+ bruteFind(cur, xo, yo,
formula()->xlow(),
formula()->xhigh(),
up ? formula()->ylow() : yo + 4,
// any improvement so far?
int xnew, ynew;
- getScreenPos(bv, xnew, ynew);
+ getScreenPos(cur, xnew, ynew);
if (up ? ynew < yo : ynew > yo)
return true;
}
bool MathCursor::bruteFind
- (BufferView & bv, int x, int y, int xlow, int xhigh, int ylow, int yhigh)
+ (LCursor & cur, int x, int y, int xlow, int xhigh, int ylow, int yhigh)
{
CursorBase best_cursor;
double best_dist = 1e10;
CursorBase et = iend(formula()->par().nucleus());
while (1) {
// avoid invalid nesting when selecting
- if (!selection_ || positionable(it, bv.fullCursor().anchor_)) {
+ if (!selection_ || positionable(it, cur.anchor_)) {
int xo, yo;
it.back().getScreenPos(xo, yo);
if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
}
if (best_dist < 1e10)
- bv.fullCursor().cursor_ = best_cursor;
+ cur.cursor_ = best_cursor;
return best_dist < 1e10;
}
-void MathCursor::bruteFind2(BufferView & bv, int x, int y)
+void MathCursor::bruteFind2(LCursor & cur, int x, int y)
{
double best_dist = 1e10;
- CursorBase it = bv.fullCursor().cursor_;
+ CursorBase it = cur.cursor_;
it.back().pos(0);
- CursorBase et = bv.fullCursor().cursor_;
+ CursorBase et = cur.cursor_;
int n = et.back().asMathInset()->cell(et.back().idx_).size();
et.back().pos(n);
for (int i = 0; ; ++i) {
lyxerr << "i: " << i << " d: " << d << " best: " << best_dist << endl;
if (d <= best_dist) {
best_dist = d;
- bv.fullCursor().cursor_ = it;
+ cur.cursor_ = it;
}
if (it == et)
break;
}
-bool MathCursor::idxLineLast(BufferView & bv)
+bool MathCursor::idxLineLast(LCursor & cur)
{
- CursorSlice & cur = bv.cursor();
cur.idx() -= cur.idx() % cur.ncols();
cur.idx() += cur.ncols() - 1;
cur.pos() = cur.lastpos();
}
-bool MathCursor::idxLeft(BufferView & bv)
+bool MathCursor::idxLeft(LCursor & cur)
{
- return bv.cursor().inset()->asMathInset()->idxLeft(bv);
+ return cur.inset()->asMathInset()->idxLeft(cur);
}
-bool MathCursor::idxRight(BufferView & bv)
+bool MathCursor::idxRight(LCursor & cur)
{
- return bv.cursor().inset()->asMathInset()->idxRight(bv);
+ return cur.inset()->asMathInset()->idxRight(cur);
}
-bool MathCursor::script(BufferView & bv, bool up)
+bool MathCursor::script(LCursor & cur, bool up)
{
// Hack to get \\^ and \\_ working
- if (inMacroMode(bv) && macroName(bv) == "\\") {
+ if (inMacroMode(cur) && macroName(cur) == "\\") {
if (up)
- niceInsert(bv, createMathInset("mathcircumflex"));
+ niceInsert(cur, createMathInset("mathcircumflex"));
else
- interpret(bv, '_');
+ interpret(cur, '_');
return true;
}
- macroModeClose(bv);
- string safe = grabAndEraseSelection(bv);
- if (inNucleus(bv)) {
+ macroModeClose(cur);
+ string safe = grabAndEraseSelection(cur);
+ if (inNucleus(cur)) {
// we are in a nucleus of a script inset, move to _our_ script
- bv.cursor().inset()->asMathInset()->asScriptInset()->ensure(up);
- bv.cursor().idx() = up;
- bv.cursor().pos() = 0;
- } else if (hasPrevAtom(bv) && prevAtom(bv)->asScriptInset()) {
- prevAtom(bv).nucleus()->asScriptInset()->ensure(up);
- pushRight(bv, prevAtom(bv));
- bv.cursor().idx() = up;
- bv.cursor().pos() = bv.cursor().lastpos();
- } else if (hasPrevAtom(bv)) {
- --bv.cursor().pos();
- bv.cursor().cell()[bv.cursor().pos()]
- = MathAtom(new MathScriptInset(nextAtom(bv), up));
- pushLeft(bv, nextAtom(bv));
- bv.cursor().idx() = up;
- bv.cursor().pos() = 0;
+ cur.inset()->asMathInset()->asScriptInset()->ensure(up);
+ cur.idx() = up;
+ cur.pos() = 0;
+ } else if (hasPrevAtom(cur) && prevAtom(cur)->asScriptInset()) {
+ prevAtom(cur).nucleus()->asScriptInset()->ensure(up);
+ pushRight(cur, prevAtom(cur));
+ cur.idx() = up;
+ cur.pos() = cur.lastpos();
+ } else if (hasPrevAtom(cur)) {
+ --cur.pos();
+ cur.cell()[cur.pos()]
+ = MathAtom(new MathScriptInset(nextAtom(cur), up));
+ pushLeft(cur, nextAtom(cur));
+ cur.idx() = up;
+ cur.pos() = 0;
} else {
- plainInsert(bv, MathAtom(new MathScriptInset(up)));
- prevAtom(bv).nucleus()->asScriptInset()->ensure(up);
- pushRight(bv, prevAtom(bv));
- bv.cursor().idx() = up;
- bv.cursor().pos() = 0;
+ plainInsert(cur, MathAtom(new MathScriptInset(up)));
+ prevAtom(cur).nucleus()->asScriptInset()->ensure(up);
+ pushRight(cur, prevAtom(cur));
+ cur.idx() = up;
+ cur.pos() = 0;
}
- paste(bv, safe);
+ paste(cur, safe);
dump("1");
return true;
}
-bool MathCursor::interpret(BufferView & bv, char c)
+bool MathCursor::interpret(LCursor & cur, char c)
{
//lyxerr << "interpret 2: '" << c << "'" << endl;
- CursorSlice & cur = bv.cursor();
- bv.x_target(-1); // "no target"
- if (inMacroArgMode(bv)) {
+ cur.bv().x_target(-1); // "no target"
+ if (inMacroArgMode(cur)) {
--cur.pos();
- plainErase(bv);
+ plainErase(cur);
int n = c - '0';
MathMacroTemplate const * p = formula()->par()->asMacroTemplate();
if (p && 1 <= n && n <= p->numargs())
- insert(bv, MathAtom(new MathMacroArgument(c - '0')));
+ insert(cur, MathAtom(new MathMacroArgument(c - '0')));
else {
- insert(bv, createMathInset("#"));
- interpret(bv, c); // try again
+ insert(cur, createMathInset("#"));
+ interpret(cur, c); // try again
}
return true;
}
// handle macroMode
- if (inMacroMode(bv)) {
- string name = macroName(bv);
+ if (inMacroMode(cur)) {
+ string name = macroName(cur);
//lyxerr << "interpret name: '" << name << "'" << endl;
if (isalpha(c)) {
- activeMacro(bv)->setName(activeMacro(bv)->name() + c);
+ activeMacro(cur)->setName(activeMacro(cur)->name() + c);
return true;
}
// handle 'special char' macros
if (name == "\\") {
// remove the '\\'
- backspace(bv);
+ backspace(cur);
if (c == '\\') {
- if (currentMode(bv) == MathInset::TEXT_MODE)
- niceInsert(bv, createMathInset("textbackslash"));
+ if (currentMode(cur) == MathInset::TEXT_MODE)
+ niceInsert(cur, createMathInset("textbackslash"));
else
- niceInsert(bv, createMathInset("backslash"));
+ niceInsert(cur, createMathInset("backslash"));
} else if (c == '{') {
- niceInsert(bv, MathAtom(new MathBraceInset));
+ niceInsert(cur, MathAtom(new MathBraceInset));
} else {
- niceInsert(bv, createMathInset(string(1, c)));
+ niceInsert(cur, createMathInset(string(1, c)));
}
return true;
}
// leave macro mode and try again if necessary
- macroModeClose(bv);
+ macroModeClose(cur);
if (c == '{')
- niceInsert(bv, MathAtom(new MathBraceInset));
+ niceInsert(cur, MathAtom(new MathBraceInset));
else if (c != ' ')
- interpret(bv, c);
+ interpret(cur, c);
return true;
}
return true;
}
- selClearOrDel(bv);
+ selClearOrDel(cur);
if (c == '\\') {
//lyxerr << "starting with macro" << endl;
- insert(bv, MathAtom(new MathUnknownInset("\\", false)));
+ insert(cur, MathAtom(new MathUnknownInset("\\", false)));
return true;
}
if (c == '\n') {
- if (currentMode(bv) == MathInset::TEXT_MODE)
- insert(bv, c);
+ if (currentMode(cur) == MathInset::TEXT_MODE)
+ insert(cur, c);
return true;
}
if (c == ' ') {
- if (currentMode(bv) == MathInset::TEXT_MODE) {
+ if (currentMode(cur) == MathInset::TEXT_MODE) {
// insert spaces in text mode,
// but suppress direct insertion of two spaces in a row
// the still allows typing '<space>a<space>' and deleting the 'a', but
// it is better than nothing...
- if (!hasPrevAtom(bv) || prevAtom(bv)->getChar() != ' ')
- insert(bv, c);
+ if (!hasPrevAtom(cur) || prevAtom(cur)->getChar() != ' ')
+ insert(cur, c);
return true;
}
- if (hasPrevAtom(bv) && prevAtom(bv)->asSpaceInset()) {
- prevAtom(bv).nucleus()->asSpaceInset()->incSpace();
+ if (hasPrevAtom(cur) && prevAtom(cur)->asSpaceInset()) {
+ prevAtom(cur).nucleus()->asSpaceInset()->incSpace();
return true;
}
- if (popRight(bv))
+ if (popRight(cur))
return true;
// if are at the very end, leave the formula
return cur.pos() != cur.lastpos();
}
if (c == '_') {
- script(bv, false);
+ script(cur, false);
return true;
}
if (c == '^') {
- script(bv, true);
+ script(cur, true);
return true;
}
if (c == '{' || c == '}' || c == '#' || c == '&' || c == '$') {
- niceInsert(bv, createMathInset(string(1, c)));
+ niceInsert(cur, createMathInset(string(1, c)));
return true;
}
if (c == '%') {
- niceInsert(bv, MathAtom(new MathCommentInset));
+ niceInsert(cur, MathAtom(new MathCommentInset));
return true;
}
// return true;
// no special circumstances, so insert the character without any fuss
- insert(bv, c);
+ insert(cur, c);
autocorrect_ = true;
return true;
}
void MathCursor::setSelection
- (BufferView & bv, CursorBase const & where, size_t n)
+ (LCursor & cur, CursorBase const & where, size_t n)
{
selection_ = true;
- bv.fullCursor().cursor_ = where;
- bv.fullCursor().anchor_ = where;
- bv.cursor().pos_ += n;
+ cur.cursor_ = where;
+ cur.anchor_ = where;
+ cur.pos() += n;
}
-void MathCursor::insetToggle(BufferView & bv)
+void MathCursor::insetToggle(LCursor & cur)
{
- if (hasNextAtom(bv)) {
+ if (hasNextAtom(cur)) {
// toggle previous inset ...
- nextAtom(bv).nucleus()->lock(!nextAtom(bv)->lock());
- } else if (popLeft(bv) && hasNextAtom(bv)) {
+ nextAtom(cur).nucleus()->lock(!nextAtom(cur)->lock());
+ } else if (popLeft(cur) && hasNextAtom(cur)) {
// ... or enclosing inset if we are in the last inset position
- nextAtom(bv).nucleus()->lock(!nextAtom(bv)->lock());
- posRight(bv);
+ nextAtom(cur).nucleus()->lock(!nextAtom(cur)->lock());
+ posRight(cur);
}
}
-string MathCursor::info(BufferView & bv) const
+string MathCursor::info(LCursor & cur) const
{
ostringstream os;
os << "Math editor mode. ";
- for (int i = 0, n = depth(bv); i < n; ++i) {
- bv.fullCursor().cursor_[i].asMathInset()->infoize(os);
+ for (int i = 0, n = cur.depth(); i < n; ++i) {
+ cur.cursor_[i].asMathInset()->infoize(os);
os << " ";
}
- if (hasPrevAtom(bv))
- prevAtom(bv)->infoize2(os);
+ if (hasPrevAtom(cur))
+ prevAtom(cur)->infoize2(os);
os << " ";
return os.str();
}
-unsigned MathCursor::depth(BufferView & bv) const
-{
- return bv.fullCursor().cursor_.size();
-}
-
-
-
-
namespace {
void region(CursorSlice const & i1, CursorSlice const & i2,
}
-string MathCursor::grabSelection(BufferView & bv) const
+string MathCursor::grabSelection(LCursor & cur) const
{
if (!selection_)
return string();
CursorSlice i1;
CursorSlice i2;
- getSelection(bv, i1, i2);
+ getSelection(cur, i1, i2);
if (i1.idx_ == i2.idx_) {
MathArray::const_iterator it = i1.cell().begin();
}
-void MathCursor::eraseSelection(BufferView & bv)
+void MathCursor::eraseSelection(LCursor & cur)
{
CursorSlice i1;
CursorSlice i2;
- getSelection(bv, i1, i2);
+ getSelection(cur, i1, i2);
if (i1.idx_ == i2.idx_)
i1.cell().erase(i1.pos_, i2.pos_);
else {
for (col_type col = c1; col <= c2; ++col)
p->cell(p->index(row, col)).clear();
}
- bv.cursor() = i1;
+ cur.top() = i1;
}
-string MathCursor::grabAndEraseSelection(BufferView & bv)
+string MathCursor::grabAndEraseSelection(LCursor & cur)
{
if (!selection_)
return string();
- string res = grabSelection(bv);
- eraseSelection(bv);
+ string res = grabSelection(cur);
+ eraseSelection(cur);
selection_ = false;
return res;
}
-CursorSlice MathCursor::normalAnchor(BufferView & bv) const
+CursorSlice MathCursor::normalAnchor(LCursor & cur) const
{
#warning FIXME
#if 0
- if (Anchor_.size() < depth()) {
- bv.resetAnchor();
+ if (Anchor_.size() < cur.depth()) {
+ cur.resetAnchor();
lyxerr << "unusual Anchor size" << endl;
}
- //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
+ //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.cur.depth());
// use Anchor on the same level as Cursor
- CursorSlice normal = Anchor_[depth() - 1];
- if (depth() < Anchor_.size() && !(normal < cursor())) {
+ CursorSlice normal = Anchor_[cur.depth() - 1];
+ if (cur.depth() < Anchor_.size() && !(normal < cursor())) {
// anchor is behind cursor -> move anchor behind the inset
++normal.pos_;
}
return normal;
#else
- return bv.cursor();
+ return cur.top();
#endif
}
-DispatchResult MathCursor::dispatch(BufferView &, FuncRequest const & cmd)
+DispatchResult MathCursor::dispatch(LCursor &, FuncRequest const & cmd)
{
// mouse clicks are somewhat special
// check
getScreenPos(x, y);
if (x < cmd.x && hasPrevAtom()) {
DispatchResult const res =
- prevAtom().nucleus()->dispatch(bv, cmd);
+ prevAtom().nucleus()->dispatch(cur, cmd);
if (res.dispatched())
return res;
}
if (x > cmd.x && hasNextAtom()) {
DispatchResult const res =
- nextAtom().nucleus()->dispatch(bv, cmd);
+ nextAtom().nucleus()->dispatch(cur, cmd);
if (res.dispatched())
return res;
}
}
/*
- for (int i = Cursor_.size() - 1; i >= 0; --i) {
- CursorBase tmp = bv->Cursor_;
+ for (int i = cur.depth() - 1; i >= 0; --i) {
+ CursorBase tmp = cur->cursor_;
CursorSlice & pos = tmp.back()
- DispatchResult const res = pos.asMathInset()->dispatch(bv, cmd);
+ DispatchResult const res = pos.asMathInset()->dispatch(cur, cmd);
if (res.dispatched()) {
if (res.val() == FINISHED) {
if (i + 1 < Cursor_.size())
}
-MathInset::mode_type MathCursor::currentMode(BufferView &) const
+MathInset::mode_type MathCursor::currentMode(LCursor &) const
{
#if 0
for (int i = Cursor_.size() - 1; i >= 0; --i) {
}
-void MathCursor::handleFont(BufferView & bv, string const & font)
+void MathCursor::handleFont(LCursor & cur, string const & font)
{
- CursorSlice cur = cursorTip(bv);
string safe;
if (selection()) {
- macroModeClose(bv);
- safe = grabAndEraseSelection(bv);
+ macroModeClose(cur);
+ safe = grabAndEraseSelection(cur);
}
if (cur.lastpos() != 0) {
// something left in the cell
if (cur.pos() == 0) {
// cursor in first position
- popLeft(bv);
+ popLeft(cur);
} else if (cur.pos() == cur.lastpos()) {
// cursor in last position
- popRight(bv);
+ popRight(cur);
} else {
// cursor in between. split cell
MathArray::iterator bt = cur.cell().begin();
MathAtom at = createMathInset(font);
at.nucleus()->cell(0) = MathArray(bt, bt + cur.pos());
cur.cell().erase(bt, bt + cur.pos());
- popLeft(bv);
- plainInsert(bv, at);
+ popLeft(cur);
+ plainInsert(cur, at);
}
} else {
// nothing left in the cell
- pullArg(bv);
- plainErase(bv);
+ pullArg(cur);
+ plainErase(cur);
}
- insert(bv, safe);
+ insert(cur, safe);
}
///
~MathCursor();
///
- void insert(BufferView & bv, MathAtom const &);
+ void insert(LCursor & cur, MathAtom const &);
///
- void insert(BufferView & bv, MathArray const &);
+ void insert(LCursor & cur, MathArray const &);
///
- void insert2(BufferView & bv, std::string const &);
+ void insert2(LCursor & cur, std::string const &);
///
- void paste(BufferView & bv, std::string const & data);
+ void paste(LCursor & cur, std::string const & data);
/// return false for empty math insets
- bool erase(BufferView & bv);
+ bool erase(LCursor & cur);
/// return false for empty math insets
- bool backspace(BufferView & bv);
+ bool backspace(LCursor & cur);
/// called for LFUN_HOME etc
- bool home(BufferView & bv, bool sel = false);
+ bool home(LCursor & cur, bool sel = false);
/// called for LFUN_END etc
- bool end(BufferView & bv, bool sel = false);
+ bool end(LCursor & cur, bool sel = false);
/// called for LFUN_RIGHT and LFUN_RIGHTSEL
- bool right(BufferView & bv, bool sel = false);
+ bool right(LCursor & cur, bool sel = false);
/// called for LFUN_LEFT etc
- bool left(BufferView & bv, bool sel = false);
+ bool left(LCursor & cur, bool sel = false);
/// called for LFUN_UP etc
- bool up(BufferView & bv, bool sel = false);
+ bool up(LCursor & cur, bool sel = false);
/// called for LFUN_DOWN etc
- bool down(BufferView & bv, bool sel = false);
+ bool down(LCursor & cur, bool sel = false);
/// Put the cursor in the first position
- void first(BufferView & bv);
+ void first(LCursor & cur);
/// Put the cursor in the last position
- void last(BufferView & bv);
+ void last(LCursor & cur);
/// move to next cell in current inset
- void idxNext(BufferView & bv);
+ void idxNext(LCursor & bv);
/// move to previous cell in current inset
- void idxPrev(BufferView & bv);
+ void idxPrev(LCursor & bv);
///
- void plainErase(BufferView & bv);
+ void plainErase(LCursor & cur);
///
- void plainInsert(BufferView & bv, MathAtom const & at);
+ void plainInsert(LCursor & cur, MathAtom const & at);
///
- void niceInsert(BufferView & bv, MathAtom const & at);
+ void niceInsert(LCursor & cur, MathAtom const & at);
///
- void niceInsert(BufferView & bv, std::string const & str);
+ void niceInsert(LCursor & cur, std::string const & str);
/// in pixels from top of screen
- void setScreenPos(BufferView & bv, int x, int y);
+ void setScreenPos(LCursor & cur, int x, int y);
/// in pixels from top of screen
- void getScreenPos(BufferView & bv, int & x, int & y) const;
+ void getScreenPos(LCursor & cur, int & x, int & y) const;
/// in pixels from left of screen
- int targetX(BufferView & bv) const;
+ int targetX(LCursor & cur) const;
/// return the next enclosing grid inset and the cursor's index in it
- MathGridInset * enclosingGrid(BufferView & bv, idx_type & idx) const;
+ MathGridInset * enclosingGrid(LCursor & cur, idx_type & idx) const;
/// go up to enclosing grid
- void popToEnclosingGrid(BufferView & bv);
+ void popToEnclosingGrid(LCursor & cur);
/// go up to the hull inset
- void popToEnclosingHull(BufferView & bv);
+ void popToEnclosingHull(LCursor & cur);
/// go up to the hull inset
- void popToHere(BufferView & bv, MathInset const * p);
+ void popToHere(LCursor & cur, MathInset const * p);
/// adjust anchor position after deletions/insertions
- void adjust(BufferView & bv, pos_type from, difference_type diff);
+ void adjust(LCursor & cur, pos_type from, difference_type diff);
///
InsetFormulaBase * formula() const;
/// current offset in the current cell
///
- bool script(BufferView & bv, bool);
+ bool script(LCursor & cur, bool);
///
- bool interpret(BufferView & bv, char);
+ bool interpret(LCursor & cur, char);
/// interpret name a name of a macro
- void macroModeClose(BufferView & bv);
+ void macroModeClose(LCursor & cur);
/// are we currently typing the name of a macro?
- bool inMacroMode(BufferView & bv) const;
+ bool inMacroMode(LCursor & cur) const;
/// get access to the macro we are currently typing
- MathUnknownInset * activeMacro(BufferView & bv);
+ MathUnknownInset * activeMacro(LCursor & cur);
/// get access to the macro we are currently typing
- MathUnknownInset const * activeMacro(BufferView & bv) const;
+ MathUnknownInset const * activeMacro(LCursor & cur) const;
/// are we currently typing '#1' or '#2' or...?
- bool inMacroArgMode(BufferView & bv) const;
+ bool inMacroArgMode(LCursor & cur) const;
/// are we in math mode (1), text mode (-1) or unsure?
- MathInset::mode_type currentMode(BufferView & bv) const;
+ MathInset::mode_type currentMode(LCursor & cur) const;
// Local selection methods
///
bool selection() const;
///
- void selCopy(BufferView & bv);
+ void selCopy(LCursor & cur);
///
- void selCut(BufferView & bv);
+ void selCut(LCursor & cur);
///
- void selDel(BufferView & bv);
+ void selDel(LCursor & cur);
/// pastes n-th element of cut buffer
- void selPaste(BufferView & bv, size_t n);
+ void selPaste(LCursor & cur, size_t n);
///
- void selHandle(BufferView & bv, bool);
+ void selHandle(LCursor & cur, bool);
///
- void selStart(BufferView & bv);
+ void selStart(LCursor & cur);
///
- void selClear(BufferView & bv);
+ void selClear(LCursor & cur);
/// clears or deletes selection depending on lyxrc setting
- void selClearOrDel(BufferView & bv);
+ void selClearOrDel(LCursor & cur);
/// draws light-blue selection background
void drawSelection(PainterInfo & pi) const;
/// replace selected stuff with at, placing the former
// selection in given cell of atom
- void handleNest(BufferView & bv, MathAtom const & at, int cell = 0);
+ void handleNest(LCursor & cur, MathAtom const & at, int cell = 0);
/// remove this as soon as LyXFunc::getStatus is "localized"
std::string getLastCode() const { return "mathnormal"; }
///
bool isInside(MathInset const *) const;
///
- char valign(BufferView & bv) const;
+ char valign(LCursor & cur) const;
///
- char halign(BufferView & bv) const;
+ char halign(LCursor & cur) const;
/// make sure cursor position is valid
- void normalize(BufferView & bv);
+ void normalize(LCursor & cur);
/// mark current cursor trace for redraw
void touch();
/// enter a MathInset
- void push(BufferView & bv, MathAtom & par);
+ void push(LCursor & cur, MathAtom & par);
/// enter a MathInset from the front
- void pushLeft(BufferView & bv, MathAtom & par);
+ void pushLeft(LCursor & cur, MathAtom & par);
/// enter a MathInset from the back
- void pushRight(BufferView & bv, MathAtom & par);
+ void pushRight(LCursor & cur, MathAtom & par);
/// leave current MathInset to the left
- bool popLeft(BufferView & bv);
+ bool popLeft(LCursor & cur);
/// leave current MathInset to the left
- bool popRight(BufferView & bv);
+ bool popRight(LCursor & cur);
///
- bool hasPrevAtom(BufferView & bv) const;
+ bool hasPrevAtom(LCursor & cur) const;
///
- bool hasNextAtom(BufferView & bv) const;
+ bool hasNextAtom(LCursor & cur) const;
///
- MathAtom const & prevAtom(BufferView & bv) const;
+ MathAtom const & prevAtom(LCursor & cur) const;
///
- MathAtom & prevAtom(BufferView & bv);
+ MathAtom & prevAtom(LCursor & cur);
///
- MathAtom const & nextAtom(BufferView & bv) const;
+ MathAtom const & nextAtom(LCursor & cur) const;
///
- MathAtom & nextAtom(BufferView & bv);
+ MathAtom & nextAtom(LCursor & cur);
/// returns the selection
- void getSelection(BufferView & bv, CursorSlice &, CursorSlice &) const;
+ void getSelection(LCursor & cur, CursorSlice &, CursorSlice &) const;
/// returns the normalized anchor of the selection
- CursorSlice normalAnchor(BufferView & bv) const;
+ CursorSlice normalAnchor(LCursor & cur) const;
/// how deep are we nested?
- unsigned depth(BufferView & bv) const;
+ unsigned depth(LCursor & cur) const;
/// describe the situation
- std::string info(BufferView & bv) const;
+ std::string info(LCursor & cur) const;
/// dump selection information for debugging
void seldump(char const * str) const;
/// dump selection information for debugging
void dump(char const * str) const;
/// moves on
- void setSelection(BufferView & bv, CursorBase const & where, size_type n);
+ void setSelection(LCursor & cur, CursorBase const & where, size_type n);
/// grab selection marked by anchor and current cursor
- std::string grabSelection(BufferView & bv) const;
+ std::string grabSelection(LCursor & cur) const;
/// guess what
- std::string grabAndEraseSelection(BufferView & bv);
+ std::string grabAndEraseSelection(LCursor & cur);
///
- void insert(BufferView & bv, char c);
+ void insert(LCursor & cur, char c);
///
- void insert(BufferView & bv, std::string const & str);
+ void insert(LCursor & cur, std::string const & str);
/// lock/unlock inset
- void insetToggle(BufferView & bv);
+ void insetToggle(LCursor & cur);
/// hack for reveal codes
- void markInsert(BufferView & bv);
- void markErase(BufferView & bv);
+ void markInsert(LCursor & cur);
+ void markErase(LCursor & cur);
/// injects content of a cell into parent
- void pullArg(BufferView & bv);
+ void pullArg(LCursor & cur);
/// split font inset etc
- void handleFont(BufferView & bv, std::string const & font);
+ void handleFont(LCursor & cur, std::string const & font);
///
- DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
+ DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
private:
/// moves cursor index one cell to the left
- bool idxLeft(BufferView & bv);
+ bool idxLeft(LCursor & bv);
/// moves cursor index one cell to the right
- bool idxRight(BufferView & bv);
+ bool idxRight(LCursor & bv);
/// moves cursor to end of last cell of current line
- bool idxLineLast(BufferView & bv);
+ bool idxLineLast(LCursor & bv);
/// moves cursor position one cell to the left
- bool posLeft(BufferView & bv);
+ bool posLeft(LCursor & cur);
/// moves cursor position one cell to the right
- bool posRight(BufferView & bv);
+ bool posRight(LCursor & cur);
/// moves position somehow up or down
- bool goUpDown(BufferView & bv, bool up);
+ bool goUpDown(LCursor & cur, bool up);
/// moves position closest to (x, y) in given box
- bool bruteFind(BufferView & bv,
+ bool bruteFind(LCursor & cur,
int x, int y, int xlow, int xhigh, int ylow, int yhigh);
/// moves position closest to (x, y) in current cell
- void bruteFind2(BufferView & bv, int x, int y);
+ void bruteFind2(LCursor & cur, int x, int y);
/// are we in a nucleus of a script inset?
- bool inNucleus(BufferView & bv) const;
+ bool inNucleus(LCursor & cur) const;
/// erase the selected part and re-sets the cursor
- void eraseSelection(BufferView & bv);
+ void eraseSelection(LCursor & cur);
/// the name of the macro we are currently inputting
- std::string macroName(BufferView & bv) const;
+ std::string macroName(LCursor & cur) const;
/// where in the curent cell does the macro name start?
- difference_type macroNamePos(BufferView & bv) const;
+ difference_type macroNamePos(LCursor & cur) const;
/// can we enter the inset?
bool openable(MathAtom const &, bool selection) const;
{}
-bool MathFracbaseInset::idxRight(BufferView &) const
+bool MathFracbaseInset::idxRight(LCursor &) const
{
return false;
}
-bool MathFracbaseInset::idxLeft(BufferView &) const
+bool MathFracbaseInset::idxLeft(LCursor &) const
{
return false;
}
-bool MathFracbaseInset::idxUpDown(BufferView & bv, bool up, int targetx) const
+bool MathFracbaseInset::idxUpDown(LCursor & cur, bool up, int targetx) const
{
- CursorSlice & cur = cursorTip(bv);
MathInset::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
if (cur.idx() == target)
return false;
///
MathFracbaseInset();
///
- bool idxUpDown(BufferView &, bool up, int targetx) const;
+ bool idxUpDown(LCursor &, bool up, int targetx) const;
///
- bool idxLeft(BufferView &) const;
+ bool idxLeft(LCursor &) const;
///
- bool idxRight(BufferView &) const;
+ bool idxRight(LCursor &) const;
};
#endif
#include "math_data.h"
#include "math_mathmlstream.h"
#include "math_streamstr.h"
+#include "BufferView.h"
#include "dispatchresult.h"
#include "debug.h"
#include "funcrequest.h"
#include "LColor.h"
+
#include "frontends/Painter.h"
+
#include "support/std_sstream.h"
#include "insets/mailinset.h"
}
-bool MathGridInset::idxUpDown(BufferView & bv, bool up, int targetx) const
+bool MathGridInset::idxUpDown(LCursor & cur, bool up, int targetx) const
{
- CursorSlice & cur = cursorTip(bv);
if (up) {
if (cur.idx() < ncols())
return false;
}
-bool MathGridInset::idxLeft(BufferView & bv) const
+bool MathGridInset::idxLeft(LCursor & cur) const
{
// leave matrix if on the left hand edge
- CursorSlice & cur = cursorTip(bv);
if (cur.col() == 0)
return false;
--cur.idx();
}
-bool MathGridInset::idxRight(BufferView & bv) const
+bool MathGridInset::idxRight(LCursor & cur) const
{
// leave matrix if on the right hand edge
- CursorSlice & cur = cursorTip(bv);
if (cur.col() + 1 == ncols())
return false;
++cur.idx();
}
-bool MathGridInset::idxFirst(BufferView & bv) const
+bool MathGridInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
switch (v_align_) {
case 't':
cur.idx() = 0;
}
-bool MathGridInset::idxLast(BufferView & bv) const
+bool MathGridInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
switch (v_align_) {
case 't':
cur.idx() = ncols() - 1;
}
-bool MathGridInset::idxHome(BufferView & bv) const
+bool MathGridInset::idxHome(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() > 0) {
cur.pos() = 0;
return true;
}
-bool MathGridInset::idxEnd(BufferView & bv) const
+bool MathGridInset::idxEnd(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() < cur.lastpos()) {
cur.pos() = cur.lastpos();
return true;
}
-void MathGridInset::splitCell(BufferView & bv)
+void MathGridInset::splitCell(LCursor & cur)
{
- CursorSlice & cur = cursorTip(bv);
if (cur.idx() + 1 == nargs())
return;
MathArray ar = cur.cell();
DispatchResult
MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
{
- CursorSlice & cur = cursorTip(bv);
+ LCursor & cur = bv.fullCursor();
switch (cmd.action) {
case LFUN_MOUSE_RELEASE:
case LFUN_CELL_SPLIT:
//recordUndo(bv, Undo::ATOMIC);
- splitCell(bv);
+ splitCell(cur);
return DispatchResult(true, FINISHED);
case LFUN_BREAKLINE: {
std::swap(cell(index(r, c)), cell(index(r + 1, c)));
// split cell
- splitCell(bv);
+ splitCell(cur);
std::swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
if (cur.idx() > 0)
--cur.idx();
row_type row(idx_type idx) const;
///
- bool idxUpDown(BufferView &, bool up, int targetx) const;
+ bool idxUpDown(LCursor &, bool up, int targetx) const;
///
- bool idxLeft(BufferView &) const;
+ bool idxLeft(LCursor &) const;
///
- bool idxRight(BufferView &) const;
+ bool idxRight(LCursor &) const;
///
- bool idxFirst(BufferView &) const;
+ bool idxFirst(LCursor &) const;
///
- bool idxLast(BufferView &) const;
+ bool idxLast(LCursor &) const;
///
- bool idxHome(BufferView &) const;
+ bool idxHome(LCursor &) const;
///
- bool idxEnd(BufferView &) const;
+ bool idxEnd(LCursor &) const;
///
bool idxDelete(idx_type & idx);
/// pulls cell after pressing erase
protected:
///
- virtual
- DispatchResult
- priv_dispatch(BufferView & bv, FuncRequest const & cmd);
-
+ DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
/// returns x offset of cell compared to inset
int cellXOffset(idx_type idx) const;
/// returns y offset of cell compared to inset
/// extract number of columns from alignment string
col_type guessColumns(std::string const & halign) const;
/// splits cells and shifts right part to the next cell
- void splitCell(BufferView & pos);
+ void splitCell(LCursor & cur);
public:
/// row info
#include "math_extern.h"
#include "math_charinset.h"
#include "textpainter.h"
+#include "BufferView.h"
#include "dispatchresult.h"
#include "debug.h"
#include "funcrequest.h"
}
-bool MathHullInset::idxFirst(BufferView & bv) const
+bool MathHullInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 0;
cur.pos() = 0;
return true;
}
-bool MathHullInset::idxLast(BufferView & bv) const
+bool MathHullInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = nargs() - 1;
cur.pos() = cur.lastpos();
return true;
}
-void MathHullInset::doExtern(FuncRequest const & func, BufferView & bv)
+void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
{
- CursorSlice & cur = cursorTip(bv);
string lang;
string extra;
istringstream iss(func.argument.c_str());
size_type pos = cur.cell().find_last(eq);
MathArray ar;
if (mathcursor && mathcursor->selection()) {
- asArray(mathcursor->grabAndEraseSelection(bv), ar);
+ asArray(mathcursor->grabAndEraseSelection(cur), ar);
} else if (pos == cur.cell().size()) {
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
}
case LFUN_MATH_EXTERN:
- doExtern(cmd, bv);
+ doExtern(bv.fullCursor(), cmd);
return DispatchResult(true, FINISHED);
case LFUN_MATH_MUTATE: {
///
char defaultColAlign(col_type col);
///
- bool idxFirst(BufferView &) const;
+ bool idxFirst(LCursor &) const;
///
- bool idxLast(BufferView &) const;
+ bool idxLast(LCursor &) const;
///
std::string fileInsetLabel() const;
///
std::string nicelabel(row_type row) const;
///
- void doExtern(FuncRequest const & func, BufferView &);
+ void doExtern(LCursor & cur, FuncRequest const & func);
///
void glueall();
///
{}
-bool MathInset::idxNext(BufferView &) const
+bool MathInset::idxNext(LCursor &) const
{
return false;
}
-bool MathInset::idxRight(BufferView &) const
+bool MathInset::idxRight(LCursor &) const
{
return false;
}
-bool MathInset::idxPrev(BufferView &) const
+bool MathInset::idxPrev(LCursor &) const
{
return false;
}
-bool MathInset::idxLeft(BufferView &) const
+bool MathInset::idxLeft(LCursor &) const
{
return false;
}
-bool MathInset::idxUpDown(BufferView &, bool, int) const
+bool MathInset::idxUpDown(LCursor &, bool, int) const
{
return false;
}
-bool MathInset::idxUpDown2(BufferView &, bool, int) const
+bool MathInset::idxUpDown2(LCursor &, bool, int) const
{
return false;
}
-bool MathInset::idxFirst(BufferView &) const
+bool MathInset::idxFirst(LCursor &) const
{
return false;
}
-bool MathInset::idxLast(BufferView &) const
+bool MathInset::idxLast(LCursor &) const
{
return false;
}
-bool MathInset::idxHome(BufferView &) const
+bool MathInset::idxHome(LCursor &) const
{
return false;
}
-bool MathInset::idxEnd(BufferView &) const
+bool MathInset::idxEnd(LCursor &) const
{
return false;
}
#ifndef MATH_INSET_H
#define MATH_INSET_H
-#include "cursor_slice.h"
+#include "cursor.h"
#include "insets/insetbase.h"
#include <string>
class WriteStream;
class InfoStream;
-class BufferView;
-class UpdatableInset;
class MathMacroTemplate;
class MathMacro;
class MathPosFinder;
class Dimension;
-class FuncRequest;
class TextPainter;
class TextMetricsInfo;
class ReplaceData;
virtual void drawT(TextPainter &, int x, int y) const;
/// Where should we go when we press the up or down cursor key?
- virtual bool idxUpDown(BufferView & bv, bool up, int targetx) const;
+ virtual bool idxUpDown(LCursor & cur, bool up, int targetx) const;
/// Where should we go when we press the up or down cursor key?
- virtual bool idxUpDown2(BufferView & bv, bool up, int targetx) const;
+ virtual bool idxUpDown2(LCursor & cur, bool up, int targetx) const;
/// The left key
- virtual bool idxLeft(BufferView & bv) const;
+ virtual bool idxLeft(LCursor & cur) const;
/// The right key
- virtual bool idxRight(BufferView & bv) const;
+ virtual bool idxRight(LCursor & cur) const;
/// Move one physical cell up
- virtual bool idxNext(BufferView & bv) const;
+ virtual bool idxNext(LCursor & cur) const;
/// Move one physical cell down
- virtual bool idxPrev(BufferView & bv) const;
+ virtual bool idxPrev(LCursor & cur) const;
/// Target pos when we enter the inset from the left by pressing "Right"
- virtual bool idxFirst(BufferView & bv) const;
+ virtual bool idxFirst(LCursor & cur) const;
/// Target pos when we enter the inset from the right by pressing "Left"
- virtual bool idxLast(BufferView & bv) const;
+ virtual bool idxLast(LCursor & cur) const;
/// Where should we go if we press home?
- virtual bool idxHome(BufferView & bv) const;
+ virtual bool idxHome(LCursor & cur) const;
/// Where should we go if we press end?
- virtual bool idxEnd(BufferView & bv) const;
+ virtual bool idxEnd(LCursor & cur) const;
/// Delete a cell and move cursor
virtual bool idxDelete(idx_type &) { return false; }
}
-bool MathMacro::idxUpDown(BufferView & bv, bool up, int x) const
+bool MathMacro::idxUpDown(LCursor & cur, bool up, int x) const
{
- CursorSlice & cur = cursorTip(bv);
if (up) {
- if (!MathNestInset::idxLeft(bv))
+ if (!MathNestInset::idxLeft(cur))
return false;
} else {
- if (!MathNestInset::idxRight(bv))
+ if (!MathNestInset::idxRight(cur))
return false;
}
cur.pos() = cur.cell().x2pos(x);
}
-bool MathMacro::idxLeft(BufferView &) const
+bool MathMacro::idxLeft(LCursor &) const
{
return false;
}
-bool MathMacro::idxRight(BufferView &) const
+bool MathMacro::idxRight(LCursor &) const
{
return false;
}
void dump() const;
///
- bool idxUpDown(BufferView &, bool up, int targetx) const;
+ bool idxUpDown(LCursor &, bool up, int targetx) const;
///
- bool idxLeft(BufferView &) const;
+ bool idxLeft(LCursor &) const;
///
- bool idxRight(BufferView &) const;
+ bool idxRight(LCursor &) const;
///
void validate(LaTeXFeatures &) const;
}
-bool MathNestInset::idxNext(BufferView & bv) const
+bool MathNestInset::idxNext(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.idx() + 1 >= nargs())
return false;
++cur.idx();
}
-bool MathNestInset::idxRight(BufferView & bv) const
+bool MathNestInset::idxRight(LCursor & cur) const
{
- return idxNext(bv);
+ return idxNext(cur);
}
-bool MathNestInset::idxPrev(BufferView & bv) const
+bool MathNestInset::idxPrev(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.idx() == 0)
return false;
--cur.idx();
}
-bool MathNestInset::idxLeft(BufferView & bv) const
+bool MathNestInset::idxLeft(LCursor & cur) const
{
- return idxPrev(bv);
+ return idxPrev(cur);
}
-bool MathNestInset::idxFirst(BufferView & bv) const
+bool MathNestInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (nargs() == 0)
return false;
cur.idx() = 0;
}
-bool MathNestInset::idxLast(BufferView & bv) const
+bool MathNestInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (nargs() == 0)
return false;
cur.idx() = nargs() - 1;
}
-bool MathNestInset::idxHome(BufferView & bv) const
+bool MathNestInset::idxHome(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.pos() == 0)
return false;
cur.pos() = 0;
}
-bool MathNestInset::idxEnd(BufferView & bv) const
+bool MathNestInset::idxEnd(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.lastpos() == cur.lastpos())
return false;
cur.pos() = cur.lastpos();
void getScreenPos(idx_type idx, pos_type pos, int & x, int & y) const;
/// order of movement through the cells when pressing the left key
- bool idxLeft(BufferView &) const;
+ bool idxLeft(LCursor &) const;
/// order of movement through the cells when pressing the right key
- bool idxRight(BufferView &) const;
+ bool idxRight(LCursor &) const;
/// move one physical cell up
- bool idxNext(BufferView &) const;
+ bool idxNext(LCursor &) const;
/// move one physical cell down
- bool idxPrev(BufferView &) const;
+ bool idxPrev(LCursor &) const;
/// target pos when we enter the inset from the left by pressing "Right"
- bool idxFirst(BufferView &) const;
+ bool idxFirst(LCursor &) const;
/// target pos when we enter the inset from the right by pressing "Left"
- bool idxLast(BufferView &) const;
+ bool idxLast(LCursor &) const;
/// where should we go if we press home?
- bool idxHome(BufferView &) const;
+ bool idxHome(LCursor &) const;
/// where should we go if we press end?
- bool idxEnd(BufferView &) const;
+ bool idxEnd(LCursor &) const;
/// number of cells currently governed by us
idx_type nargs() const;
}
-bool MathOversetInset::idxFirst(BufferView & bv) const
+bool MathOversetInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 1;
cur.pos() = 0;
return true;
}
-bool MathOversetInset::idxLast(BufferView & bv) const
+bool MathOversetInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 1;
cur.pos() = cur.lastpos();
return true;
///
void draw(PainterInfo & pi, int x, int y) const;
///
- bool idxFirst(BufferView &) const;
+ bool idxFirst(LCursor &) const;
///
- bool idxLast(BufferView &) const;
+ bool idxLast(LCursor &) const;
///
void write(WriteStream & os) const;
}
-bool MathRootInset::idxUpDown(BufferView & bv, bool up, int) const
+bool MathRootInset::idxUpDown(LCursor & cur, bool up, int) const
{
- CursorSlice & cur = cursorTip(bv);
bool target = !up; // up ? 0 : 1;
if (cur.idx() == target)
return false;
///
virtual std::auto_ptr<InsetBase> clone() const;
///
- bool idxUpDown(BufferView &, bool up, int targetx) const;
+ bool idxUpDown(LCursor &, bool up, int targetx) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
}
-bool MathScriptInset::idxFirst(BufferView & bv) const
+bool MathScriptInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 2;
cur.pos() = 0;
return true;
}
-bool MathScriptInset::idxLast(BufferView & bv) const
+bool MathScriptInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 2;
cur.pos() = nuc().size();
return true;
}
-bool MathScriptInset::idxRight(BufferView &) const
+bool MathScriptInset::idxRight(LCursor &) const
{
return false;
}
-bool MathScriptInset::idxLeft(BufferView &) const
+bool MathScriptInset::idxLeft(LCursor &) const
{
return false;
}
-bool MathScriptInset::idxUpDown(BufferView & bv, bool up, int) const
+bool MathScriptInset::idxUpDown(LCursor & cur, bool up, int) const
{
- CursorSlice & cur = cursorTip(bv);
if (cur.idx() == 1) {
// if we are 'up' we can't go further up
if (up)
/// write content as something readable by Octave
void octave(OctaveStream &) const;
/// move cursor left
- bool idxLeft(BufferView &) const;
+ bool idxLeft(LCursor &) const;
/// move cursor right
- bool idxRight(BufferView &) const;
+ bool idxRight(LCursor &) const;
/// move cursor up or down
- bool idxUpDown(BufferView &, bool up, int targetx) const;
+ bool idxUpDown(LCursor &, bool up, int targetx) const;
/// Target pos when we enter the inset from the left by pressing "Right"
- bool idxFirst(BufferView &) const;
+ bool idxFirst(LCursor &) const;
/// Target pos when we enter the inset from the right by pressing "Left"
- bool idxLast(BufferView &) const;
+ bool idxLast(LCursor &) const;
/// can we enter this cell?
bool validCell(idx_type i) const { return i == 2 || script_[i]; }
#if 0
-bool MathTextInset::idxUpDown2(BufferView & pos, bool up,
+bool MathTextInset::idxUpDown2(LCursor & pos, bool up,
int /*targetx*/) const
{
// try to move only one screen row up or down if possible
void drawSelection(PainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
/// moves cursor up or down
- //bool idxUpDown2(BufferView & pos, bool up, int targetx) const;
+ //bool idxUpDown2(LCursor & pos, bool up, int targetx) const;
protected:
/// row corresponding to given position
idx_type pos2row(pos_type pos) const;
}
-bool MathUndersetInset::idxFirst(BufferView & bv) const
+bool MathUndersetInset::idxFirst(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 1;
cur.pos() = 0;
return true;
}
-bool MathUndersetInset::idxLast(BufferView & bv) const
+bool MathUndersetInset::idxLast(LCursor & cur) const
{
- CursorSlice & cur = cursorTip(bv);
cur.idx() = 1;
cur.pos() = cur.lastpos();
return true;
}
-bool MathUndersetInset::idxUpDown(BufferView & bv, bool up, int targetx) const
+bool MathUndersetInset::idxUpDown(LCursor & cur, bool up, int targetx) const
{
- CursorSlice & cur = cursorTip(bv);
idx_type target = up; // up ? 1 : 0, since upper cell has idx 1
if (cur.idx() == target)
return false;
///
void draw(PainterInfo & pi, int x, int y) const;
///
- bool idxFirst(BufferView &) const;
+ bool idxFirst(LCursor &) const;
///
- bool idxLast(BufferView &) const;
+ bool idxLast(LCursor &) const;
///
- bool idxUpDown(BufferView &, bool up, int targetx) const;
+ bool idxUpDown(LCursor &, bool up, int targetx) const;
///
void write(WriteStream & os) const;
///