mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 00:20:43 +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/Menubar_pimpl.C
|
||||||
src/frontends/xforms/xforms_helpers.C
|
src/frontends/xforms/xforms_helpers.C
|
||||||
src/gettext.h
|
src/gettext.h
|
||||||
src/graphics/GraphicsCacheItem.C
|
|
||||||
src/graphics/GraphicsConverter.C
|
|
||||||
src/importer.C
|
src/importer.C
|
||||||
src/insets/insetbib.C
|
src/insets/insetbib.C
|
||||||
src/insets/inset.C
|
src/insets/inset.C
|
||||||
|
@ -1217,9 +1217,10 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
|
|||||||
bv_->text->cursor.iy()
|
bv_->text->cursor.iy()
|
||||||
+ bv_->theLockingInset()->insetInInsetY()
|
+ bv_->theLockingInset()->insetInInsetY()
|
||||||
+ y - text->cursor.row()->baseline());
|
+ 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() -
|
screen_->draw(text, bv_, text->cursor.y() -
|
||||||
text->cursor.row()->baseline());
|
text->cursor.row()->baseline());
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
updateScrollbar();
|
updateScrollbar();
|
||||||
}
|
}
|
||||||
@ -1454,7 +1455,7 @@ void BufferView::Pimpl::stuffClipboard(string const & stuff) const
|
|||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void BufferView::Pimpl::moveCursorUpdate(bool selecting)
|
void BufferView::Pimpl::moveCursorUpdate(bool selecting, bool fitcur)
|
||||||
{
|
{
|
||||||
LyXText * lt = bv_->getLyXText();
|
LyXText * lt = bv_->getLyXText();
|
||||||
|
|
||||||
@ -1466,7 +1467,10 @@ void BufferView::Pimpl::moveCursorUpdate(bool selecting)
|
|||||||
updateInset(lt->inset_owner, false);
|
updateInset(lt->inset_owner, false);
|
||||||
}
|
}
|
||||||
if (lt->bv_owner) {
|
if (lt->bv_owner) {
|
||||||
update(lt, BufferView::SELECT|BufferView::FITCUR);
|
if (fitcur)
|
||||||
|
update(lt, BufferView::SELECT|BufferView::FITCUR);
|
||||||
|
else
|
||||||
|
update(lt, BufferView::SELECT);
|
||||||
showCursor();
|
showCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2056,7 +2060,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
|||||||
update(lt, BufferView::UPDATE);
|
update(lt, BufferView::UPDATE);
|
||||||
cursorNext(lt);
|
cursorNext(lt);
|
||||||
finishUndo();
|
finishUndo();
|
||||||
moveCursorUpdate(false);
|
moveCursorUpdate(false, false);
|
||||||
owner_->showState();
|
owner_->showState();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2209,7 +2213,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
|||||||
|
|
||||||
update(lt,
|
update(lt,
|
||||||
BufferView::SELECT|BufferView::FITCUR);
|
BufferView::SELECT|BufferView::FITCUR);
|
||||||
lt->cursorUp(bv_);
|
lt->cursorUp(bv_, true);
|
||||||
finishUndo();
|
finishUndo();
|
||||||
moveCursorUpdate(true);
|
moveCursorUpdate(true);
|
||||||
owner_->showState();
|
owner_->showState();
|
||||||
@ -2222,7 +2226,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
|||||||
|
|
||||||
update(lt,
|
update(lt,
|
||||||
BufferView::SELECT|BufferView::FITCUR);
|
BufferView::SELECT|BufferView::FITCUR);
|
||||||
lt->cursorDown(bv_);
|
lt->cursorDown(bv_, true);
|
||||||
finishUndo();
|
finishUndo();
|
||||||
moveCursorUpdate(true);
|
moveCursorUpdate(true);
|
||||||
owner_->showState();
|
owner_->showState();
|
||||||
|
@ -200,7 +200,7 @@ private:
|
|||||||
///
|
///
|
||||||
std::vector<Position> saved_positions;
|
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
|
/// Get next inset of this class from current cursor position
|
||||||
Inset * getInsetByCode(Inset::Code code);
|
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>
|
2002-04-16 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* insetnote.h (ascii): overide the InsetCollapsable::ascii method to
|
* insetnote.h (ascii): overide the InsetCollapsable::ascii method to
|
||||||
|
@ -1843,9 +1843,9 @@ UpdatableInset::RESULT
|
|||||||
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
|
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
|
||||||
{
|
{
|
||||||
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
||||||
return moveLeftIntern(bv, false, activate_inset, selecting);
|
return moveLeftIntern(bv, true, activate_inset, selecting);
|
||||||
else
|
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)
|
InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
|
||||||
{
|
{
|
||||||
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
||||||
return moveRightIntern(bv, true, activate_inset, selecting);
|
return moveRightIntern(bv, false, activate_inset, selecting);
|
||||||
else
|
else
|
||||||
return moveLeftIntern(bv, true, activate_inset, selecting);
|
return moveLeftIntern(bv, false, activate_inset, selecting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UpdatableInset::RESULT
|
UpdatableInset::RESULT
|
||||||
InsetText::moveRightIntern(BufferView * bv, bool behind,
|
InsetText::moveRightIntern(BufferView * bv, bool front,
|
||||||
bool activate_inset, bool selecting)
|
bool activate_inset, bool selecting)
|
||||||
{
|
{
|
||||||
if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
|
if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
|
||||||
return FINISHED_RIGHT;
|
return FINISHED_RIGHT;
|
||||||
if (activate_inset && checkAndActivateInset(bv, behind))
|
if (activate_inset && checkAndActivateInset(bv, front))
|
||||||
return DISPATCHED;
|
return DISPATCHED;
|
||||||
getLyXText(bv)->cursorRight(bv);
|
getLyXText(bv)->cursorRight(bv);
|
||||||
if (!selecting)
|
if (!selecting)
|
||||||
@ -1875,7 +1875,7 @@ InsetText::moveRightIntern(BufferView * bv, bool behind,
|
|||||||
|
|
||||||
|
|
||||||
UpdatableInset::RESULT
|
UpdatableInset::RESULT
|
||||||
InsetText::moveLeftIntern(BufferView * bv, bool behind,
|
InsetText::moveLeftIntern(BufferView * bv, bool front,
|
||||||
bool activate_inset, bool selecting)
|
bool activate_inset, bool selecting)
|
||||||
{
|
{
|
||||||
if (!cpar(bv)->previous() && (cpos(bv) <= 0))
|
if (!cpar(bv)->previous() && (cpos(bv) <= 0))
|
||||||
@ -1883,7 +1883,7 @@ InsetText::moveLeftIntern(BufferView * bv, bool behind,
|
|||||||
getLyXText(bv)->cursorLeft(bv);
|
getLyXText(bv)->cursorLeft(bv);
|
||||||
if (!selecting)
|
if (!selecting)
|
||||||
getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
|
getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
|
||||||
if (activate_inset && checkAndActivateInset(bv, behind))
|
if (activate_inset && checkAndActivateInset(bv, front))
|
||||||
return DISPATCHED;
|
return DISPATCHED;
|
||||||
return DISPATCHED_NOUPDATE;
|
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))) {
|
if (cpar(bv)->isInset(cpos(bv))) {
|
||||||
unsigned int x;
|
|
||||||
unsigned int y;
|
|
||||||
Inset * inset =
|
Inset * inset =
|
||||||
static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
|
static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
|
||||||
if (!isHighlyEditableInset(inset))
|
if (!isHighlyEditableInset(inset))
|
||||||
return false;
|
return false;
|
||||||
LyXFont const font =
|
inset->edit(bv, front);
|
||||||
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);
|
|
||||||
if (!the_locking_inset)
|
if (!the_locking_inset)
|
||||||
return false;
|
return false;
|
||||||
updateLocal(bv, CURSOR, false);
|
updateLocal(bv, CURSOR, false);
|
||||||
|
@ -299,11 +299,11 @@ private:
|
|||||||
bool activate_inset = true,
|
bool activate_inset = true,
|
||||||
bool selecting = false);
|
bool selecting = false);
|
||||||
///
|
///
|
||||||
UpdatableInset::RESULT moveRightIntern(BufferView *, bool behind,
|
UpdatableInset::RESULT moveRightIntern(BufferView *, bool front,
|
||||||
bool activate_inset = true,
|
bool activate_inset = true,
|
||||||
bool selecting = false);
|
bool selecting = false);
|
||||||
///
|
///
|
||||||
UpdatableInset::RESULT moveLeftIntern(BufferView *, bool behind,
|
UpdatableInset::RESULT moveLeftIntern(BufferView *, bool front,
|
||||||
bool activate_inset = true,
|
bool activate_inset = true,
|
||||||
bool selecting = false);
|
bool selecting = false);
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ private:
|
|||||||
///
|
///
|
||||||
void setCharFont(Buffer const *, int pos, LyXFont const & font);
|
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,
|
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
|
||||||
int button = 0);
|
int button = 0);
|
||||||
|
@ -958,7 +958,9 @@ string const LyXFunc::dispatch(kb_action action, string argument)
|
|||||||
moveCursorUpdate(true, false);
|
moveCursorUpdate(true, false);
|
||||||
owner->showState();
|
owner->showState();
|
||||||
goto exit_with_message;
|
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"));
|
//setMessage(N_("Text mode"));
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case LFUN_UNKNOWN_ACTION:
|
case LFUN_UNKNOWN_ACTION:
|
||||||
|
@ -340,9 +340,9 @@ public:
|
|||||||
void setCursorFromCoordinates(BufferView *, LyXCursor &,
|
void setCursorFromCoordinates(BufferView *, LyXCursor &,
|
||||||
int x, int y) const;
|
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;
|
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
|
#if 1
|
||||||
int x = cursor.x_fix();
|
int x = cursor.x_fix();
|
||||||
int y = cursor.y() - cursor.row()->baseline() - 1;
|
int y = cursor.y() - cursor.row()->baseline() - 1;
|
||||||
setCursorFromCoordinates(bview, x, y);
|
setCursorFromCoordinates(bview, x, y);
|
||||||
int y1 = cursor.iy() - first_y;
|
if (!selecting) {
|
||||||
int y2 = y1;
|
int y1 = cursor.iy() - first_y;
|
||||||
Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
|
int y2 = y1;
|
||||||
if (inset_hit && isHighlyEditableInset(inset_hit)) {
|
y -= first_y;
|
||||||
inset_hit->edit(bview, x, y - (y2 - y1), 0);
|
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
|
#else
|
||||||
setCursorFromCoordinates(bview, cursor.x_fix(),
|
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
|
#if 1
|
||||||
int x = cursor.x_fix();
|
int x = cursor.x_fix();
|
||||||
int y = cursor.y() - cursor.row()->baseline() +
|
int y = cursor.y() - cursor.row()->baseline() +
|
||||||
cursor.row()->height() + 1;
|
cursor.row()->height() + 1;
|
||||||
setCursorFromCoordinates(bview, x, y);
|
setCursorFromCoordinates(bview, x, y);
|
||||||
int y1 = cursor.iy() - first_y;
|
if (!selecting) {
|
||||||
int y2 = y1;
|
int y1 = cursor.iy() - first_y;
|
||||||
Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
|
int y2 = y1;
|
||||||
if (inset_hit && isHighlyEditableInset(inset_hit)) {
|
y -= first_y;
|
||||||
inset_hit->edit(bview, x, y - (y2 - y1), 0);
|
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
|
#else
|
||||||
setCursorFromCoordinates(bview, cursor.x_fix(),
|
setCursorFromCoordinates(bview, cursor.x_fix(),
|
||||||
|
Loading…
Reference in New Issue
Block a user