InsetTabular::priv_dispatch(FuncRequest const & cmd,
idx_type & idx, pos_type & pos)
{
- lyxerr << "# InsetTabular::dispatch: " << cmd << endl;
+ //lyxerr << "# InsetTabular::dispatch: " << cmd << endl;
DispatchResult result(true, true);
BufferView * bv = cmd.view();
- lyxerr << "# cursor: " << bv->cursor() << endl;
switch (cmd.action) {
<< "here" << endl;
}
- lyxerr << "# InsetTabular::dispatch 1: " << cmd << endl;
result = tabular.getCellInset(cell).dispatch(cmd, idx, pos);
switch (result.val()) {
case FINISHED:
- lyxerr << "# handle FINISHED_LEFT, act: " << actcell << endl;
- if (movePrevCell(bv, false))
+ if (movePrevCell(bv))
result = DispatchResult(true, true);
else
result = DispatchResult(false, FINISHED);
break;
case FINISHED_RIGHT:
- lyxerr << "# handle FINISHED_RIGHT, act: " << actcell << endl;
- if (moveNextCell(bv, false))
+ if (moveNextCell(bv))
result = DispatchResult(true, true);
else
result = DispatchResult(false, FINISHED_RIGHT);
break;
case FINISHED_UP:
- lyxerr << "# handle FINISHED_UP, act: " << actcell << endl;
- result = moveUp(bv, true);
+ result = moveUpLock(bv);
break;
case FINISHED_DOWN:
- lyxerr << "# handle FINISHED_DOWN, act: " << actcell << endl;
- result = moveDown(bv, true);
+ result = moveDownLock(bv);
break;
default:
break;
}
- lyxerr << "# InsetTabular::dispatch 2: " << cmd << endl;
return result;
}
case LFUN_CELL_BACKWARD:
case LFUN_CELL_FORWARD:
if (cmd.action == LFUN_CELL_FORWARD)
- moveNextCell(bv, false);
+ moveNextCell(bv);
else
- movePrevCell(bv, false);
+ movePrevCell(bv);
clearSelection();
return result;
// if we are starting a selection, only select
// the current cell at the beginning
if (hasSelection()) {
- moveRight(bv, false);
+ moveRight(bv);
end = actcell;
}
setSelection(start, end);
}
case LFUN_RIGHT:
- result = moveRight(bv, true);
+ result = moveRightLock(bv);
clearSelection();
break;
// if we are starting a selection, only select
// the current cell at the beginning
if (hasSelection()) {
- moveLeft(bv, false);
+ moveLeft(bv);
end = actcell;
}
setSelection(start, end);
}
case LFUN_LEFT:
- result = moveLeft(bv, true);
+ result = moveLeftLock(bv);
clearSelection();
break;
// if we are starting a selection, only select
// the current cell at the beginning
if (hasSelection()) {
- moveDown(bv, false);
+ moveDown(bv);
if (ocell == sel_cell_end ||
tabular.column_of_cell(ocell) > tabular.column_of_cell(actcell))
setSelection(start, tabular.getCellBelow(sel_cell_end));
}
case LFUN_DOWN:
- result = moveDown(bv, false);
+ result = moveDown(bv);
clearSelection();
break;
// if we are starting a selection, only select
// the current cell at the beginning
if (hasSelection()) {
- moveUp(bv, false);
+ moveUp(bv);
if (ocell == sel_cell_end ||
tabular.column_of_cell(ocell) > tabular.column_of_cell(actcell))
setSelection(start, tabular.getCellAbove(sel_cell_end));
}
case LFUN_UP:
- result = moveUp(bv, false);
+ result = moveUp(bv);
clearSelection();
break;
}
-DispatchResult InsetTabular::moveRight(BufferView * bv, bool lock)
+DispatchResult InsetTabular::moveRight(BufferView * bv)
{
bool moved = isRightToLeft(bv) ? movePrevCell(bv) : moveNextCell(bv);
if (!moved)
return DispatchResult(false, FINISHED_RIGHT);
- if (lock) {
- activateCellInset(bv, actcell, false);
- return DispatchResult(true, true);
- }
resetPos(bv);
return DispatchResult(true);
}
-DispatchResult InsetTabular::moveLeft(BufferView * bv, bool lock)
+DispatchResult InsetTabular::moveRightLock(BufferView * bv)
+{
+ bool moved = isRightToLeft(bv) ? movePrevCell(bv) : moveNextCell(bv);
+ if (!moved)
+ return DispatchResult(false, FINISHED_RIGHT);
+ activateCellInset(bv, actcell, false);
+ return DispatchResult(true, true);
+}
+
+
+DispatchResult InsetTabular::moveLeft(BufferView * bv)
{
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
if (!moved)
return DispatchResult(false, FINISHED);
- // behind the inset
- if (lock) {
- activateCellInset(bv, actcell, true);
- return DispatchResult(true, true);
- }
resetPos(bv);
return DispatchResult(true);
}
-DispatchResult InsetTabular::moveUp(BufferView * bv, bool lock)
+DispatchResult InsetTabular::moveLeftLock(BufferView * bv)
+{
+ bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
+ if (!moved)
+ return DispatchResult(false, FINISHED);
+ activateCellInset(bv, actcell, true);
+ return DispatchResult(true, true);
+}
+
+
+DispatchResult InsetTabular::moveUp(BufferView * bv)
{
int const ocell = actcell;
actcell = tabular.getCellAbove(actcell);
if (actcell == ocell) // we moved out of the inset
return DispatchResult(false, FINISHED_UP);
resetPos(bv);
- if (lock)
- activateCellInset(bv, actcell, bv->x_target(), 0);
return DispatchResult(true, true);
}
-DispatchResult InsetTabular::moveDown(BufferView * bv, bool lock)
+DispatchResult InsetTabular::moveUpLock(BufferView * bv)
+{
+ int const ocell = actcell;
+ actcell = tabular.getCellAbove(actcell);
+ if (actcell == ocell) // we moved out of the inset
+ return DispatchResult(false, FINISHED_UP);
+ resetPos(bv);
+ activateCellInset(bv, actcell, bv->x_target(), 0);
+ return DispatchResult(true, true);
+}
+
+
+DispatchResult InsetTabular::moveDown(BufferView * bv)
{
int const ocell = actcell;
actcell = tabular.getCellBelow(actcell);
if (actcell == ocell) // we moved out of the inset
return DispatchResult(false, FINISHED_DOWN);
resetPos(bv);
- if (lock)
- activateCellInset(bv, actcell, bv->x_target());
return DispatchResult(true, true);
}
-bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
+DispatchResult InsetTabular::moveDownLock(BufferView * bv)
+{
+ int const ocell = actcell;
+ actcell = tabular.getCellBelow(actcell);
+ if (actcell == ocell) // we moved out of the inset
+ return DispatchResult(false, FINISHED_DOWN);
+ resetPos(bv);
+ activateCellInset(bv, actcell, bv->x_target());
+ return DispatchResult(true, true);
+}
+
+
+bool InsetTabular::moveNextCell(BufferView * bv)
{
lyxerr << "InsetTabular::moveNextCell 1 actcell: " << actcell << endl;
if (isRightToLeft(bv)) {
++actcell;
}
lyxerr << "InsetTabular::moveNextCell 2 actcell: " << actcell << endl;
- if (lock) {
- bool rtl = tabular.getCellInset(actcell).paragraphs().begin()->
- isRightToLeftPar(bv->buffer()->params());
- activateCellInset(bv, actcell, !rtl);
- }
resetPos(bv);
return true;
}
-bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
+bool InsetTabular::movePrevCell(BufferView * bv)
{
- lyxerr << "move prevcell 1" << endl;
if (isRightToLeft(bv)) {
- lyxerr << "move prevcell a" << endl;
if (tabular.isLastCellInRow(actcell)) {
int row = tabular.row_of_cell(actcell);
if (row == 0)
++actcell;
}
} else {
- lyxerr << "move prevcell b" << endl;
if (actcell == 0) // first cell
return false;
--actcell;
}
- lyxerr << "move prevcell 2" << endl;
- if (lock) {
- bool rtl = tabular.getCellInset(actcell).paragraphs().begin()->
- isRightToLeftPar(bv->buffer()->params());
- activateCellInset(bv, actcell, !rtl);
- }
- lyxerr << "move prevcell 3" << endl;
resetPos(bv);
- lyxerr << "move prevcell 4" << endl;
return true;
}
return true;
}
+
namespace {
void checkLongtableSpecial(LyXTabular::ltType & ltt,