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
This commit is contained in:
Abdelrazak Younes 2006-10-22 10:51:59 +00:00
parent d890f45e25
commit 98a81507ad
5 changed files with 16 additions and 19 deletions

View File

@ -118,6 +118,8 @@ public:
/// do we have a paragraph with this id? /// do we have a paragraph with this id?
bool hasParWithID(int id) const; 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. /// This signal is emitted when some parsing error shows up.
boost::signal<void(std::string)> errors; boost::signal<void(std::string)> errors;
/// This signal is emitted when some message shows up. /// This signal is emitted when some message shows up.

View 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() WorkArea * LyXView::workArea()
{ {
return work_area_; return work_area_;
@ -136,7 +128,8 @@ void LyXView::setBuffer(Buffer * b)
updateToolbars(); updateToolbars();
updateLayoutChoice(); updateLayoutChoice();
updateWindowTitle(); updateWindowTitle();
redrawWorkArea(); updateStatusBar();
work_area_->redraw();
} }
@ -155,7 +148,8 @@ bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
connectBuffer(*work_area_->bufferView().buffer()); connectBuffer(*work_area_->bufferView().buffer());
showErrorList("Parse"); showErrorList("Parse");
} }
redrawWorkArea(); updateStatusBar();
work_area_->redraw();
return loaded; return loaded;
} }
@ -165,6 +159,10 @@ void LyXView::connectBuffer(Buffer & buf)
if (errorsConnection_.connected()) if (errorsConnection_.connected())
disconnectBuffer(); disconnectBuffer();
bufferChangedConnection_ =
buf.changed.connect(
boost::bind(&WorkArea::redraw, work_area_));
errorsConnection_ = errorsConnection_ =
buf.errors.connect( buf.errors.connect(
boost::bind(&LyXView::showErrorList, this, _1)); boost::bind(&LyXView::showErrorList, this, _1));
@ -197,6 +195,8 @@ void LyXView::connectBuffer(Buffer & buf)
void LyXView::disconnectBuffer() void LyXView::disconnectBuffer()
{ {
errorsConnection_.disconnect();
bufferChangedConnection_.disconnect();
messageConnection_.disconnect(); messageConnection_.disconnect();
busyConnection_.disconnect(); busyConnection_.disconnect();
titleConnection_.disconnect(); titleConnection_.disconnect();

View File

@ -152,9 +152,6 @@ public:
/// returns true if this view has the focus. /// returns true if this view has the focus.
virtual bool hasFocus() const = 0; 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. /// Temporary method to access the current workArea.
/// This is needed for the gtk frontend. /// This is needed for the gtk frontend.
frontend::WorkArea * workArea(); frontend::WorkArea * workArea();
@ -197,6 +194,8 @@ private:
/// dialogs for this view /// dialogs for this view
boost::scoped_ptr<Dialogs> dialogs_; boost::scoped_ptr<Dialogs> dialogs_;
/// buffer changed signal connection
boost::signals::connection bufferChangedConnection_;
/// buffer errors signal connection /// buffer errors signal connection
boost::signals::connection errorsConnection_; boost::signals::connection errorsConnection_;
/// buffer messages signal connection /// buffer messages signal connection

View File

@ -250,11 +250,6 @@ void WorkArea::processKeySym(LyXKeySymPtr key,
*/ */
// if (buffer_view_->buffer()) // if (buffer_view_->buffer())
toggleCursor(); 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();
} }

View File

@ -1606,7 +1606,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
else if (update) else if (update)
view()->update(Update::FitCursor); 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 we executed a mutating lfun, mark the buffer as dirty
if (flag.enabled() if (flag.enabled()