]> git.lyx.org Git - features.git/commitdiff
Immediate rendering of buffer change for one or multiple LyXView.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 22 Oct 2006 10:51:59 +0000 (10:51 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 22 Oct 2006 10:51:59 +0000 (10:51 +0000)
* Buffer: new changed() boost::signal.

* LyXView:
  - redrawWorkArea(): deleted
  - bufferChangedConnection_: new signal connection

* LyXFunc: replace LyXView::redrawWorkArea() direct call with Buffer::changed() signal emission.

* WorkArea.C: deleted some comments about redrawWorkArea.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15464 a592a061-630c-0410-9148-cb99ea01b6c8

src/buffer.h
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/WorkArea.C
src/lyxfunc.C

index b29d61e083d862e0812b2db69754c353c29e9c32..90a36be7ef097f2d1620cba82f420cee5777497b 100644 (file)
@@ -118,6 +118,8 @@ public:
        /// do we have a paragraph with this id?
        bool hasParWithID(int id) const;
 
+       /// This signal is emitted when the buffer is changed.
+       boost::signal<void()> changed;
        /// This signal is emitted when some parsing error shows up.
        boost::signal<void(std::string)> errors;
        /// This signal is emitted when some message shows up.
index 5f600ac88af2015a9cebace10cf5d04980e3be13..3643581101f22b32a6523e7e9f347ce92cf2af73 100644 (file)
@@ -94,14 +94,6 @@ void LyXView::setWorkArea(WorkArea * work_area)
 }
 
 
-void LyXView::redrawWorkArea()
-{
-       lyxerr[Debug::WORKAREA] << "LyXView::redrawWorkArea" << std::endl;
-       work_area_->redraw();
-       updateStatusBar();
-}
-
-
 WorkArea * LyXView::workArea()
 {
        return work_area_;
@@ -136,7 +128,8 @@ void LyXView::setBuffer(Buffer * b)
        updateToolbars();
        updateLayoutChoice();
        updateWindowTitle();
-       redrawWorkArea();
+       updateStatusBar();
+       work_area_->redraw();
 }
 
 
@@ -155,7 +148,8 @@ bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
                connectBuffer(*work_area_->bufferView().buffer());
                showErrorList("Parse");
        }
-       redrawWorkArea();
+       updateStatusBar();
+       work_area_->redraw();
        return loaded;
 }
 
@@ -165,6 +159,10 @@ void LyXView::connectBuffer(Buffer & buf)
        if (errorsConnection_.connected())
                disconnectBuffer();
 
+       bufferChangedConnection_ =
+               buf.changed.connect(
+                       boost::bind(&WorkArea::redraw, work_area_));
+
        errorsConnection_ =
                buf.errors.connect(
                        boost::bind(&LyXView::showErrorList, this, _1));
@@ -197,6 +195,8 @@ void LyXView::connectBuffer(Buffer & buf)
 
 void LyXView::disconnectBuffer()
 {
+       errorsConnection_.disconnect();
+       bufferChangedConnection_.disconnect();
        messageConnection_.disconnect();
        busyConnection_.disconnect();
        titleConnection_.disconnect();
index ba5e9f7e6735969c12bbec294470a2764ba730c6..b6be9b053824f8334f4f2e4600f792c5508c85b8 100644 (file)
@@ -152,9 +152,6 @@ public:
        /// returns true if this view has the focus.
        virtual bool hasFocus() const = 0;
 
-       /// Temporary method used by the kernel to redraw the work area.
-       virtual void redrawWorkArea();
-
        /// Temporary method to access the current workArea.
        /// This is needed for the gtk frontend.
        frontend::WorkArea * workArea();
@@ -197,6 +194,8 @@ private:
        /// dialogs for this view
        boost::scoped_ptr<Dialogs> dialogs_;
 
+       /// buffer changed signal connection
+       boost::signals::connection bufferChangedConnection_;
        /// buffer errors signal connection
        boost::signals::connection errorsConnection_;
        /// buffer messages signal connection
index e581536ff9ef35dfbf3bca8e1ec20da9d8ed347c..19ad1071faa3fbb14a737d7fda56790c75535755 100644 (file)
@@ -250,11 +250,6 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
         */
 //     if (buffer_view_->buffer())
        toggleCursor();
-       
-       // uneeded "redraw()" call commented out for now.
-       // When/if the call to LyXView::redrawWorkArea() in "lyxfunc.C:1610"
-       // is not needed anymore, this line should be uncommented out
-       //redraw();
 }
 
 
index 1ff7b537544c90f421cb00b610c80e488232fe48..2e24f7f1563753185095d833bb5556af8d9389ac 100644 (file)
@@ -1606,7 +1606,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        else if (update)
                                view()->update(Update::FitCursor);
 
-                       lyx_view_->redrawWorkArea();
+                       view()->buffer()->changed();
+                       lyx_view_->updateStatusBar();
 
                        // if we executed a mutating lfun, mark the buffer as dirty
                        if (flag.enabled()