From: Abdelrazak Younes Date: Sun, 22 Oct 2006 10:51:59 +0000 (+0000) Subject: Immediate rendering of buffer change for one or multiple LyXView. X-Git-Tag: 1.6.10~12260 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=98a81507adba31e4bd5e1f0b3da44eea91d8545b;p=features.git Immediate rendering of buffer change for one or multiple LyXView. * 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 --- diff --git a/src/buffer.h b/src/buffer.h index b29d61e083..90a36be7ef 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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 changed; /// This signal is emitted when some parsing error shows up. boost::signal errors; /// This signal is emitted when some message shows up. diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index 5f600ac88a..3643581101 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -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(); diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index ba5e9f7e67..b6be9b0538 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -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_; + /// buffer changed signal connection + boost::signals::connection bufferChangedConnection_; /// buffer errors signal connection boost::signals::connection errorsConnection_; /// buffer messages signal connection diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index e581536ff9..19ad1071fa 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -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(); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 1ff7b53754..2e24f7f156 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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()