mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
and some mathed de-uglyfication
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8359 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
69bee02a89
commit
ea53de7c85
@ -168,7 +168,7 @@ string const currentState(BufferView * bv)
|
||||
return string();
|
||||
|
||||
if (mathcursor)
|
||||
return mathcursor->info(*bv);
|
||||
return mathcursor->info(bv->fullCursor());
|
||||
|
||||
ostringstream state;
|
||||
|
||||
|
20
src/cursor.C
20
src/cursor.C
@ -217,21 +217,13 @@ InsetTabular * LCursor::innerInsetTabular() const
|
||||
}
|
||||
|
||||
|
||||
void LCursor::cell(int idx)
|
||||
{
|
||||
BOOST_ASSERT(!cursor_.empty());
|
||||
cursor_.back().idx_ = idx;
|
||||
}
|
||||
|
||||
|
||||
int LCursor::cell() const
|
||||
{
|
||||
BOOST_ASSERT(!cursor_.empty());
|
||||
return cursor_.back().idx_;
|
||||
}
|
||||
|
||||
|
||||
void LCursor::resetAnchor()
|
||||
{
|
||||
anchor_ = cursor_;
|
||||
}
|
||||
|
||||
|
||||
BufferView & LCursor::bv() const
|
||||
{
|
||||
return *bv_;
|
||||
}
|
||||
|
46
src/cursor.h
46
src/cursor.h
@ -37,10 +37,14 @@ public:
|
||||
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);
|
||||
@ -54,11 +58,41 @@ public:
|
||||
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;
|
||||
///
|
||||
@ -75,7 +109,7 @@ public:
|
||||
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 &);
|
||||
|
@ -128,14 +128,14 @@ bool CursorSlice::boundary() 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_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -398,12 +398,12 @@ void InsetTabular::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
|
||||
@ -422,7 +422,7 @@ void InsetTabular::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
|
||||
setSelection(actcell, actcell);
|
||||
bv.setSelection();
|
||||
} else {
|
||||
bv.cursor().idx(actcell);
|
||||
bv.cursor().idx() = actcell;
|
||||
setSelection(sel_cell_start, actcell);
|
||||
tablemode = (sel_cell_start != actcell);
|
||||
}
|
||||
@ -460,7 +460,7 @@ void InsetTabular::edit(BufferView * view, bool left)
|
||||
resetPos(bv);
|
||||
bv.fitCursor();
|
||||
bv.fullCursor().push(this);
|
||||
bv.fullCursor().cell(cell);
|
||||
bv.fullCursor().idx() = cell;
|
||||
lyxerr << bv.cursor() << endl;
|
||||
}
|
||||
|
||||
|
@ -111,31 +111,31 @@ void InsetFormulaBase::mutateToText()
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +154,8 @@ string const InsetFormulaBase::editMessage() const
|
||||
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())
|
||||
@ -164,17 +164,11 @@ void InsetFormulaBase::insetUnlock(BufferView & bv)
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -196,13 +190,6 @@ void InsetFormulaBase::getCursorDim(int & asc, int & desc) const
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
|
||||
{
|
||||
if (mathcursor)
|
||||
bv->update();
|
||||
}
|
||||
|
||||
|
||||
DispatchResult
|
||||
InsetFormulaBase::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
{
|
||||
@ -213,7 +200,7 @@ 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");
|
||||
@ -224,17 +211,17 @@ InsetFormulaBase::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
|
||||
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);
|
||||
@ -257,20 +244,20 @@ InsetFormulaBase::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -285,7 +272,7 @@ InsetFormulaBase::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
|
||||
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
|
||||
@ -299,9 +286,9 @@ InsetFormulaBase::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
|
||||
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);
|
||||
}
|
||||
@ -325,7 +312,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int y)
|
||||
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
|
||||
@ -344,6 +331,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
// delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
|
||||
bool remove_inset = false;
|
||||
LCursor & cur = bv.fullCursor();
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
@ -368,10 +356,9 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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) {
|
||||
@ -389,13 +376,13 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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);
|
||||
@ -406,27 +393,27 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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:
|
||||
@ -441,7 +428,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
|
||||
@ -450,7 +437,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
|
||||
@ -469,17 +456,17 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
}
|
||||
@ -488,7 +475,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
}
|
||||
@ -504,7 +491,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
int y = 0;
|
||||
istringstream is(cmd.argument.c_str());
|
||||
is >> x >> y;
|
||||
mathcursor->setScreenPos(bv, x, y);
|
||||
mathcursor->setScreenPos(cur, x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -513,19 +500,19 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
|
||||
|
||||
@ -536,7 +523,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
// do superscript if LyX handles
|
||||
// deadkeys
|
||||
recordUndo(bv, Undo::ATOMIC);
|
||||
mathcursor->script(bv, true);
|
||||
mathcursor->script(cur, true);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -559,26 +546,26 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
// 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:
|
||||
@ -601,7 +588,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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;
|
||||
}
|
||||
@ -616,14 +603,14 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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:
|
||||
@ -638,7 +625,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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:
|
||||
@ -652,7 +639,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
// 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:
|
||||
@ -660,22 +647,22 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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:
|
||||
@ -707,7 +694,7 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
} 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);
|
||||
@ -731,17 +718,14 @@ InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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)
|
||||
@ -756,7 +740,7 @@ void InsetFormulaBase::revealCodes(BufferView & bv) const
|
||||
{
|
||||
if (!mathcursor)
|
||||
return;
|
||||
bv.owner()->message(mathcursor->info(bv));
|
||||
bv.owner()->message(mathcursor->info(bv.fullCursor()));
|
||||
/*
|
||||
// write something to the minibuffer
|
||||
// translate to latex
|
||||
@ -849,7 +833,7 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
|
||||
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();
|
||||
@ -879,7 +863,7 @@ bool InsetFormulaBase::display() const
|
||||
|
||||
string InsetFormulaBase::selectionAsString(BufferView & bv) const
|
||||
{
|
||||
return mathcursor ? mathcursor->grabSelection(bv) : string();
|
||||
return mathcursor ? mathcursor->grabSelection(bv.fullCursor()) : string();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
@ -20,6 +20,7 @@ class Buffer;
|
||||
class BufferView;
|
||||
class MathAtom;
|
||||
class CursorSlice;
|
||||
class LCursor;
|
||||
|
||||
|
||||
/// An abstract base class for all math related LyX insets
|
||||
@ -45,14 +46,10 @@ public:
|
||||
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);
|
||||
|
||||
@ -113,9 +110,9 @@ protected:
|
||||
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.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -56,207 +56,207 @@ public:
|
||||
///
|
||||
~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;
|
||||
|
||||
|
@ -19,21 +19,20 @@ MathFracbaseInset::MathFracbaseInset()
|
||||
{}
|
||||
|
||||
|
||||
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;
|
||||
|
@ -20,11 +20,11 @@ public:
|
||||
///
|
||||
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
|
||||
|
@ -14,11 +14,14 @@
|
||||
#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"
|
||||
@ -751,9 +754,8 @@ int MathGridInset::cellYOffset(idx_type idx) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -768,10 +770,9 @@ bool MathGridInset::idxUpDown(BufferView & bv, bool up, int targetx) const
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
@ -780,10 +781,9 @@ bool MathGridInset::idxLeft(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
@ -792,9 +792,8 @@ bool MathGridInset::idxRight(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
bool MathGridInset::idxFirst(BufferView & bv) const
|
||||
bool MathGridInset::idxFirst(LCursor & cur) const
|
||||
{
|
||||
CursorSlice & cur = cursorTip(bv);
|
||||
switch (v_align_) {
|
||||
case 't':
|
||||
cur.idx() = 0;
|
||||
@ -810,9 +809,8 @@ bool MathGridInset::idxFirst(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -828,9 +826,8 @@ bool MathGridInset::idxLast(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -849,9 +846,8 @@ bool MathGridInset::idxHome(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -1033,9 +1029,8 @@ int MathGridInset::border() const
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::splitCell(BufferView & bv)
|
||||
void MathGridInset::splitCell(LCursor & cur)
|
||||
{
|
||||
CursorSlice & cur = cursorTip(bv);
|
||||
if (cur.idx() + 1 == nargs())
|
||||
return;
|
||||
MathArray ar = cur.cell();
|
||||
@ -1050,7 +1045,7 @@ void MathGridInset::splitCell(BufferView & bv)
|
||||
DispatchResult
|
||||
MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
{
|
||||
CursorSlice & cur = cursorTip(bv);
|
||||
LCursor & cur = bv.fullCursor();
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
@ -1082,7 +1077,7 @@ MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
|
||||
case LFUN_CELL_SPLIT:
|
||||
//recordUndo(bv, Undo::ATOMIC);
|
||||
splitCell(bv);
|
||||
splitCell(cur);
|
||||
return DispatchResult(true, FINISHED);
|
||||
|
||||
case LFUN_BREAKLINE: {
|
||||
@ -1095,7 +1090,7 @@ MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
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();
|
||||
|
@ -145,19 +145,19 @@ public:
|
||||
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
|
||||
@ -216,10 +216,7 @@ public:
|
||||
|
||||
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
|
||||
@ -231,7 +228,7 @@ protected:
|
||||
/// 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
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "math_extern.h"
|
||||
#include "math_charinset.h"
|
||||
#include "textpainter.h"
|
||||
#include "BufferView.h"
|
||||
#include "dispatchresult.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
@ -135,18 +136,16 @@ MathInset::mode_type MathHullInset::currentMode() const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -696,9 +695,8 @@ void MathHullInset::check() const
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
@ -728,7 +726,7 @@ void MathHullInset::doExtern(FuncRequest const & func, BufferView & bv)
|
||||
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;
|
||||
@ -841,7 +839,7 @@ MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_MATH_EXTERN:
|
||||
doExtern(cmd, bv);
|
||||
doExtern(bv.fullCursor(), cmd);
|
||||
return DispatchResult(true, FINISHED);
|
||||
|
||||
case LFUN_MATH_MUTATE: {
|
||||
|
@ -81,9 +81,9 @@ public:
|
||||
///
|
||||
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;
|
||||
@ -116,7 +116,7 @@ private:
|
||||
///
|
||||
std::string nicelabel(row_type row) const;
|
||||
///
|
||||
void doExtern(FuncRequest const & func, BufferView &);
|
||||
void doExtern(LCursor & cur, FuncRequest const & func);
|
||||
///
|
||||
void glueall();
|
||||
///
|
||||
|
@ -56,61 +56,61 @@ void MathInset::substitute(MathMacro const &)
|
||||
{}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef MATH_INSET_H
|
||||
#define MATH_INSET_H
|
||||
|
||||
#include "cursor_slice.h"
|
||||
#include "cursor.h"
|
||||
#include "insets/insetbase.h"
|
||||
|
||||
#include <string>
|
||||
@ -64,13 +64,10 @@ class MathMLStream;
|
||||
class WriteStream;
|
||||
class InfoStream;
|
||||
|
||||
class BufferView;
|
||||
class UpdatableInset;
|
||||
class MathMacroTemplate;
|
||||
class MathMacro;
|
||||
class MathPosFinder;
|
||||
class Dimension;
|
||||
class FuncRequest;
|
||||
class TextPainter;
|
||||
class TextMetricsInfo;
|
||||
class ReplaceData;
|
||||
@ -95,28 +92,28 @@ public:
|
||||
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; }
|
||||
|
@ -155,14 +155,13 @@ void MathMacro::dump() const
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -170,13 +169,13 @@ bool MathMacro::idxUpDown(BufferView & bv, bool up, int x) const
|
||||
}
|
||||
|
||||
|
||||
bool MathMacro::idxLeft(BufferView &) const
|
||||
bool MathMacro::idxLeft(LCursor &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MathMacro::idxRight(BufferView &) const
|
||||
bool MathMacro::idxRight(LCursor &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ public:
|
||||
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;
|
||||
|
@ -71,9 +71,8 @@ void MathNestInset::metrics(MetricsInfo const & mi) 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();
|
||||
@ -82,15 +81,14 @@ bool MathNestInset::idxNext(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
@ -99,15 +97,14 @@ bool MathNestInset::idxPrev(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -116,9 +113,8 @@ bool MathNestInset::idxFirst(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -127,9 +123,8 @@ bool MathNestInset::idxLast(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -137,9 +132,8 @@ bool MathNestInset::idxHome(BufferView & bv) const
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
@ -43,24 +43,24 @@ public:
|
||||
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;
|
||||
|
@ -47,18 +47,16 @@ void MathOversetInset::draw(PainterInfo & pi, int x, int y) 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;
|
||||
|
@ -25,9 +25,9 @@ public:
|
||||
///
|
||||
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;
|
||||
|
@ -78,9 +78,8 @@ void MathRootInset::normalize(NormalStream & 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;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
///
|
||||
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;
|
||||
///
|
||||
|
@ -72,18 +72,16 @@ MathScriptInset * MathScriptInset::asScriptInset()
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -315,21 +313,20 @@ bool MathScriptInset::hasDown() const
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
@ -48,15 +48,15 @@ public:
|
||||
/// 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]; }
|
||||
|
||||
|
@ -50,7 +50,7 @@ void MathTextInset::getScreenPos(idx_type /*idx*/, pos_type pos, int & x, int &
|
||||
|
||||
|
||||
#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
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
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;
|
||||
|
@ -47,27 +47,24 @@ void MathUndersetInset::draw(PainterInfo & pi, int x, int y) 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;
|
||||
|
@ -25,11 +25,11 @@ public:
|
||||
///
|
||||
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;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user