mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Simplified code and don't enter inset on cursor down/up while we are selecting.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4013 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1bef00e7a3
commit
ba79607927
@ -150,8 +150,6 @@ src/frontends/xforms/input_validators.C
|
||||
src/frontends/xforms/Menubar_pimpl.C
|
||||
src/frontends/xforms/xforms_helpers.C
|
||||
src/gettext.h
|
||||
src/graphics/GraphicsCacheItem.C
|
||||
src/graphics/GraphicsConverter.C
|
||||
src/importer.C
|
||||
src/insets/insetbib.C
|
||||
src/insets/inset.C
|
||||
|
@ -1217,9 +1217,10 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
|
||||
bv_->text->cursor.iy()
|
||||
+ bv_->theLockingInset()->insetInInsetY()
|
||||
+ y - text->cursor.row()->baseline());
|
||||
} else if (text->cursor.row()->height() < workarea_.height()) {
|
||||
} else if (text->cursor.irow()->height() < workarea_.height()) {
|
||||
screen_->draw(text, bv_, text->cursor.y() -
|
||||
text->cursor.row()->baseline());
|
||||
} else {
|
||||
}
|
||||
updateScrollbar();
|
||||
}
|
||||
@ -1454,7 +1455,7 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
|
||||
|
||||
|
||||
inline
|
||||
void BufferView::Pimpl::moveCursorUpdate(bool selecting)
|
||||
void BufferView::Pimpl::moveCursorUpdate(bool selecting, bool fitcur)
|
||||
{
|
||||
LyXText * lt = bv_->getLyXText();
|
||||
|
||||
@ -1466,7 +1467,10 @@ void BufferView::Pimpl::moveCursorUpdate(bool selecting)
|
||||
updateInset(lt->inset_owner, false);
|
||||
}
|
||||
if (lt->bv_owner) {
|
||||
update(lt, BufferView::SELECT|BufferView::FITCUR);
|
||||
if (fitcur)
|
||||
update(lt, BufferView::SELECT|BufferView::FITCUR);
|
||||
else
|
||||
update(lt, BufferView::SELECT);
|
||||
showCursor();
|
||||
}
|
||||
|
||||
@ -2056,7 +2060,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
update(lt, BufferView::UPDATE);
|
||||
cursorNext(lt);
|
||||
finishUndo();
|
||||
moveCursorUpdate(false);
|
||||
moveCursorUpdate(false, false);
|
||||
owner_->showState();
|
||||
}
|
||||
break;
|
||||
@ -2209,7 +2213,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
|
||||
update(lt,
|
||||
BufferView::SELECT|BufferView::FITCUR);
|
||||
lt->cursorUp(bv_);
|
||||
lt->cursorUp(bv_, true);
|
||||
finishUndo();
|
||||
moveCursorUpdate(true);
|
||||
owner_->showState();
|
||||
@ -2222,7 +2226,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
|
||||
update(lt,
|
||||
BufferView::SELECT|BufferView::FITCUR);
|
||||
lt->cursorDown(bv_);
|
||||
lt->cursorDown(bv_, true);
|
||||
finishUndo();
|
||||
moveCursorUpdate(true);
|
||||
owner_->showState();
|
||||
|
@ -200,7 +200,7 @@ private:
|
||||
///
|
||||
std::vector<Position> saved_positions;
|
||||
///
|
||||
void moveCursorUpdate(bool selecting);
|
||||
void moveCursorUpdate(bool selecting, bool fitcur = true);
|
||||
/// Get next inset of this class from current cursor position
|
||||
Inset * getInsetByCode(Inset::Code code);
|
||||
///
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-04-17 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.h: changed behind variables to front variables to be
|
||||
equal to the one in the edit call (as it is for that they are used).
|
||||
|
||||
2002-04-16 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* insetnote.h (ascii): overide the InsetCollapsable::ascii method to
|
||||
|
@ -1843,9 +1843,9 @@ UpdatableInset::RESULT
|
||||
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
|
||||
{
|
||||
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
||||
return moveLeftIntern(bv, false, activate_inset, selecting);
|
||||
return moveLeftIntern(bv, true, activate_inset, selecting);
|
||||
else
|
||||
return moveRightIntern(bv, false, activate_inset, selecting);
|
||||
return moveRightIntern(bv, true, activate_inset, selecting);
|
||||
}
|
||||
|
||||
|
||||
@ -1853,19 +1853,19 @@ UpdatableInset::RESULT
|
||||
InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
|
||||
{
|
||||
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
||||
return moveRightIntern(bv, true, activate_inset, selecting);
|
||||
return moveRightIntern(bv, false, activate_inset, selecting);
|
||||
else
|
||||
return moveLeftIntern(bv, true, activate_inset, selecting);
|
||||
return moveLeftIntern(bv, false, activate_inset, selecting);
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
InsetText::moveRightIntern(BufferView * bv, bool behind,
|
||||
InsetText::moveRightIntern(BufferView * bv, bool front,
|
||||
bool activate_inset, bool selecting)
|
||||
{
|
||||
if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
|
||||
return FINISHED_RIGHT;
|
||||
if (activate_inset && checkAndActivateInset(bv, behind))
|
||||
if (activate_inset && checkAndActivateInset(bv, front))
|
||||
return DISPATCHED;
|
||||
getLyXText(bv)->cursorRight(bv);
|
||||
if (!selecting)
|
||||
@ -1875,7 +1875,7 @@ InsetText::moveRightIntern(BufferView * bv, bool behind,
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
InsetText::moveLeftIntern(BufferView * bv, bool behind,
|
||||
InsetText::moveLeftIntern(BufferView * bv, bool front,
|
||||
bool activate_inset, bool selecting)
|
||||
{
|
||||
if (!cpar(bv)->previous() && (cpos(bv) <= 0))
|
||||
@ -1883,7 +1883,7 @@ InsetText::moveLeftIntern(BufferView * bv, bool behind,
|
||||
getLyXText(bv)->cursorLeft(bv);
|
||||
if (!selecting)
|
||||
getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
|
||||
if (activate_inset && checkAndActivateInset(bv, behind))
|
||||
if (activate_inset && checkAndActivateInset(bv, front))
|
||||
return DISPATCHED;
|
||||
return DISPATCHED_NOUPDATE;
|
||||
}
|
||||
@ -2022,27 +2022,14 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
||||
}
|
||||
|
||||
|
||||
bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
|
||||
bool InsetText::checkAndActivateInset(BufferView * bv, bool front)
|
||||
{
|
||||
if (cpar(bv)->isInset(cpos(bv))) {
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
Inset * inset =
|
||||
static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
|
||||
if (!isHighlyEditableInset(inset))
|
||||
return false;
|
||||
LyXFont const font =
|
||||
getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
|
||||
if (behind) {
|
||||
x = inset->width(bv, font);
|
||||
y = font.isRightToLeft() ? 0 : inset->descent(bv, font);
|
||||
} else {
|
||||
x = 0;
|
||||
y = font.isRightToLeft() ? inset->descent(bv, font) : 0;
|
||||
}
|
||||
//inset_x = cx(bv) - top_x + drawTextXOffset;
|
||||
//inset_y = cy(bv) + drawTextYOffset;
|
||||
inset->edit(bv, x, y, 0);
|
||||
inset->edit(bv, front);
|
||||
if (!the_locking_inset)
|
||||
return false;
|
||||
updateLocal(bv, CURSOR, false);
|
||||
|
@ -299,11 +299,11 @@ private:
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
///
|
||||
UpdatableInset::RESULT moveRightIntern(BufferView *, bool behind,
|
||||
UpdatableInset::RESULT moveRightIntern(BufferView *, bool front,
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
///
|
||||
UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind,
|
||||
UpdatableInset::RESULT moveLeftIntern(BufferView *, bool front,
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
|
||||
@ -314,7 +314,7 @@ private:
|
||||
///
|
||||
void setCharFont(Buffer const *, int pos, LyXFont const & font);
|
||||
///
|
||||
bool checkAndActivateInset(BufferView * bv, bool behind);
|
||||
bool checkAndActivateInset(BufferView * bv, bool front);
|
||||
///
|
||||
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
|
||||
int button = 0);
|
||||
|
@ -958,7 +958,9 @@ string const LyXFunc::dispatch(kb_action action, string argument)
|
||||
moveCursorUpdate(true, false);
|
||||
owner->showState();
|
||||
goto exit_with_message;
|
||||
} else {
|
||||
}
|
||||
#warning I am not sure this is still right, please have a look! (Jug 20020417)
|
||||
else { // result == UNDISPATCHED
|
||||
//setMessage(N_("Text mode"));
|
||||
switch (action) {
|
||||
case LFUN_UNKNOWN_ACTION:
|
||||
|
@ -340,9 +340,9 @@ public:
|
||||
void setCursorFromCoordinates(BufferView *, LyXCursor &,
|
||||
int x, int y) const;
|
||||
///
|
||||
void cursorUp(BufferView *) const;
|
||||
void cursorUp(BufferView *, bool selecting = false) const;
|
||||
///
|
||||
void cursorDown(BufferView *) const;
|
||||
void cursorDown(BufferView *, bool selecting = false) const;
|
||||
///
|
||||
void cursorLeft(BufferView *, bool internal = true) const;
|
||||
///
|
||||
|
32
src/text2.C
32
src/text2.C
@ -2319,17 +2319,21 @@ void LyXText::cursorRight(BufferView * bview, bool internal) const
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorUp(BufferView * bview) const
|
||||
void LyXText::cursorUp(BufferView * bview, bool selecting) const
|
||||
{
|
||||
#if 1
|
||||
int x = cursor.x_fix();
|
||||
int y = cursor.y() - cursor.row()->baseline() - 1;
|
||||
setCursorFromCoordinates(bview, x, y);
|
||||
int y1 = cursor.iy() - first_y;
|
||||
int y2 = y1;
|
||||
Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
|
||||
if (inset_hit && isHighlyEditableInset(inset_hit)) {
|
||||
inset_hit->edit(bview, x, y - (y2 - y1), 0);
|
||||
if (!selecting) {
|
||||
int y1 = cursor.iy() - first_y;
|
||||
int y2 = y1;
|
||||
y -= first_y;
|
||||
Inset * inset_hit =
|
||||
bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
|
||||
if (inset_hit && isHighlyEditableInset(inset_hit)) {
|
||||
inset_hit->edit(bview, x, y - (y2 - y1), 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
setCursorFromCoordinates(bview, cursor.x_fix(),
|
||||
@ -2338,18 +2342,22 @@ void LyXText::cursorUp(BufferView * bview) const
|
||||
}
|
||||
|
||||
|
||||
void LyXText::cursorDown(BufferView * bview) const
|
||||
void LyXText::cursorDown(BufferView * bview, bool selecting) const
|
||||
{
|
||||
#if 1
|
||||
int x = cursor.x_fix();
|
||||
int y = cursor.y() - cursor.row()->baseline() +
|
||||
cursor.row()->height() + 1;
|
||||
setCursorFromCoordinates(bview, x, y);
|
||||
int y1 = cursor.iy() - first_y;
|
||||
int y2 = y1;
|
||||
Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
|
||||
if (inset_hit && isHighlyEditableInset(inset_hit)) {
|
||||
inset_hit->edit(bview, x, y - (y2 - y1), 0);
|
||||
if (!selecting) {
|
||||
int y1 = cursor.iy() - first_y;
|
||||
int y2 = y1;
|
||||
y -= first_y;
|
||||
Inset * inset_hit =
|
||||
bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
|
||||
if (inset_hit && isHighlyEditableInset(inset_hit)) {
|
||||
inset_hit->edit(bview, x, y - (y2 - y1), 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
setCursorFromCoordinates(bview, cursor.x_fix(),
|
||||
|
Loading…
Reference in New Issue
Block a user