mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
split functions into logical pieces
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8253 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d80377e089
commit
bbcd13990a
@ -489,11 +489,10 @@ DispatchResult
|
|||||||
InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
||||||
idx_type & idx, pos_type & pos)
|
idx_type & idx, pos_type & pos)
|
||||||
{
|
{
|
||||||
lyxerr << "# InsetTabular::dispatch: " << cmd << endl;
|
//lyxerr << "# InsetTabular::dispatch: " << cmd << endl;
|
||||||
|
|
||||||
DispatchResult result(true, true);
|
DispatchResult result(true, true);
|
||||||
BufferView * bv = cmd.view();
|
BufferView * bv = cmd.view();
|
||||||
lyxerr << "# cursor: " << bv->cursor() << endl;
|
|
||||||
|
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
@ -522,34 +521,29 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
<< "here" << endl;
|
<< "here" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
lyxerr << "# InsetTabular::dispatch 1: " << cmd << endl;
|
|
||||||
result = tabular.getCellInset(cell).dispatch(cmd, idx, pos);
|
result = tabular.getCellInset(cell).dispatch(cmd, idx, pos);
|
||||||
|
|
||||||
switch (result.val()) {
|
switch (result.val()) {
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
lyxerr << "# handle FINISHED_LEFT, act: " << actcell << endl;
|
if (movePrevCell(bv))
|
||||||
if (movePrevCell(bv, false))
|
|
||||||
result = DispatchResult(true, true);
|
result = DispatchResult(true, true);
|
||||||
else
|
else
|
||||||
result = DispatchResult(false, FINISHED);
|
result = DispatchResult(false, FINISHED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FINISHED_RIGHT:
|
case FINISHED_RIGHT:
|
||||||
lyxerr << "# handle FINISHED_RIGHT, act: " << actcell << endl;
|
if (moveNextCell(bv))
|
||||||
if (moveNextCell(bv, false))
|
|
||||||
result = DispatchResult(true, true);
|
result = DispatchResult(true, true);
|
||||||
else
|
else
|
||||||
result = DispatchResult(false, FINISHED_RIGHT);
|
result = DispatchResult(false, FINISHED_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FINISHED_UP:
|
case FINISHED_UP:
|
||||||
lyxerr << "# handle FINISHED_UP, act: " << actcell << endl;
|
result = moveUpLock(bv);
|
||||||
result = moveUp(bv, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FINISHED_DOWN:
|
case FINISHED_DOWN:
|
||||||
lyxerr << "# handle FINISHED_DOWN, act: " << actcell << endl;
|
result = moveDownLock(bv);
|
||||||
result = moveDown(bv, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -557,7 +551,6 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lyxerr << "# InsetTabular::dispatch 2: " << cmd << endl;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,9 +560,9 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
case LFUN_CELL_BACKWARD:
|
case LFUN_CELL_BACKWARD:
|
||||||
case LFUN_CELL_FORWARD:
|
case LFUN_CELL_FORWARD:
|
||||||
if (cmd.action == LFUN_CELL_FORWARD)
|
if (cmd.action == LFUN_CELL_FORWARD)
|
||||||
moveNextCell(bv, false);
|
moveNextCell(bv);
|
||||||
else
|
else
|
||||||
movePrevCell(bv, false);
|
movePrevCell(bv);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -594,7 +587,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
// if we are starting a selection, only select
|
// if we are starting a selection, only select
|
||||||
// the current cell at the beginning
|
// the current cell at the beginning
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
moveRight(bv, false);
|
moveRight(bv);
|
||||||
end = actcell;
|
end = actcell;
|
||||||
}
|
}
|
||||||
setSelection(start, end);
|
setSelection(start, end);
|
||||||
@ -602,7 +595,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_RIGHT:
|
case LFUN_RIGHT:
|
||||||
result = moveRight(bv, true);
|
result = moveRightLock(bv);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -617,7 +610,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
// if we are starting a selection, only select
|
// if we are starting a selection, only select
|
||||||
// the current cell at the beginning
|
// the current cell at the beginning
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
moveLeft(bv, false);
|
moveLeft(bv);
|
||||||
end = actcell;
|
end = actcell;
|
||||||
}
|
}
|
||||||
setSelection(start, end);
|
setSelection(start, end);
|
||||||
@ -625,7 +618,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_LEFT:
|
case LFUN_LEFT:
|
||||||
result = moveLeft(bv, true);
|
result = moveLeftLock(bv);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -635,7 +628,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
// if we are starting a selection, only select
|
// if we are starting a selection, only select
|
||||||
// the current cell at the beginning
|
// the current cell at the beginning
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
moveDown(bv, false);
|
moveDown(bv);
|
||||||
if (ocell == sel_cell_end ||
|
if (ocell == sel_cell_end ||
|
||||||
tabular.column_of_cell(ocell) > tabular.column_of_cell(actcell))
|
tabular.column_of_cell(ocell) > tabular.column_of_cell(actcell))
|
||||||
setSelection(start, tabular.getCellBelow(sel_cell_end));
|
setSelection(start, tabular.getCellBelow(sel_cell_end));
|
||||||
@ -648,7 +641,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_DOWN:
|
case LFUN_DOWN:
|
||||||
result = moveDown(bv, false);
|
result = moveDown(bv);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -658,7 +651,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
// if we are starting a selection, only select
|
// if we are starting a selection, only select
|
||||||
// the current cell at the beginning
|
// the current cell at the beginning
|
||||||
if (hasSelection()) {
|
if (hasSelection()) {
|
||||||
moveUp(bv, false);
|
moveUp(bv);
|
||||||
if (ocell == sel_cell_end ||
|
if (ocell == sel_cell_end ||
|
||||||
tabular.column_of_cell(ocell) > tabular.column_of_cell(actcell))
|
tabular.column_of_cell(ocell) > tabular.column_of_cell(actcell))
|
||||||
setSelection(start, tabular.getCellAbove(sel_cell_end));
|
setSelection(start, tabular.getCellAbove(sel_cell_end));
|
||||||
@ -671,7 +664,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_UP:
|
case LFUN_UP:
|
||||||
result = moveUp(bv, false);
|
result = moveUp(bv);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1079,62 +1072,93 @@ void InsetTabular::resetPos(BufferView * bv) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DispatchResult InsetTabular::moveRight(BufferView * bv, bool lock)
|
DispatchResult InsetTabular::moveRight(BufferView * bv)
|
||||||
{
|
{
|
||||||
bool moved = isRightToLeft(bv) ? movePrevCell(bv) : moveNextCell(bv);
|
bool moved = isRightToLeft(bv) ? movePrevCell(bv) : moveNextCell(bv);
|
||||||
if (!moved)
|
if (!moved)
|
||||||
return DispatchResult(false, FINISHED_RIGHT);
|
return DispatchResult(false, FINISHED_RIGHT);
|
||||||
if (lock) {
|
|
||||||
activateCellInset(bv, actcell, false);
|
|
||||||
return DispatchResult(true, true);
|
|
||||||
}
|
|
||||||
resetPos(bv);
|
resetPos(bv);
|
||||||
return DispatchResult(true);
|
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);
|
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
|
||||||
if (!moved)
|
if (!moved)
|
||||||
return DispatchResult(false, FINISHED);
|
return DispatchResult(false, FINISHED);
|
||||||
// behind the inset
|
|
||||||
if (lock) {
|
|
||||||
activateCellInset(bv, actcell, true);
|
|
||||||
return DispatchResult(true, true);
|
|
||||||
}
|
|
||||||
resetPos(bv);
|
resetPos(bv);
|
||||||
return DispatchResult(true);
|
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);
|
||||||
|
return DispatchResult(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DispatchResult InsetTabular::moveUpLock(BufferView * bv)
|
||||||
{
|
{
|
||||||
int const ocell = actcell;
|
int const ocell = actcell;
|
||||||
actcell = tabular.getCellAbove(actcell);
|
actcell = tabular.getCellAbove(actcell);
|
||||||
if (actcell == ocell) // we moved out of the inset
|
if (actcell == ocell) // we moved out of the inset
|
||||||
return DispatchResult(false, FINISHED_UP);
|
return DispatchResult(false, FINISHED_UP);
|
||||||
resetPos(bv);
|
resetPos(bv);
|
||||||
if (lock)
|
|
||||||
activateCellInset(bv, actcell, bv->x_target(), 0);
|
activateCellInset(bv, actcell, bv->x_target(), 0);
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DispatchResult InsetTabular::moveDown(BufferView * bv, bool lock)
|
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);
|
||||||
|
return DispatchResult(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DispatchResult InsetTabular::moveDownLock(BufferView * bv)
|
||||||
{
|
{
|
||||||
int const ocell = actcell;
|
int const ocell = actcell;
|
||||||
actcell = tabular.getCellBelow(actcell);
|
actcell = tabular.getCellBelow(actcell);
|
||||||
if (actcell == ocell) // we moved out of the inset
|
if (actcell == ocell) // we moved out of the inset
|
||||||
return DispatchResult(false, FINISHED_DOWN);
|
return DispatchResult(false, FINISHED_DOWN);
|
||||||
resetPos(bv);
|
resetPos(bv);
|
||||||
if (lock)
|
|
||||||
activateCellInset(bv, actcell, bv->x_target());
|
activateCellInset(bv, actcell, bv->x_target());
|
||||||
return DispatchResult(true, true);
|
return DispatchResult(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
|
bool InsetTabular::moveNextCell(BufferView * bv)
|
||||||
{
|
{
|
||||||
lyxerr << "InsetTabular::moveNextCell 1 actcell: " << actcell << endl;
|
lyxerr << "InsetTabular::moveNextCell 1 actcell: " << actcell << endl;
|
||||||
if (isRightToLeft(bv)) {
|
if (isRightToLeft(bv)) {
|
||||||
@ -1155,21 +1179,14 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
|
|||||||
++actcell;
|
++actcell;
|
||||||
}
|
}
|
||||||
lyxerr << "InsetTabular::moveNextCell 2 actcell: " << actcell << endl;
|
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);
|
resetPos(bv);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
|
bool InsetTabular::movePrevCell(BufferView * bv)
|
||||||
{
|
{
|
||||||
lyxerr << "move prevcell 1" << endl;
|
|
||||||
if (isRightToLeft(bv)) {
|
if (isRightToLeft(bv)) {
|
||||||
lyxerr << "move prevcell a" << endl;
|
|
||||||
if (tabular.isLastCellInRow(actcell)) {
|
if (tabular.isLastCellInRow(actcell)) {
|
||||||
int row = tabular.row_of_cell(actcell);
|
int row = tabular.row_of_cell(actcell);
|
||||||
if (row == 0)
|
if (row == 0)
|
||||||
@ -1182,20 +1199,11 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
|
|||||||
++actcell;
|
++actcell;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lyxerr << "move prevcell b" << endl;
|
|
||||||
if (actcell == 0) // first cell
|
if (actcell == 0) // first cell
|
||||||
return false;
|
return false;
|
||||||
--actcell;
|
--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);
|
resetPos(bv);
|
||||||
lyxerr << "move prevcell 4" << endl;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,6 +1232,7 @@ bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void checkLongtableSpecial(LyXTabular::ltType & ltt,
|
void checkLongtableSpecial(LyXTabular::ltType & ltt,
|
||||||
|
@ -179,17 +179,29 @@ private:
|
|||||||
///
|
///
|
||||||
void setPos(BufferView *, int x, int y) const;
|
void setPos(BufferView *, int x, int y) const;
|
||||||
///
|
///
|
||||||
DispatchResult moveRight(BufferView *, bool lock);
|
DispatchResult moveRight(BufferView *);
|
||||||
///
|
///
|
||||||
DispatchResult moveLeft(BufferView *, bool lock);
|
DispatchResult moveLeft(BufferView *);
|
||||||
///
|
///
|
||||||
DispatchResult moveUp(BufferView *, bool lock);
|
DispatchResult moveUp(BufferView *);
|
||||||
///
|
///
|
||||||
DispatchResult moveDown(BufferView *, bool lock);
|
DispatchResult moveDown(BufferView *);
|
||||||
|
|
||||||
///
|
///
|
||||||
bool moveNextCell(BufferView *, bool lock = false);
|
DispatchResult moveRightLock(BufferView *);
|
||||||
///
|
///
|
||||||
bool movePrevCell(BufferView *, bool lock = false);
|
DispatchResult moveLeftLock(BufferView *);
|
||||||
|
///
|
||||||
|
DispatchResult moveUpLock(BufferView *);
|
||||||
|
///
|
||||||
|
DispatchResult moveDownLock(BufferView *);
|
||||||
|
|
||||||
|
///
|
||||||
|
bool moveNextCell(BufferView *);
|
||||||
|
///
|
||||||
|
bool movePrevCell(BufferView *);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
int getCellXPos(int cell) const;
|
int getCellXPos(int cell) const;
|
||||||
///
|
///
|
||||||
|
@ -274,12 +274,11 @@ void InsetText::edit(BufferView * bv, bool left)
|
|||||||
lyxerr << "InsetText: edit left/right" << endl;
|
lyxerr << "InsetText: edit left/right" << endl;
|
||||||
old_par = -1;
|
old_par = -1;
|
||||||
setViewCache(bv);
|
setViewCache(bv);
|
||||||
|
int const par = left ? 0 : paragraphs().size() - 1;
|
||||||
if (left)
|
int const pos = left ? 0 : paragraphs().back().size();
|
||||||
text_.setCursorIntern(0, 0);
|
text_.setCursor(par, pos);
|
||||||
else
|
text_.clearSelection();
|
||||||
text_.setCursor(paragraphs().size() - 1, paragraphs().back().size());
|
finishUndo();
|
||||||
|
|
||||||
sanitizeEmptyText(bv);
|
sanitizeEmptyText(bv);
|
||||||
updateLocal(bv);
|
updateLocal(bv);
|
||||||
bv->updateParagraphDialog();
|
bv->updateParagraphDialog();
|
||||||
@ -290,13 +289,10 @@ void InsetText::edit(BufferView * bv, int x, int y)
|
|||||||
{
|
{
|
||||||
lyxerr << "InsetText::edit xy" << endl;
|
lyxerr << "InsetText::edit xy" << endl;
|
||||||
old_par = -1;
|
old_par = -1;
|
||||||
|
text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y() - text_.yo_);
|
||||||
sanitizeEmptyText(bv);
|
|
||||||
text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y()
|
|
||||||
- text_.yo_);
|
|
||||||
text_.clearSelection();
|
text_.clearSelection();
|
||||||
finishUndo();
|
finishUndo();
|
||||||
|
sanitizeEmptyText(bv);
|
||||||
updateLocal(bv);
|
updateLocal(bv);
|
||||||
bv->updateParagraphDialog();
|
bv->updateParagraphDialog();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user