]> git.lyx.org Git - features.git/commitdiff
removing update calls
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 11 Nov 2003 13:17:28 +0000 (13:17 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 11 Nov 2003 13:17:28 +0000 (13:17 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8076 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/bufferview_funcs.C
src/cursor.C
src/cursor.h
src/dispatchresult.h
src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insettext.C
src/paragraph_funcs.C

index 6f6d80c3ed4b3a372d0a3d791e8d6879aea81376..61d686b090556aa4faf4da2ef8a64d4cff4b0e4f 100644 (file)
@@ -616,8 +616,6 @@ void BufferView::Pimpl::update()
 
        // check needed to survive LyX startup
        if (bv_->getLyXText()) {
-               bv_->getLyXText()->redoCursor();
-
                // update all 'visible' paragraphs
                ParagraphList::iterator beg;
                ParagraphList::iterator end;
@@ -625,7 +623,7 @@ void BufferView::Pimpl::update()
                               top_y(), top_y() + workarea().workHeight(),
                               beg, end);
                bv_->text->redoParagraphs(beg, end);
-
+               bv_->getLyXText()->redoCursor();
                updateScrollbar();
        }
        screen().redraw(*bv_);
@@ -962,8 +960,10 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                        cmd2.x -= inset->x();
                        cmd2.y -= inset->y();
                        res = inset->dispatch(cmd2);
-                       if (res.update())
+                       if (res.update()) {
                                bv_->update();
+                               bv_->cursor().updatePos();
+                       }
                        res.update(false);
                        switch (res.val()) {
                                case FINISHED:
@@ -973,6 +973,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                                        theTempCursor.pop();
                                        bv_->cursor() = theTempCursor;
                                        bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
+                                       bv_->cursor().updatePos();
                                        bv_->fitCursor();
                                        return true;
                                default:
@@ -987,12 +988,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                        lyxerr << "dispatching " << cmd1
                               << " to surrounding LyXText "
                               << bv_->cursor().innerText() << endl;
-                       cursor_ = theTempCursor;
+                       bv_->cursor() = theTempCursor;
                        theTempCursor.dispatch(cmd1);
+                       bv_->update();
+                       bv_->cursor().updatePos();
                        //return DispatchResult(true, true);
                }
-
-               bv_->update();
                // see workAreaKeyPress
                cursor_timeout.restart();
                screen().showCursor(*bv_);
index 655258b2ae67fa83bea0ca678c4b0359558a3114..faad588306d30f478451c0010bddbf767a92c095 100644 (file)
@@ -1,3 +1,9 @@
+2003-11-11  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * cursor.[Ch] (updatePos): new function for updating the y
+       position of the tip inset
+       * bufferview_funcs.C (put_selection_at): 
+       * BufferView_pimpl.C (workAreaDispatch): rationalise update calls
 
 2003-11-11  André Pönitz  <poenitz@gmx.net>
 
index d275b1c4ba90385996463e3bf6763d1a695f4fce..3f67f87d0e84cc80a8115dfc1edf50208cb321d5 100644 (file)
@@ -19,6 +19,7 @@
 #include "buffer.h"
 #include "bufferparams.h"
 #include "BufferView.h"
+#include "cursor.h"
 #include "gettext.h"
 #include "language.h"
 #include "LColor.h"
@@ -263,6 +264,20 @@ void replaceSelection(LyXText * text)
 }
 
 
+/*
+if the fitCursor call refers to some point in never-explored-land, then we
+don't have y information in insets there, then we cannot even do an update
+to get it (because we need the y infomation for setting top_y first). So
+this is solved in put_selection_at with:
+
+- setting top_y to the y of the outerPar (that has good info)
+- calling update
+- calling cursor().updatePos()
+- then call fitCursor()
+
+Ab.
+*/
+
 void put_selection_at(BufferView * bv, PosIterator const & cur,
                      int length, bool backwards)
 {
@@ -272,8 +287,12 @@ void put_selection_at(BufferView * bv, PosIterator const & cur,
 
        LyXText * text = par.text(bv);
        par.lockPath(bv);
-
+       //hack for the chicken and egg problem
+       if (par.inset())
+               bv->top_y(par.outerPar()->y);
+       bv->update();
        text->setCursor(cur.pit(), cur.pos());
+       bv->cursor().updatePos();
 
        if (length) {
                text->setSelectionRange(length);
@@ -281,7 +300,7 @@ void put_selection_at(BufferView * bv, PosIterator const & cur,
                if (backwards)
                        text->cursor = text->selection.start;
        }
-       
+
        bv->fitCursor();
        bv->update();
 }
index c3d7c950806215a5211c2498277ef4c8ed710094..383e615cb2aa2557b96da9ab95c5e7107498295a 100644 (file)
@@ -113,7 +113,7 @@ void LCursor::push(UpdatableInset * inset)
 {
        lyxerr << "LCursor::push()  inset: " << inset << endl;
        data_.push_back(CursorItem(inset));
-       cached_y_ = bv_->top_y() + inset->y();
+       cached_y_ = bv_->top_y() + innerInset()->y();
 }
 
 
@@ -157,6 +157,13 @@ LyXText * LCursor::innerText() const
 }
 
 
+void LCursor::updatePos()
+{
+       if (!data_.empty())
+               cached_y_ = bv_->top_y() + innerInset()->y();
+}
+
+
 void LCursor::getPos(int & x, int & y) const
 {
        if (data_.empty()) {
index a7f981b31e3a8a57fcf53b6163efd86364f9a8ba..6f43f2c0c4f188eba6ae256f63c1165ddb75b305 100644 (file)
@@ -75,6 +75,8 @@ public:
        LyXText * innerText() const;
        /// returns x,y position
        void getPos(int & x, int & y) const;
+       /// cache the absolute coordinate from the top inset
+       void updatePos();
        ///
        friend std::ostream & operator<<(std::ostream &, LCursor const &);
 public:
index 19aa2b979c44ec0564fad1bb5a0fe6c147f57090..16ed98e9d62fafd5c0d811e28824c5662db67672 100644 (file)
@@ -51,9 +51,9 @@ public:
        DispatchResult(bool dis)
                : dispatched_(dis), update_(false), val_(NONE) {}
        DispatchResult(bool dis, bool update)
-               : dispatched_(dis), update_(true), val_(NONE) {}
+               : dispatched_(dis), update_(update), val_(NONE) {}
        DispatchResult(bool dis, dispatch_result_t val)
-               : dispatched_(dis), update_(false), val_(val) {}
+               : dispatched_(dis), update_(true), val_(val) {}
        dispatch_result_t val() const { return val_; }
        void val(dispatch_result_t drt) {
                val_ = drt;
index 4f730fa10c54753af1ba49fc45835cf15626265f..d4cf4786b73e6374546ecf67c1c114bd974e7f67 100644 (file)
@@ -1,3 +1,8 @@
+2003-11-11  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * insettext.C: remove all update calls
+       * insetcollapsable.C: remove all update calls
+
 2003-11-11  Alfredo Braunstein  <abraunst@libero.it>
 
        * insettext.C (updateLocal, insertInset, setFont): remove 
index 6b9367c989b8ff845fb14b9eabfc2089b6c5ec5a..9f57b483dc9db6cfc63f448927bcb45fac979768 100644 (file)
@@ -205,8 +205,6 @@ DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
                lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
                collapsed_ = false;
                edit(bv, true);
-               bv->buffer()->markDirty();
-               bv->update();
                return DispatchResult(true, true);
        }
 
@@ -214,12 +212,9 @@ DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
                if (!collapsed_) {
                        collapsed_ = true;
                        lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
-                       bv->update();
                        return DispatchResult(false, FINISHED_RIGHT);
                }
                collapsed_ = false;
-               bv->update();
-               bv->buffer()->markDirty();
                lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
        } else if (!collapsed_ && cmd.y > button_dim.y2) {
                lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
@@ -281,8 +276,6 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
                collapsed_ = false;
                // set this only here as it should be recollapsed only if
                // it was already collapsed!
-               bv->update();
-               bv->buffer()->markDirty();
                inset.edit(bv, x, y);
        } else {
                if (y <= button_dim.y2)
@@ -398,7 +391,6 @@ void InsetCollapsable::open(BufferView * bv)
                return;
 
        collapsed_ = false;
-       bv->update();
 }
 
 
@@ -408,7 +400,6 @@ void InsetCollapsable::close(BufferView * bv) const
                return;
 
        collapsed_ = true;
-       bv->update();
 }
 
 
index bdc65b83cd8a638b543693af7a309304660f35cb..b505230851baa5df9a22cfa0813e9c3c23d24407 100644 (file)
@@ -290,7 +290,6 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
                text_.selection.cursor = text_.cursor;
 
 //     bv->fitCursor();
-       bv->update();
        bv->owner()->view_state_changed();
        bv->owner()->updateMenubar();
        bv->owner()->updateToolbar();
index 884b6933dc8af4af2c919ea8c8111d84904ab811..74d52499166eae8dbd10bde2ae9126dfee66728f 100644 (file)
@@ -628,6 +628,6 @@ void getParsInRange(ParagraphList & pl,
        for (--beg; beg != begpar && beg->y > ystart; --beg)
                ;
 
-       for (end = beg ; end != endpar && end->y < yend; ++end)
+       for (end = beg ; end != endpar && end->y <= yend; ++end)
                ;
 }