From: Jürgen Vigna Date: Wed, 17 Apr 2002 08:34:59 +0000 (+0000) Subject: Simplified code and don't enter inset on cursor down/up while we are selecting. X-Git-Tag: 1.6.10~19393 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ba7960792763492390c97d8dfa81c8b2c6f3202e;p=features.git 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 --- diff --git a/po/POTFILES.in b/po/POTFILES.in index e9dce5852a..845e1749a8 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 1a43fd4abc..be1e1020be 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.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(); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 9391bb6d2f..535adca5cc 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -200,7 +200,7 @@ private: /// std::vector 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); /// diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c3436a7330..3ead5971d3 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-04-17 Juergen Vigna + + * 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 * insetnote.h (ascii): overide the InsetCollapsable::ascii method to diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 27db48df81..b35065af69 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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(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); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index bb6beb7689..1229044b52 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -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); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d4986d6b2f..bf587bfe0f 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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: diff --git a/src/lyxtext.h b/src/lyxtext.h index a595e2f785..62247add0a 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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; /// diff --git a/src/text2.C b/src/text2.C index 64c45adcd4..2e5d93d03d 100644 --- a/src/text2.C +++ b/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(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(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(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(this), x, y1); + if (inset_hit && isHighlyEditableInset(inset_hit)) { + inset_hit->edit(bview, x, y - (y2 - y1), 0); + } } #else setCursorFromCoordinates(bview, cursor.x_fix(),