]> git.lyx.org Git - features.git/commitdiff
Simplified code and don't enter inset on cursor down/up while we are selecting.
authorJürgen Vigna <jug@sad.it>
Wed, 17 Apr 2002 08:34:59 +0000 (08:34 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 17 Apr 2002 08:34:59 +0000 (08:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4013 a592a061-630c-0410-9148-cb99ea01b6c8

po/POTFILES.in
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/insets/ChangeLog
src/insets/insettext.C
src/insets/insettext.h
src/lyxfunc.C
src/lyxtext.h
src/text2.C

index e9dce5852a9c50394901971e7ef2dc757a6e6f44..845e1749a8a94bc87774c27a85adebcb4c5f9691 100644 (file)
@@ -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
index 1a43fd4abc4050bdf1ec6dd6084f3968a9a4dca5..be1e1020be14f96ed295139960179bd0de536acc 100644 (file)
@@ -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();
index 9391bb6d2f791b52b4f672af8fe611f5f0d022e9..535adca5cc2f4005750b72a5bd617e195c35c5ef 100644 (file)
@@ -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);
        ///
index c3436a733080566de03a6f15a7eba92cfd86a597..3ead5971d3206f0d5d12e5f04d47840f6f2ec297 100644 (file)
@@ -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
index 27db48df81a157b2eeb6efcca79b53ceb3fe6b3c..b35065af69da726944d5a024d99c452f3b8faa29 100644 (file)
@@ -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);
index bb6beb768953f40fe1c03d31bee5f4fa7c683de6..1229044b5271bf9b23bcf2777abfcfba5d1b47de 100644 (file)
@@ -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);
index d4986d6b2f463ed2dff5b28a3988b228913555d4..bf587bfe0feb6bf7309fc0c34b28d77ea99ae139 100644 (file)
@@ -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:
index a595e2f7856fdc3f70153e6e29408886a44538dd..62247add0ac8dc1451a814e66f7a1771fb4f1e89 100644 (file)
@@ -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;
        ///
index 64c45adcd4dba101a12f6494daff96fd2099a81f..2e5d93d03dbce1152ce206eb782c60541abbfecb 100644 (file)
@@ -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(),