#include "bufferparams.h"
#include "BufferView.h"
#include "debug.h"
+#include "dispatchresult.h"
#include "factory.h"
#include "funcrequest.h"
#include "gettext.h"
{
LyXText * lt = bv->getLyXText();
- //if (!lt->selection.set())
- // lt->selection.cursor = lt->cursor;
+// if (!lt->selection.set())
+// lt->selection.cursor = lt->cursor;
if (selecting || lt->selection.mark())
lt->setSelection();
void LyXText::cursorPrevious()
{
- int y = bv_owner->top_y();
+ int y = bv()->top_y();
- RowList::iterator rit = cursorRow();
+ ParagraphList::iterator cpit = cursorPar();
+ RowList::iterator crit = cpit->getRow(cursor.pos());
- if (rit == firstRow()) {
+ if (isFirstRow(cpit, *crit)) {
if (y > 0)
bv()->updateScrollbar();
return;
}
- setCursorFromCoordinates(cursor.x_fix(), y);
+ setCursorFromCoordinates(bv()->x_target(), y);
finishUndo();
- int new_y;
- if (rit == bv()->text->cursorRow()) {
+ if (crit == bv()->text->cursorRow()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the previous row instead.
cursorUp(true);
return;
- // This is what we used to do, so we wouldn't skip right past
- // tall rows, but it's not working right now.
+ }
+
+ int new_y = + crit->height() - bv()->workHeight() + 1;
+
+ if (inset_owner) {
+ new_y += bv()->text->cursor.y()
+ + bv()->theLockingInset()->insetInInsetY() + y;
} else {
- if (inset_owner) {
- new_y = bv()->text->cursor.y()
- + bv()->theLockingInset()->insetInInsetY() + y
- + rit->height()
- - bv()->workHeight() + 1;
- } else {
- new_y = cursor.y()
- - rit->baseline()
- + rit->height()
- - bv()->workHeight() + 1;
- }
+ new_y += cursor.y() - crit->baseline();
}
+ previousRow(cpit, crit);
LyXCursor cur;
- rit = cursorRow();
- ParagraphList::iterator pit = cursorPar();
- rit = cursorRow();
- previousRow(pit, rit);
- setCursor(cur, parOffset(pit), rit->pos(), false);
- if (cur.y() > bv_owner->top_y())
+ setCursor(cur, parOffset(cpit), crit->pos(), false);
+ if (cur.y() > bv()->top_y())
cursorUp(true);
bv()->updateScrollbar();
}
void LyXText::cursorNext()
{
- int topy = bv_owner->top_y();
+ int topy = bv()->top_y();
- RowList::iterator rit = cursorRow();
- if (rit == lastRow()) {
- int y = cursor.y() - rit->baseline() + cursorRow()->height();
+ ParagraphList::iterator cpit = cursorPar();
+ RowList::iterator crit = cpit->getRow(cursor.pos());
+
+ if (isLastRow(cpit, *crit)) {
+ int y = cursor.y() - crit->baseline() + crit->height();
if (y > topy + bv()->workHeight())
- bv_owner->updateScrollbar();
+ bv()->updateScrollbar();
return;
}
- int y = topy + bv_owner->workHeight();
+ int y = topy + bv()->workHeight();
if (inset_owner && !topy) {
- y -= (bv_owner->text->cursor.y()
- - bv_owner->top_y()
- + bv_owner->theLockingInset()->insetInInsetY());
+ y -= (bv()->text->cursor.y()
+ - bv()->top_y()
+ + bv()->theLockingInset()->insetInInsetY());
}
ParagraphList::iterator dummypit;
Row const & rr = *getRowNearY(y, dummypit);
y = dummypit->y + rr.y_offset();
- setCursorFromCoordinates(cursor.x_fix(), y);
+ setCursorFromCoordinates(bv()->x_target(), y);
// + bv->workHeight());
finishUndo();
int new_y;
- if (rit == bv_owner->text->cursorRow()) {
+ if (crit == bv()->text->cursorRow()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the next row instead.
cursorDown(true);
#if 0
new_y = bv->top_y() + bv->workHeight();
#endif
+ }
+
+ if (inset_owner) {
+ new_y = bv()->text->cursor.y()
+ + bv()->theLockingInset()->insetInInsetY()
+ + y - crit->baseline();
} else {
- if (inset_owner) {
- new_y = bv()->text->cursor.y()
- + bv()->theLockingInset()->insetInInsetY()
- + y - rit->baseline();
- } else {
- new_y = cursor.y() - cursorRow()->baseline();
- }
+ new_y = cursor.y() - crit->baseline();
}
- ParagraphList::iterator pit = cursorPar();
- rit = cursorRow();
- nextRow(pit, rit);
+
+ nextRow(cpit, crit);
LyXCursor cur;
- setCursor(cur, parOffset(pit), rit->pos(), false);
+ setCursor(cur, parOffset(cpit), crit->pos(), false);
if (cur.y() < bv_owner->top_y() + bv()->workHeight())
cursorDown(true);
bv()->updateScrollbar();
} // anon namespace
-dispatch_result LyXText::dispatch(FuncRequest const & cmd)
+DispatchResult LyXText::dispatch(FuncRequest const & cmd)
{
lyxerr[Debug::ACTION] << "LyXText::dispatch: action[" << cmd.action
<<"] arg[" << cmd.argument << ']' << "xy[" <<
if (cursor.pos() == 0
&& !(params.spaceTop() == VSpace (VSpace::NONE))) {
setParagraph(
- params.lineTop(),
- params.lineBottom(),
- params.pagebreakTop(),
- params.pagebreakBottom(),
VSpace(VSpace::NONE),
params.spaceBottom(),
params.spacing(),
ParagraphParameters & params = cursorPar()->params();
if (cursor.pos() == 0 && !(params.spaceTop() == VSpace(VSpace::NONE))) {
setParagraph(
- params.lineTop(),
- params.lineBottom(),
- params.pagebreakTop(),
- params.pagebreakBottom(),
VSpace(VSpace::NONE),
params.spaceBottom(),
params.spacing(),
ParagraphParameters & params = getPar(cur)->params();
if (params.spaceTop() == VSpace(VSpace::NONE)) {
setParagraph(
- params.lineTop(),
- params.lineBottom(),
- params.pagebreakTop(),
- params.pagebreakBottom(),
VSpace(VSpace::DEFSKIP), params.spaceBottom(),
params.spacing(),
params.align(),
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
- return UNDISPATCHED;
+ return DispatchResult(false);
cursorTop();
finishChange(bv, true);
break;
case LFUN_ENDBUFSEL:
if (inset_owner)
- return UNDISPATCHED;
+ return DispatchResult(false);
cursorBottom();
finishChange(bv, true);
break;
bv->text->setCursorFromCoordinates(x, y + screen_first);
finishUndo();
bv->text->selection.cursor = bv->text->cursor;
- bv->text->cursor.x_fix(bv->text->cursor.x());
+ bv->x_target(bv->text->cursor.x());
if (bv->fitCursor())
selection_possible = false;
case LFUN_INDEX_PRINT:
case LFUN_TOC_INSERT:
case LFUN_HFILL:
+ case LFUN_INSERT_LINE:
+ case LFUN_INSERT_PAGEBREAK:
// do nothing fancy
doInsertInset(this, cmd, false, false);
break;
break;
default:
- return UNDISPATCHED;
+ return DispatchResult(false);
}
- return DISPATCHED;
+ return DispatchResult(true, true);
}