some de-mathed-ification

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8459 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-02-25 14:39:14 +00:00
parent d891a896f4
commit 2c535ef9e9
11 changed files with 252 additions and 346 deletions

View File

@ -921,45 +921,6 @@ bool LCursor::inNucleus()
} }
bool LCursor::left()
{
autocorrect() = false;
clearTargetX();
if (inMacroMode()) {
macroModeClose();
return true;
}
if (pos() != 0 && openable(prevAtom())) {
posLeft();
push(nextAtom().nucleus());
inset()->idxLast(*this);
return true;
}
return posLeft() || idxLeft() || popLeft() || selection();
}
bool LCursor::right()
{
autocorrect() = false;
clearTargetX();
if (inMacroMode()) {
macroModeClose();
return true;
}
if (pos() != lastpos() && openable(nextAtom())) {
pushLeft(nextAtom().nucleus());
inset()->idxFirst(*this);
return true;
}
return posRight() || idxRight() || popRight() || selection();
}
bool positionable(CursorBase const & cursor, CursorBase const & anchor) bool positionable(CursorBase const & cursor, CursorBase const & anchor)
{ {
// avoid deeper nested insets when selecting // avoid deeper nested insets when selecting
@ -990,28 +951,6 @@ void LCursor::setScreenPos(int x, int y)
bool LCursor::home()
{
autocorrect() = false;
macroModeClose();
if (!inset()->idxHome(*this))
return popLeft();
clearTargetX();
return true;
}
bool LCursor::end()
{
autocorrect() = false;
macroModeClose();
if (!inset()->idxEnd(*this))
return popRight();
clearTargetX();
return true;
}
void LCursor::plainErase() void LCursor::plainErase()
{ {
cell().erase(pos()); cell().erase(pos());
@ -1143,7 +1082,7 @@ bool LCursor::backspace()
// let's require two backspaces for 'big stuff' and // let's require two backspaces for 'big stuff' and
// highlight on the first // highlight on the first
selection() = true; selection() = true;
left(); --pos();
} else { } else {
--pos(); --pos();
plainErase(); plainErase();
@ -1182,7 +1121,7 @@ bool LCursor::erase()
if (pos() != lastpos() && inset()->nargs() > 0) { if (pos() != lastpos() && inset()->nargs() > 0) {
selection() = true; selection() = true;
right(); ++pos();
} else { } else {
plainErase(); plainErase();
} }
@ -1232,8 +1171,8 @@ void LCursor::macroModeClose()
string const name = s.substr(1); string const name = s.substr(1);
// prevent entering of recursive macros // prevent entering of recursive macros
if (formula()->lyxCode() == InsetOld::MATHMACRO_CODE InsetBase const * macro = innerInsetOfType(InsetBase::MATHMACRO_CODE);
&& formula()->getInsetName() == name) if (macro && macro->getInsetName() == name)
lyxerr << "can't enter recursive macro" << endl; lyxerr << "can't enter recursive macro" << endl;
niceInsert(createMathInset(name)); niceInsert(createMathInset(name));
@ -1544,27 +1483,6 @@ void LCursor::bruteFind2(int x, int y)
} }
bool LCursor::idxLineLast()
{
idx() -= idx() % ncols();
idx() += ncols() - 1;
pos() = lastpos();
return true;
}
bool LCursor::idxLeft()
{
return inset()->idxLeft(*this);
}
bool LCursor::idxRight()
{
return inset()->idxRight(*this);
}
bool LCursor::script(bool up) bool LCursor::script(bool up)
{ {
// Hack to get \\^ and \\_ working // Hack to get \\^ and \\_ working
@ -1849,13 +1767,13 @@ void LCursor::handleFont(string const & font)
bool LCursor::inMathed() const bool LCursor::inMathed() const
{ {
return formula(); return current_ && inset()->inMathed();
} }
bool LCursor::inTexted() const bool LCursor::inTexted() const
{ {
return !formula(); return !inMathed();
} }

View File

@ -190,8 +190,12 @@ public:
size_t nrows() const; size_t nrows() const;
/// return the grid row of the current cell /// return the grid row of the current cell
row_type row() const; row_type row() const;
/// return the grid row of the current cell /// return the last row of the current grid
row_type lastrow() const { return nrows() - 1; }
/// return the grid column of the current cell
col_type col() const; col_type col() const;
/// return the last column of the current grid
col_type lastcol() const { return ncols() - 1; }
/// the inset just behind the cursor /// the inset just behind the cursor
InsetBase * nextInset(); InsetBase * nextInset();
/// the inset just in front of the cursor /// the inset just in front of the cursor
@ -362,14 +366,6 @@ public:
bool erase(); bool erase();
/// return false for empty math insets /// return false for empty math insets
bool backspace(); bool backspace();
/// called for LFUN_HOME etc
bool home();
/// called for LFUN_END etc
bool end();
/// called for LFUN_RIGHT and LFUN_RIGHTSEL
bool right();
/// called for LFUN_LEFT etc
bool left();
/// called for LFUN_UP etc /// called for LFUN_UP etc
bool up(); bool up();
/// called for LFUN_DOWN etc /// called for LFUN_DOWN etc
@ -451,12 +447,6 @@ public:
std::string getPossibleLabel(); std::string getPossibleLabel();
private: private:
/// moves cursor index one cell to the left
bool idxLeft();
/// moves cursor index one cell to the right
bool idxRight();
/// moves cursor to end of last cell of current line
bool idxLineLast();
/// moves position somehow up or down /// moves position somehow up or down
bool goUpDown(bool up); bool goUpDown(bool up);
/// moves position closest to (x, y) in given box /// moves position closest to (x, y) in given box
@ -470,6 +460,7 @@ private:
std::string macroName(); std::string macroName();
/// where in the curent cell does the macro name start? /// where in the curent cell does the macro name start?
int macroNamePos(); int macroNamePos();
public:
/// can we enter the inset? /// can we enter the inset?
bool openable(MathAtom const &) const; bool openable(MathAtom const &) const;
}; };

View File

@ -67,6 +67,8 @@ public:
virtual MathInset * asMathInset() { return 0; } virtual MathInset * asMathInset() { return 0; }
/// identification as non-math inset /// identification as non-math inset
virtual UpdatableInset * asUpdatableInset() { return 0; } virtual UpdatableInset * asUpdatableInset() { return 0; }
/// true for 'math' math inset, but not for e.g. mbox
virtual bool inMathed() const { return false; }
// the real dispatcher // the real dispatcher
void dispatch(LCursor & cur, FuncRequest const & cmd); void dispatch(LCursor & cur, FuncRequest const & cmd);
@ -127,11 +129,6 @@ public:
/// Target pos when we enter the inset from the right by pressing "Left" /// Target pos when we enter the inset from the right by pressing "Left"
virtual bool idxLast(LCursor &) const { return false; } virtual bool idxLast(LCursor &) const { return false; }
/// Where should we go if we press home?
virtual bool idxHome(LCursor &) const { return false; }
/// Where should we go if we press end?
virtual bool idxEnd(LCursor &) const { return false; }
/// Delete a cell and move cursor /// Delete a cell and move cursor
virtual bool idxDelete(idx_type &) { return false; } virtual bool idxDelete(idx_type &) { return false; }
/// pulls cell after pressing erase /// pulls cell after pressing erase

View File

@ -826,46 +826,6 @@ bool MathGridInset::idxLast(LCursor & cur) const
} }
bool MathGridInset::idxHome(LCursor & cur) const
{
if (cur.pos() > 0) {
cur.pos() = 0;
return true;
}
if (cur.col() > 0) {
cur.idx() -= cur.idx() % ncols();
cur.pos() = 0;
return true;
}
if (cur.idx() > 0) {
cur.idx() = 0;
cur.pos() = 0;
return true;
}
return false;
}
bool MathGridInset::idxEnd(LCursor & cur) const
{
if (cur.pos() < cur.lastpos()) {
cur.pos() = cur.lastpos();
return true;
}
if (cur.col() < ncols() - 1) {
cur.idx() = cur.idx() - cur.idx() % ncols() + ncols() - 1;
cur.pos() = cur.lastpos();
return true;
}
if (cur.idx() < nargs() - 1) {
cur.idx() = nargs() - 1;
cur.pos() = cur.lastpos();
return true;
}
return false;
}
bool MathGridInset::idxDelete(idx_type & idx) bool MathGridInset::idxDelete(idx_type & idx)
{ {
// nothing to do if we have just one row // nothing to do if we have just one row
@ -1047,154 +1007,183 @@ void MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
//lyxerr << "*** MathGridInset: request: " << cmd << endl; //lyxerr << "*** MathGridInset: request: " << cmd << endl;
switch (cmd.action) { switch (cmd.action) {
case LFUN_MOUSE_RELEASE: case LFUN_MOUSE_RELEASE:
//if (cmd.button() == mouse_button::button3) { //if (cmd.button() == mouse_button::button3) {
// GridInsetMailer(*this).showDialog(); // GridInsetMailer(*this).showDialog();
// return DispatchResult(true, true); // return DispatchResult(true, true);
//} //}
MathNestInset::priv_dispatch(cur, cmd); MathNestInset::priv_dispatch(cur, cmd);
return; return;
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE:
GridInsetMailer(*this).updateDialog(&cur.bv()); GridInsetMailer(*this).updateDialog(&cur.bv());
return; return;
// insert file functions // insert file functions
case LFUN_DELETE_LINE_FORWARD: case LFUN_DELETE_LINE_FORWARD:
//autocorrect_ = false; //autocorrect_ = false;
//macroModeClose(); //macroModeClose();
//if (selection_) { //if (selection_) {
// selDel(); // selDel();
// return; // return;
//} //}
if (nrows() > 1) if (nrows() > 1)
delRow(cur.row());
if (cur.idx() > cur.lastidx())
cur.idx() = cur.lastidx();
if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos();
return;
case LFUN_CELL_SPLIT:
////recordUndo(cur, Undo::ATOMIC);
splitCell(cur);
return;
case LFUN_BREAKLINE: {
////recordUndo(cur, Undo::INSERT);
row_type const r = cur.row();
addRow(r);
// split line
for (col_type c = col(cur.idx()) + 1; c < ncols(); ++c)
swap(cell(index(r, c)), cell(index(r + 1, c)));
// split cell
splitCell(cur);
swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
if (cur.idx() > 0)
--cur.idx();
cur.idx() = cur.lastpos();
//mathcursor->normalize();
cur.dispatched(FINISHED_LEFT);
return;
}
case LFUN_TABULAR_FEATURE: {
//lyxerr << "handling tabular-feature " << cmd.argument << endl;
istringstream is(cmd.argument);
string s;
is >> s;
if (s == "valign-top")
valign('t');
else if (s == "valign-middle")
valign('c');
else if (s == "valign-bottom")
valign('b');
else if (s == "align-left")
halign('l', col(cur.idx()));
else if (s == "align-right")
halign('r', col(cur.idx()));
else if (s == "align-center")
halign('c', col(cur.idx()));
else if (s == "append-row")
for (int i = 0, n = extractInt(is); i < n; ++i)
addRow(cur.row());
else if (s == "delete-row")
for (int i = 0, n = extractInt(is); i < n; ++i) {
delRow(cur.row()); delRow(cur.row());
if (cur.idx() > cur.lastidx()) if (cur.idx() > nargs())
cur.idx() = cur.lastidx(); cur.idx() -= ncols();
if (cur.pos() > cur.lastpos()) }
cur.pos() = cur.lastpos(); else if (s == "copy-row")
for (int i = 0, n = extractInt(is); i < n; ++i)
copyRow(cur.row());
else if (s == "swap-row")
swapRow(cur.row());
else if (s == "append-column")
for (int i = 0, n = extractInt(is); i < n; ++i) {
row_type r = cur.row();
col_type c = col(cur.idx());
addCol(c);
cur.idx() = index(r, c);
}
else if (s == "delete-column")
for (int i = 0, n = extractInt(is); i < n; ++i) {
row_type r = cur.row();
col_type c = col(cur.idx());
delCol(col(cur.idx()));
cur.idx() = index(r, c);
if (cur.idx() > nargs())
cur.idx() -= ncols();
}
else if (s == "copy-column")
copyCol(col(cur.idx()));
else if (s == "swap-column")
swapCol(col(cur.idx()));
else {
cur.notdispatched();
return; return;
}
lyxerr << "returning FINISHED_LEFT" << endl;
return;
}
case LFUN_CELL_SPLIT: case LFUN_PASTE: {
////recordUndo(cur, Undo::ATOMIC); //lyxerr << "pasting '" << cmd.argument << "'" << endl;
splitCell(cur); MathGridInset grid(1, 1);
return; mathed_parse_normal(grid, cmd.argument);
if (grid.nargs() == 1) {
// single cell/part of cell
cur.cell().insert(cur.pos(), grid.cell(0));
cur.pos() += grid.cell(0).size();
} else {
// multiple cells
col_type const numcols =
min(grid.ncols(), ncols() - col(cur.idx()));
row_type const numrows =
min(grid.nrows(), nrows() - cur.row());
for (row_type r = 0; r < numrows; ++r) {
for (col_type c = 0; c < numcols; ++c) {
idx_type i = index(r + cur.row(), c + col(cur.idx()));
cell(i).insert(0, grid.cell(grid.index(r, c)));
}
// append the left over horizontal cells to the last column
idx_type i = index(r + cur.row(), ncols() - 1);
for (MathInset::col_type c = numcols; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
}
// append the left over vertical cells to the last _cell_
idx_type i = nargs() - 1;
for (row_type r = numrows; r < grid.nrows(); ++r)
for (col_type c = 0; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
}
return;
}
case LFUN_BREAKLINE: { case LFUN_HOMESEL:
////recordUndo(cur, Undo::INSERT); case LFUN_HOME:
row_type const r = cur.row(); case LFUN_WORDLEFTSEL:
addRow(r); case LFUN_WORDLEFT:
cur.selHandle(cmd.action == LFUN_WORDLEFTSEL || cmd.action == LFUN_HOMESEL);
// split line cur.macroModeClose();
for (col_type c = col(cur.idx()) + 1; c < ncols(); ++c) if (cur.pos() != 0)
swap(cell(index(r, c)), cell(index(r + 1, c))); cur.pos() = 0;
else if (cur.idx() != 0)
// split cell cur.idx() = 0;
splitCell(cur); else
swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
if (cur.idx() > 0)
--cur.idx();
cur.idx() = cur.lastpos();
//mathcursor->normalize();
cur.dispatched(FINISHED_LEFT); cur.dispatched(FINISHED_LEFT);
return; break;
}
case LFUN_TABULAR_FEATURE: { case LFUN_WORDRIGHTSEL:
//lyxerr << "handling tabular-feature " << cmd.argument << endl; case LFUN_WORDRIGHT:
istringstream is(cmd.argument); case LFUN_ENDSEL:
string s; case LFUN_END:
is >> s; cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL || cmd.action == LFUN_ENDSEL);
if (s == "valign-top") cur.macroModeClose();
valign('t'); cur.clearTargetX();
else if (s == "valign-middle") if (cur.pos() != cur.lastpos())
valign('c'); cur.pos() = cur.lastpos();
else if (s == "valign-bottom") else if (cur.idx() != cur.lastidx())
valign('b'); cur.idx() = cur.lastidx();
else if (s == "align-left") else
halign('l', col(cur.idx())); cur.dispatched(FINISHED_RIGHT);
else if (s == "align-right") break;
halign('r', col(cur.idx()));
else if (s == "align-center")
halign('c', col(cur.idx()));
else if (s == "append-row")
for (int i = 0, n = extractInt(is); i < n; ++i)
addRow(cur.row());
else if (s == "delete-row")
for (int i = 0, n = extractInt(is); i < n; ++i) {
delRow(cur.row());
if (cur.idx() > nargs())
cur.idx() -= ncols();
}
else if (s == "copy-row")
for (int i = 0, n = extractInt(is); i < n; ++i)
copyRow(cur.row());
else if (s == "swap-row")
swapRow(cur.row());
else if (s == "append-column")
for (int i = 0, n = extractInt(is); i < n; ++i) {
row_type r = cur.row();
col_type c = col(cur.idx());
addCol(c);
cur.idx() = index(r, c);
}
else if (s == "delete-column")
for (int i = 0, n = extractInt(is); i < n; ++i) {
row_type r = cur.row();
col_type c = col(cur.idx());
delCol(col(cur.idx()));
cur.idx() = index(r, c);
if (cur.idx() > nargs())
cur.idx() -= ncols();
}
else if (s == "copy-column")
copyCol(col(cur.idx()));
else if (s == "swap-column")
swapCol(col(cur.idx()));
else {
cur.notdispatched();
return;
}
lyxerr << "returning FINISHED_LEFT" << endl;
return;
}
case LFUN_PASTE: { default:
//lyxerr << "pasting '" << cmd.argument << "'" << endl; MathNestInset::priv_dispatch(cur, cmd);
MathGridInset grid(1, 1); return;
mathed_parse_normal(grid, cmd.argument);
if (grid.nargs() == 1) {
// single cell/part of cell
cur.cell().insert(cur.pos(), grid.cell(0));
cur.pos() += grid.cell(0).size();
} else {
// multiple cells
col_type const numcols =
min(grid.ncols(), ncols() - col(cur.idx()));
row_type const numrows =
min(grid.nrows(), nrows() - cur.row());
for (row_type r = 0; r < numrows; ++r) {
for (col_type c = 0; c < numcols; ++c) {
idx_type i = index(r + cur.row(), c + col(cur.idx()));
cell(i).insert(0, grid.cell(grid.index(r, c)));
}
// append the left over horizontal cells to the last column
idx_type i = index(r + cur.row(), ncols() - 1);
for (MathInset::col_type c = numcols; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
}
// append the left over vertical cells to the last _cell_
idx_type i = nargs() - 1;
for (row_type r = numrows; r < grid.nrows(); ++r)
for (col_type c = 0; c < grid.ncols(); ++c)
cell(i).append(grid.cell(grid.index(r, c)));
}
return;
}
default:
MathNestInset::priv_dispatch(cur, cmd);
return;
} }
} }

View File

@ -155,10 +155,6 @@ public:
/// ///
bool idxLast(LCursor &) const; bool idxLast(LCursor &) const;
/// ///
bool idxHome(LCursor &) const;
///
bool idxEnd(LCursor &) const;
///
bool idxDelete(idx_type & idx); bool idxDelete(idx_type & idx);
/// pulls cell after pressing erase /// pulls cell after pressing erase
void idxGlue(idx_type idx); void idxGlue(idx_type idx);

View File

@ -851,12 +851,14 @@ void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
case LFUN_MATH_MUTATE: { case LFUN_MATH_MUTATE: {
lyxerr << "Hull: MUTATE: " << cmd.argument << endl; lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
row_type r = cur.row(); row_type row = cur.row();
col_type c = cur.col(); col_type col = cur.col();
mutate(cmd.argument); mutate(cmd.argument);
cur.idx() = r * ncols() + c; cur.idx() = row * ncols() + col;
if (cur.idx() >= nargs()) if (cur.idx() > cur.lastidx()) {
cur.idx() = nargs() - 1; cur.idx() = cur.lastidx();
cur.pos() = cur.lastpos();
}
if (cur.pos() > cur.lastpos()) if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos(); cur.pos() = cur.lastpos();
//cur.dispatched(FINISHED); //cur.dispatched(FINISHED);

View File

@ -77,6 +77,8 @@ class MathInset : public InsetBase {
public: public:
/// identification as math inset /// identification as math inset
MathInset * asMathInset() { return this; } MathInset * asMathInset() { return this; }
/// this is overridden in math text insets (i.e. mbox)
bool inMathed() const { return true; }
/// substitutes macro arguments if necessary /// substitutes macro arguments if necessary
virtual void substitute(MathMacro const & macro); virtual void substitute(MathMacro const & macro);

View File

@ -35,6 +35,8 @@ public:
/// ///
void write(WriteStream & os) const; void write(WriteStream & os) const;
///
bool inMathed() const { return false; }
/// ///
LyXText * getText(int) const; LyXText * getText(int) const;

View File

@ -164,26 +164,6 @@ bool MathNestInset::idxLast(LCursor & cur) const
} }
bool MathNestInset::idxHome(LCursor & cur) const
{
BOOST_ASSERT(ptr_cmp(cur.inset(), this));
if (cur.pos() == 0)
return false;
cur.pos() = 0;
return true;
}
bool MathNestInset::idxEnd(LCursor & cur) const
{
BOOST_ASSERT(ptr_cmp(cur.inset(), this));
if (cur.lastpos() == cur.lastpos())
return false;
cur.pos() = cur.lastpos();
return true;
}
void MathNestInset::dump() const void MathNestInset::dump() const
{ {
WriteStream os(lyxerr); WriteStream os(lyxerr);
@ -351,6 +331,7 @@ void MathNestInset::handleFont2(LCursor & cur, string const & arg)
void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd) void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
{ {
lyxerr << "MathNestInset: request: " << cmd << std::endl; lyxerr << "MathNestInset: request: " << cmd << std::endl;
CursorSlice sl = cur.current();
switch (cmd.action) { switch (cmd.action) {
@ -423,15 +404,38 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
case LFUN_RIGHTSEL: case LFUN_RIGHTSEL:
case LFUN_RIGHT: case LFUN_RIGHT:
lyxerr << "mathnest RIGHT: from:\n" << cur << endl;
cur.selHandle(cmd.action == LFUN_RIGHTSEL); cur.selHandle(cmd.action == LFUN_RIGHTSEL);
if (!cur.right()) cur.autocorrect() = false;
cur.clearTargetX();
if (cur.inMacroMode())
cur.macroModeClose();
else if (cur.pos() != cur.lastpos() && cur.openable(cur.nextAtom())) {
cur.pushLeft(cur.nextAtom().nucleus());
cur.inset()->idxFirst(cur);
} else if (cur.posRight() || idxRight(cur)
|| cur.popRight() || cur.selection())
;
else
cur.dispatched(FINISHED_RIGHT); cur.dispatched(FINISHED_RIGHT);
lyxerr << "mathnest RIGHT: to:\n" << cur << endl;
break; break;
case LFUN_LEFTSEL: case LFUN_LEFTSEL:
case LFUN_LEFT: case LFUN_LEFT:
cur.selHandle(cmd.action == LFUN_LEFTSEL); cur.selHandle(cmd.action == LFUN_LEFTSEL);
if (!cur.left()) cur.autocorrect() = false;
cur.clearTargetX();
if (cur.inMacroMode())
cur.macroModeClose();
else if (cur.pos() != 0 && cur.openable(cur.prevAtom())) {
cur.posLeft();
cur.push(cur.nextAtom().nucleus());
cur.inset()->idxLast(cur);
} else if (cur.posLeft() || idxLeft(cur)
|| cur.popLeft() || cur.selection())
;
else
cur.dispatched(FINISHED_LEFT); cur.dispatched(FINISHED_LEFT);
break; break;
@ -450,10 +454,12 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
break; break;
case LFUN_WORDSEL: case LFUN_WORDSEL:
cur.home(); cur.pos() = 0;
cur.idx() = 0;
cur.resetAnchor(); cur.resetAnchor();
cur.selection() = true; cur.selection() = true;
cur.end(); cur.pos() = cur.lastpos();
cur.idx() = cur.lastidx();
break; break;
case LFUN_UP_PARAGRAPHSEL: case LFUN_UP_PARAGRAPHSEL:
@ -462,32 +468,43 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
case LFUN_DOWN_PARAGRAPH: case LFUN_DOWN_PARAGRAPH:
break; break;
case LFUN_HOMESEL:
case LFUN_HOME:
case LFUN_WORDLEFTSEL: case LFUN_WORDLEFTSEL:
case LFUN_WORDLEFT: case LFUN_WORDLEFT:
cur.selHandle(cmd.action == LFUN_WORDLEFTSEL); cur.selHandle(cmd.action == LFUN_WORDLEFTSEL || cmd.action == LFUN_HOMESEL);
if (!cur.home()) cur.macroModeClose();
if (cur.pos() != 0) {
cur.pos() = 0;
} else if (cur.col() != 0) {
cur.idx() -= cur.col();
cur.pos() = 0;
} else if (cur.idx() != 0) {
cur.idx() = 0;
cur.pos() = 0;
} else {
cur.dispatched(FINISHED_LEFT); cur.dispatched(FINISHED_LEFT);
}
break; break;
case LFUN_WORDRIGHTSEL: case LFUN_WORDRIGHTSEL:
case LFUN_WORDRIGHT: case LFUN_WORDRIGHT:
cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL);
if (!cur.end())
cur.dispatched(FINISHED_RIGHT);
break;
case LFUN_HOMESEL:
case LFUN_HOME:
cur.selHandle(cmd.action == LFUN_HOMESEL);
if (!cur.home())
cur.dispatched(FINISHED_LEFT);
break;
case LFUN_ENDSEL: case LFUN_ENDSEL:
case LFUN_END: case LFUN_END:
cur.selHandle(cmd.action == LFUN_ENDSEL); cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL || cmd.action == LFUN_ENDSEL);
if (!cur.end()) cur.macroModeClose();
cur.clearTargetX();
if (cur.pos() != cur.lastpos()) {
cur.pos() = cur.lastpos();
} else if (cur.col() != cur.lastcol()) {
cur.idx() = cur.idx() - cur.col() + cur.lastcol();
cur.pos() = cur.lastpos();
} else if (cur.idx() != cur.lastidx()) {
cur.idx() = cur.lastidx();
cur.pos() = cur.lastpos();
} else {
cur.dispatched(FINISHED_RIGHT); cur.dispatched(FINISHED_RIGHT);
}
break; break;
case LFUN_PRIORSEL: case LFUN_PRIORSEL:

View File

@ -60,11 +60,6 @@ public:
/// target pos when we enter the inset from the right by pressing "Left" /// target pos when we enter the inset from the right by pressing "Left"
bool idxLast(LCursor &) const; bool idxLast(LCursor &) const;
/// where should we go if we press home?
bool idxHome(LCursor &) const;
/// where should we go if we press end?
bool idxEnd(LCursor &) const;
/// number of cells currently governed by us /// number of cells currently governed by us
idx_type nargs() const; idx_type nargs() const;
/// access to the lock /// access to the lock

View File

@ -135,8 +135,7 @@ namespace {
lyxerr << "selection is: '" << sel << "'" << endl; lyxerr << "selection is: '" << sel << "'" << endl;
if (sel.empty()) { if (sel.empty()) {
cur.insert(new MathHullInset); cur.insert(new MathHullInset); // activates inset
cur.dispatch(FuncRequest(LFUN_RIGHT));
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple")); cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
// don't do that also for LFUN_MATH_MODE unless you want end up with // don't do that also for LFUN_MATH_MODE unless you want end up with
// always changing to mathrm when opening an inlined inset // always changing to mathrm when opening an inlined inset
@ -152,12 +151,10 @@ namespace {
sel.find("\\def") == string::npos) sel.find("\\def") == string::npos)
{ {
cur.insert(new MathHullInset); cur.insert(new MathHullInset);
cur.dispatch(FuncRequest(LFUN_RIGHT));
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple")); cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel)); cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel));
} else { } else {
cur.insert(new InsetFormulaMacro(sel)); cur.insert(new InsetFormulaMacro(sel));
cur.dispatch(FuncRequest(LFUN_RIGHT));
} }
} }
cur.message(N_("Math editor mode")); cur.message(N_("Math editor mode"));