mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 14:29:21 +00:00
Transfer and bug fix LFUN_BUFFER_BEGIN/END_SELECT to BufferView.cpp
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23512 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5a9653203f
commit
a4d5b78430
@ -902,14 +902,9 @@ FuncStatus BufferView::getStatus(FuncRequest const & cmd)
|
||||
case LFUN_SCREEN_UP:
|
||||
case LFUN_SCREEN_DOWN:
|
||||
case LFUN_SCROLL:
|
||||
flag.enabled(true);
|
||||
break;
|
||||
|
||||
// FIXME: LFUN_SCREEN_DOWN_SELECT should be removed from
|
||||
// everywhere else before this can enabled:
|
||||
case LFUN_SCREEN_UP_SELECT:
|
||||
case LFUN_SCREEN_DOWN_SELECT:
|
||||
flag.enabled(false);
|
||||
flag.enabled(true);
|
||||
break;
|
||||
|
||||
case LFUN_LAYOUT_TABULAR:
|
||||
@ -1311,26 +1306,37 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
lfunScroll(cmd);
|
||||
break;
|
||||
|
||||
case LFUN_SCREEN_UP_SELECT:
|
||||
case LFUN_SCREEN_DOWN_SELECT: {
|
||||
// Those two are not ready yet for consumption.
|
||||
return false;
|
||||
|
||||
case LFUN_SCREEN_UP_SELECT: {
|
||||
cur.selHandle(true);
|
||||
size_t initial_depth = cur.depth();
|
||||
Point const p = getPos(cur, cur.boundary());
|
||||
scroll(cmd.action == LFUN_SCREEN_UP_SELECT? - height_ : height_);
|
||||
// FIXME: We need to verify if the cursor stayed within an inset...
|
||||
//cur.reset(buffer_.inset());
|
||||
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);
|
||||
cur.finishUndo();
|
||||
while (cur.depth() > initial_depth) {
|
||||
cur.forwardInset();
|
||||
if (isTopScreen()) {
|
||||
lyx::dispatch(FuncRequest(LFUN_BUFFER_BEGIN_SELECT));
|
||||
cur.finishUndo();
|
||||
break;
|
||||
}
|
||||
// FIXME: we need to do a redraw again because of the selection
|
||||
// But no screen update is needed.
|
||||
d->update_strategy_ = NoScreenUpdate;
|
||||
buffer_.changed();
|
||||
int y = getPos(cur, cur.boundary()).y_;
|
||||
int const ymin = y - height_ + defaultRowHeight();
|
||||
while (y > ymin && cur.up())
|
||||
y = getPos(cur, cur.boundary()).y_;
|
||||
|
||||
cur.finishUndo();
|
||||
processUpdateFlags(Update::SinglePar | Update::FitCursor);
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_SCREEN_DOWN_SELECT: {
|
||||
cur.selHandle(true);
|
||||
if (isBottomScreen()) {
|
||||
lyx::dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
|
||||
cur.finishUndo();
|
||||
break;
|
||||
}
|
||||
int y = getPos(cur, cur.boundary()).y_;
|
||||
int const ymax = y + height_ - defaultRowHeight();
|
||||
while (y < ymax && cur.down())
|
||||
y = getPos(cur, cur.boundary()).y_;
|
||||
|
||||
cur.finishUndo();
|
||||
processUpdateFlags(Update::SinglePar | Update::FitCursor);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1554,7 +1554,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
|
||||
if (pit() + 1 >= int(text()->paragraphs().size()) &&
|
||||
row + 1 >= int(pm.rows().size()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// with and without selection are handled differently
|
||||
if (!selection()) {
|
||||
@ -1587,7 +1587,10 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
|
||||
top().pos() = min(tm.x2pos(pit(), row - 1, xo), top().lastpos());
|
||||
} else if (pit() > 0) {
|
||||
--pit();
|
||||
ParagraphMetrics const & pmcur = bv_->parMetrics(text(), pit());
|
||||
TextMetrics & tm = bv_->textMetrics(text());
|
||||
if (!tm.contains(pit()))
|
||||
tm.newParMetricsUp();
|
||||
ParagraphMetrics const & pmcur = tm.parMetrics(pit());
|
||||
top().pos() = min(tm.x2pos(pit(), pmcur.rows().size() - 1, xo), top().lastpos());
|
||||
}
|
||||
} else {
|
||||
@ -1595,6 +1598,9 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
|
||||
top().pos() = min(tm.x2pos(pit(), row + 1, xo), top().lastpos());
|
||||
} else if (pit() + 1 < int(text()->paragraphs().size())) {
|
||||
++pit();
|
||||
TextMetrics & tm = bv_->textMetrics(text());
|
||||
if (!tm.contains(pit()))
|
||||
tm.newParMetricsDown();
|
||||
top().pos() = min(tm.x2pos(pit(), 0, xo), top().lastpos());
|
||||
}
|
||||
}
|
||||
|
@ -604,25 +604,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
needsUpdate |= cursorDownParagraph(cur);
|
||||
break;
|
||||
|
||||
case LFUN_SCREEN_UP_SELECT:
|
||||
needsUpdate |= cur.selHandle(true);
|
||||
if (cur.pit() == 0 && cur.textRow().pos() == 0)
|
||||
cur.undispatched();
|
||||
else {
|
||||
tm.cursorPrevious(cur);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_SCREEN_DOWN_SELECT:
|
||||
needsUpdate |= cur.selHandle(true);
|
||||
if (cur.pit() == cur.lastpit()
|
||||
&& cur.textRow().endpos() == cur.lastpos())
|
||||
cur.undispatched();
|
||||
else {
|
||||
tm.cursorNext(cur);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_LINE_BEGIN:
|
||||
case LFUN_LINE_BEGIN_SELECT:
|
||||
needsUpdate |= cur.selHandle(cmd.action == LFUN_LINE_BEGIN_SELECT);
|
||||
@ -2137,8 +2118,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
case LFUN_DOWN_SELECT:
|
||||
case LFUN_PARAGRAPH_UP_SELECT:
|
||||
case LFUN_PARAGRAPH_DOWN_SELECT:
|
||||
case LFUN_SCREEN_UP_SELECT:
|
||||
case LFUN_SCREEN_DOWN_SELECT:
|
||||
case LFUN_LINE_BEGIN_SELECT:
|
||||
case LFUN_LINE_END_SELECT:
|
||||
case LFUN_WORD_FORWARD_SELECT:
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "InsetList.h"
|
||||
#include "Layout.h"
|
||||
#include "Length.h"
|
||||
#include "LyXFunc.h"
|
||||
#include "LyXRC.h"
|
||||
#include "MetricsInfo.h"
|
||||
#include "paragraph_funcs.h"
|
||||
@ -1611,73 +1610,6 @@ int TextMetrics::cursorY(CursorSlice const & sl, bool boundary) const
|
||||
}
|
||||
|
||||
|
||||
void TextMetrics::cursorPrevious(Cursor & cur)
|
||||
{
|
||||
if (bv_->isTopScreen()) {
|
||||
lyx::dispatch(FuncRequest(cur.selection()
|
||||
? LFUN_BUFFER_BEGIN_SELECT : LFUN_BUFFER_BEGIN));
|
||||
cur.finishUndo();
|
||||
cur.updateFlags(Update::None);
|
||||
return;
|
||||
}
|
||||
|
||||
pos_type cpos = cur.pos();
|
||||
pit_type cpar = cur.pit();
|
||||
|
||||
// Memorize current position.
|
||||
Point p = bv_->getPos(cur, cur.boundary());
|
||||
// Scroll one full page.
|
||||
lyx::dispatch(FuncRequest(LFUN_SCROLL, "page up"));
|
||||
// Try to place the cursor to the same coordinates.
|
||||
setCursorFromCoordinates(cur, p.x_, p.y_);
|
||||
// And move one line up in order to acknowledge in inset movement and/or
|
||||
// selection.
|
||||
cur.dispatch(FuncRequest(cur.selection()? LFUN_UP_SELECT: LFUN_UP));
|
||||
|
||||
if (cpar == cur.pit() && cpos == cur.pos())
|
||||
// we have a row which is taller than the workarea. The
|
||||
// simplest solution is to move to the previous row instead.
|
||||
cur.dispatch(FuncRequest(cur.selection()? LFUN_UP_SELECT: LFUN_UP));
|
||||
|
||||
cur.finishUndo();
|
||||
cur.updateFlags(Update::Force | Update::FitCursor);
|
||||
}
|
||||
|
||||
|
||||
void TextMetrics::cursorNext(Cursor & cur)
|
||||
{
|
||||
if (bv_->isBottomScreen()) {
|
||||
lyx::dispatch(FuncRequest(cur.selection()
|
||||
? LFUN_BUFFER_END_SELECT : LFUN_BUFFER_END));
|
||||
cur.finishUndo();
|
||||
cur.updateFlags(Update::None);
|
||||
return;
|
||||
}
|
||||
|
||||
pos_type cpos = cur.pos();
|
||||
pit_type cpar = cur.pit();
|
||||
|
||||
// Memorize current position.
|
||||
Point p = bv_->getPos(cur, cur.boundary());
|
||||
// Scroll one full page.
|
||||
lyx::dispatch(FuncRequest(LFUN_SCROLL, "page down"));
|
||||
// Try to place the cursor to the same coordinates.
|
||||
setCursorFromCoordinates(cur, p.x_, p.y_);
|
||||
// And move one line down in order to acknowledge in inset movement and/or
|
||||
// selection.
|
||||
cur.dispatch(FuncRequest(cur.selection()? LFUN_DOWN_SELECT: LFUN_DOWN));
|
||||
|
||||
if (cpar == cur.pit() && cpos == cur.pos())
|
||||
// we have a row which is taller than the workarea. The
|
||||
// simplest solution is to move to the next row instead.
|
||||
cur.dispatch(
|
||||
FuncRequest(cur.selection()? LFUN_DOWN_SELECT: LFUN_DOWN));
|
||||
|
||||
cur.finishUndo();
|
||||
cur.updateFlags(Update::Force | Update::FitCursor);
|
||||
}
|
||||
|
||||
|
||||
// the cursor set functions have a special mechanism. When they
|
||||
// realize you left an empty paragraph, they will delete it.
|
||||
|
||||
|
@ -211,10 +211,6 @@ public:
|
||||
int cursorY(CursorSlice const & cursor,
|
||||
bool boundary) const;
|
||||
|
||||
///
|
||||
void cursorPrevious(Cursor & cur);
|
||||
///
|
||||
void cursorNext(Cursor & cur);
|
||||
///
|
||||
bool cursorHome(Cursor & cur);
|
||||
///
|
||||
|
@ -665,16 +665,6 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_SCREEN_UP_SELECT:
|
||||
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
|
||||
cur.undispatched();
|
||||
break;
|
||||
|
||||
case LFUN_SCREEN_DOWN_SELECT:
|
||||
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
|
||||
cur.undispatched();
|
||||
break;
|
||||
|
||||
case LFUN_CELL_FORWARD:
|
||||
cur.updateFlags(Update::Decoration | Update::FitCursor);
|
||||
cur.inset().idxNext(cur);
|
||||
|
Loading…
Reference in New Issue
Block a user