]> git.lyx.org Git - lyx.git/commitdiff
Some more fixes to selection, fitCursor calls for InsetText/Tabular.
authorJürgen Vigna <jug@sad.it>
Fri, 29 Mar 2002 15:49:45 +0000 (15:49 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 29 Mar 2002 15:49:45 +0000 (15:49 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3864 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/BufferView2.C
src/ChangeLog
src/insets/ChangeLog
src/insets/insettabular.C
src/insets/insettext.C
src/lyxfunc.C
src/screen.C

index 028466fc4285e6885704a221d02725e09fecb18b..68a19e76b251f04324946ce3636f14c56c201d4e 100644 (file)
@@ -83,9 +83,9 @@ void BufferView::redraw()
 }
 
 
-void BufferView::fitCursor()
+bool BufferView::fitCursor()
 {
-       pimpl_->fitCursor();
+       return pimpl_->fitCursor();
 }
 
 
index bb1a72c3a330f573bc66aff22155b87e2bd5b8b4..72bbc4c1dc19458b49ba06c3b3e4cca159af5425 100644 (file)
@@ -64,7 +64,7 @@ public:
        ///
        void redraw();
        ///
-       void fitCursor();
+       bool fitCursor();
        ///
        void update();
        //
@@ -169,7 +169,7 @@ public:
        ///
        void hideLockedInsetCursor();
        ///
-       void fitLockedInsetCursor(int x, int y, int asc, int desc);
+       bool fitLockedInsetCursor(int x, int y, int asc, int desc);
        ///
        int unlockInset(UpdatableInset * inset);
        ///
index da33665c2797885bfbff2d4212e47fc0091ec5f3..fa9456ea50788a105b496d7242557021762e5155 100644 (file)
@@ -587,13 +587,16 @@ void BufferView::hideLockedInsetCursor()
 }
 
 
-void BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
+bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
 {
        if (theLockingInset() && available()) {
                y += text->cursor.y() + theLockingInset()->insetInInsetY();
-               if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc))
+               if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc)) {
                        updateScrollbar();
+                       return true;
+               }
        }
+       return false;
 }
 
 
index 84747d7dd7cd7dae476b3ecde05b022a0b762e91..f3487eeac4d49f00b901bf5c68b118f0b63e4bb4 100644 (file)
@@ -1,5 +1,15 @@
 2002-03-29  Juergen Vigna  <jug@sad.it>
 
+       * lyxfunc.C (dispatch): add a missing fitCursor call.
+
+       * BufferView2.C (fitLockedInsetCursor): the inset needs to know if
+       it was scrolled by a cursor move, so return the bool status.
+
+       * BufferView.C (fitCursor): return the bool flag also to the outside
+       world as this is needed.
+
+       * screen.C (toggleToggle): don't subtract the offset if it's positive.
+
        * BufferView_pimpl.C (workAreaButtonPress): just lock the inset don't
        call the edit() as it is not needed (and wrong) IMO.
        (workAreaButtonPress): set the screen_first variable before evt.
index 60dfe91d895785a8458f748b760586f2f7dc2259..20c9268229dd8333481e6e21108367bbce3ac946 100644 (file)
@@ -1,8 +1,14 @@
 2002-03-29  Juergen Vigna  <jug@sad.it>
 
+       * insettext.C (updateLocal): fixes to fitCursor calls when locking/
+       unlocking inset.
+
+       * insettabular.C (edit): call fitCursor().
+
        * insettext.C (insetButtonPress): change behaviour of no_selection
        to the one in the BufferView selection_possible and fix the spurious
        selection bug with it.
+       (localDispatch): revoke selection on BREAK... functions.
 
 2002-03-28  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
index 11e692028a5460118fd359de44760826319a0bcb..b4496156bc563170accf8f75e60dc3f75e8be368 100644 (file)
@@ -578,6 +578,7 @@ void InsetTabular::edit(BufferView * bv, bool front)
                lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
                return;
        }
+       finishUndo();
        locked = true;
        the_locking_inset = 0;
        inset_x = 0;
@@ -588,7 +589,7 @@ void InsetTabular::edit(BufferView * bv, bool front)
                actcell = tabular->GetNumberOfCells() - 1;
        clearSelection();
        resetPos(bv);
-       finishUndo();
+       bv->fitCursor();
 }
 
 
@@ -1276,7 +1277,10 @@ InsetTabular::localDispatch(BufferView * bv, kb_action action,
        }
        if (result < FINISHED) {
                if (!the_locking_inset) {
-//                     showInsetCursor(bv);
+                       if (bv->fitCursor())
+                               updateLocal(bv, FULL, false);
+                       if (locked)
+                               showInsetCursor(bv);
                }
        } else
                bv->unlockInset(this);
@@ -1454,14 +1458,18 @@ void InsetTabular::hideInsetCursor(BufferView * bv)
 void InsetTabular::fitInsetCursor(BufferView * bv) const
 {
        if (the_locking_inset) {
+               int old_first_y = bv->text->first_y;
                the_locking_inset->fitInsetCursor(bv);
+               if (old_first_y != bv->text->first_y)
+                       need_update = FULL;
                return;
        }
        LyXFont font;
 
        int const asc = lyxfont::maxAscent(font);
        int const desc = lyxfont::maxDescent(font);
-       bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
+       if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
+               need_update = FULL;
 }
 
 
index e44b51aba4614c78fb7a7966ef972006f45e9643..3ceb4f48812088d2d5af000f6cfb8fbe54e070fe 100644 (file)
@@ -618,16 +618,17 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
        }
        lt->fullRebreak(bv);
        setUpdateStatus(bv, what);
-       bool flag = (((need_update != CURSOR) && (need_update != NONE)) ||
-                    (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
+       bool flag = mark_dirty ||
+               (((need_update != CURSOR) && (need_update != NONE)) ||
+                (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
        if (!lt->selection.set())
                lt->selection.cursor = lt->cursor;
        if (clear)
                lt = 0;
+       if (locked && (need_update & CURSOR) && bv->fitCursor())
+               need_update |= FULL;
        if (flag)
                bv->updateInset(const_cast<InsetText *>(this), mark_dirty);
-       else
-               bv->fitCursor();
 
        if (need_update == CURSOR)
                need_update = NONE;
@@ -681,7 +682,6 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
                font.setLanguage(bv->getParentLanguage(this));
                setFont(bv, font, false);
        }
-//     showInsetCursor(bv);
        if (clear)
                lt = 0;
 
@@ -689,6 +689,7 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button)
        if (drawFrame_ == LOCKED)
                code = CURSOR|DRAW_FRAME;
        updateLocal(bv, code, false);
+       showInsetCursor(bv);
 
        // Tell the paragraph dialog that we've entered an insettext.
        bv->owner()->getDialogs()->updateParagraph();
@@ -733,13 +734,13 @@ void InsetText::edit(BufferView * bv, bool front)
                font.setLanguage(bv->getParentLanguage(this));
                setFont(bv, font, false);
        }
-//     showInsetCursor(bv);
        if (clear)
                lt = 0;
        int code = CURSOR;
        if (drawFrame_ == LOCKED)
                code = CURSOR|DRAW_FRAME;
        updateLocal(bv, code, false);
+       showInsetCursor(bv);
 }
 
 
@@ -918,7 +919,7 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
 
 void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
 {
-       no_selection = false;
+       no_selection = true;
 
        // use this to check mouse motion for selection!
        mouse_x = x;
@@ -953,8 +954,8 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
                the_locking_inset->insetUnlock(bv);
                the_locking_inset = 0;
        }
-       if (inset)
-               no_selection = true;
+       if (!inset)
+               no_selection = false;
 
        if (bv->theLockingInset()) {
                if (isHighlyEditableInset(inset)) {
@@ -1057,13 +1058,15 @@ bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
 
 void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
 {
-       if (no_selection || ((mouse_x == x) && (mouse_y == y)))
-               return;
        if (the_locking_inset) {
                the_locking_inset->insetMotionNotify(bv, x - inset_x,
                                                     y - inset_y,state);
                return;
        }
+
+       if (no_selection || ((mouse_x == x) && (mouse_y == y)))
+               return;
+
        bool clear = false;
        if (!lt) {
                lt = getLyXText(bv);
@@ -1147,6 +1150,7 @@ InsetText::localDispatch(BufferView * bv,
 #ifdef WITH_WARNINGS
 #warning I changed this to always return Dispatched maybe it is wrong (20011001 Jug)
 #endif
+                       updateLocal(bv, CURSOR, false);
                        return result;
                }
        }
@@ -1322,7 +1326,7 @@ InsetText::localDispatch(BufferView * bv,
                        break;
                }
                lt->breakParagraph(bv, 0);
-               updwhat = FULL;
+               updwhat = CURSOR | FULL;
                updflag = true;
                break;
        case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
@@ -1331,7 +1335,7 @@ InsetText::localDispatch(BufferView * bv,
                        break;
                }
                lt->breakParagraph(bv, 1);
-               updwhat = FULL;
+               updwhat = CURSOR | FULL;
                updflag = true;
                break;
 
@@ -1343,7 +1347,7 @@ InsetText::localDispatch(BufferView * bv,
                setUndo(bv, Undo::INSERT,
                        lt->cursor.par(), lt->cursor.par()->next());
                lt->insertChar(bv, Paragraph::META_NEWLINE);
-               updwhat = CURSOR_PAR;
+               updwhat = CURSOR | CURSOR_PAR;
                updflag = true;
        }
        break;
@@ -1454,6 +1458,9 @@ InsetText::localDispatch(BufferView * bv,
 
        if (result >= FINISHED)
                bv->unlockInset(this);
+
+       if (result == DISPATCHED_NOUPDATE && (need_update & FULL))
+               result = DISPATCHED;
        return result;
 }
 
@@ -1771,7 +1778,8 @@ void InsetText::fitInsetCursor(BufferView * bv) const
        int const asc = lyxfont::maxAscent(font);
        int const desc = lyxfont::maxDescent(font);
 
-       bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+       if (bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc))
+               need_update |= FULL;
 }
 
 
index 63afaf34d77d18ec8c7e67a96d8aec49e45feb1d..af1d9f9571da9494c84adde14f1591293fe653c2 100644 (file)
@@ -922,6 +922,8 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                                        TEXT()->cursorUp(owner->view());
                                        moveCursorUpdate(true, false);
                                        owner->showState();
+                               } else {
+                                       owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
                                }
                                goto exit_with_message;
                        } else if (result == UpdatableInset::FINISHED_DOWN) {
index e3d27a5d084b4faeba9c6755fd6c2d60f9a062ae..66df051f80cfdf48e1d93db51512269a8203a9cd 100644 (file)
@@ -522,10 +522,11 @@ void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
                - text->toggle_end_cursor.row()->baseline()
                + text->toggle_end_cursor.row()->height();
 
+       int const offset = y_offset < 0 ? y_offset : 0;
        int const bottom = min(max(bottom_tmp, text->first_y),
-                    static_cast<int>(text->first_y + owner.height()))-y_offset;
+                    static_cast<int>(text->first_y + owner.height()))-offset;
        int const top = min(max(top_tmp, text->first_y),
-                 static_cast<int>(text->first_y + owner.height()))-y_offset;
+                 static_cast<int>(text->first_y + owner.height()))-offset;
        
        drawFromTo(text, bv, top - text->first_y,
                   bottom - text->first_y, y_offset,