1
0
mirror of https://git.lyx.org/repos/lyx.git synced 2025-01-11 03:03:06 +00:00

* BufferView::update(): renamed to processUpdateFlags() to clarify the intent. Also get rid of the default argument which added to the confusion as to what was the purpose of update(). Now also emit Buffer::changed() signal internally instead of assuming that the caller will act upon the returned boolean.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20884 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-10-10 08:52:55 +00:00
parent 6a474e739c
commit e3032e7d0e
8 changed files with 37 additions and 43 deletions

View File

@ -415,7 +415,7 @@ bool BufferView::multiParSel()
}
bool BufferView::update(Update::flags flags)
void BufferView::processUpdateFlags(Update::flags flags)
{
// last_inset_ points to the last visited inset. This pointer may become
// invalid because of keyboard editing. Since all such operations
@ -441,12 +441,13 @@ bool BufferView::update(Update::flags flags)
if (!flags) {
// no need to redraw anything.
metrics_info_.update_strategy = NoScreenUpdate;
return false;
return;
}
if (flags == Update::Decoration) {
metrics_info_.update_strategy = DecorationUpdate;
return true;
buffer_.changed();
return;
}
if (flags == Update::FitCursor
@ -455,15 +456,17 @@ bool BufferView::update(Update::flags flags)
// tell the frontend to update the screen if needed.
if (fit_cursor) {
updateMetrics(false);
return true;
buffer_.changed();
return;
}
if (flags & Update::Decoration) {
metrics_info_.update_strategy = DecorationUpdate;
return true;
buffer_.changed();
return;
}
// no screen update is needed.
metrics_info_.update_strategy = NoScreenUpdate;
return false;
return;
}
bool full_metrics = flags & Update::Force;
@ -473,21 +476,24 @@ bool BufferView::update(Update::flags flags)
bool const single_par = !full_metrics;
updateMetrics(single_par);
if (flags & Update::FitCursor) {
//FIXME: updateMetrics() does not update paragraph position
// This is done at draw() time. So we need a redraw!
if (!(flags & Update::FitCursor)) {
buffer_.changed();
if (fitCursor())
updateMetrics(false);
else
// The screen has already been updated thanks to the
// 'buffer_.changed()' call three line above. So no need
// to redraw again.
return false;
return;
}
// tell the frontend to update the screen.
return true;
//FIXME: updateMetrics() does not update paragraph position
// This is done at draw() time. So we need a redraw!
buffer_.changed();
if (!fitCursor())
// The screen has already been updated thanks to the
// 'buffer_.changed()' call three line above. So no need
// to redraw again.
return;
// The screen has been recentered around the cursor position so
// refresh it:
updateMetrics(false);
buffer_.changed();
}
@ -1403,11 +1409,8 @@ void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
// If the command has been dispatched,
if (cur.result().dispatched()
// an update is asked,
&& cur.result().update()
// and redraw is needed,
&& update(cur.result().update()))
// then trigger a redraw.
buffer_.changed();
&& cur.result().update())
processUpdateFlags(cur.result().update());
}
@ -1490,7 +1493,7 @@ void BufferView::gotoLabel(docstring const & label)
it->getLabelList(buffer_, labels);
if (std::find(labels.begin(), labels.end(), label) != labels.end()) {
setCursor(it);
update();
processUpdateFlags(Update::FitCursor);
return;
}
}

View File

@ -101,7 +101,7 @@ public:
* \c Update::Force means to force an update in any case.
* \retval true if a screen redraw is needed
*/
bool update(Update::flags flags = Update::FitCursor | Update::Force);
void processUpdateFlags(Update::flags flags);
/// move the screen to fit the cursor.
/// Only to be called with good y coordinates (after a bv::metrics)

View File

@ -266,7 +266,7 @@ void LyXFunc::handleKeyFunc(kb_action action)
keyseq.clear();
// copied verbatim from do_accent_char
view()->cursor().resetAnchor();
view()->update();
view()->processUpdateFlags(Update::FitCursor);
}
@ -1979,13 +1979,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
// also initializes the position cache for all insets in
// (at least partially) visible top-level paragraphs.
// We will redraw the screen only if needed.
if (view()->update(updateFlags)) {
// Buffer::changed() signals that a repaint is needed.
// The frontend (WorkArea) knows which area to repaint
// thanks to the ViewMetricsInfo updated above.
lyx_view_->buffer()->changed();
}
view()->processUpdateFlags(updateFlags);
lyx_view_->updateStatusBar();
// if we executed a mutating lfun, mark the buffer as dirty

View File

@ -1724,8 +1724,7 @@ void GuiDocument::dispatchParams()
"assign branch"));
}
// FIXME: If we used an LFUN, we would not need those two lines:
bufferview()->update();
lyxview().currentWorkArea()->redraw();
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
}

View File

@ -135,9 +135,8 @@ void GuiErrorList::goTo(int item)
pos_type const range = end - start;
DocIterator const dit = makeDocIterator(pit, start);
bufferview()->putSelectionAt(dit, range, false);
// FIXME: If we used an LFUN, we would not need those two lines:
bufferview()->update();
lyxview().currentWorkArea()->redraw();
// FIXME: If we used an LFUN, we would not need this line:
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
}

View File

@ -378,9 +378,8 @@ void GuiSpellchecker::check()
bufferview()->putSelectionAt(cur, size, false);
// FIXME: if we used a lfun like in find/replace, dispatch would do
// that for us
bufferview()->update();
// FIXME: this Controller is very badly designed...
lyxview().currentWorkArea()->redraw();
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
// set suggestions
if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
@ -434,7 +433,7 @@ void GuiSpellchecker::replace(docstring const & replacement)
cap::replaceSelectionWithString(bufferview()->cursor(), replacement, true);
buffer().markDirty();
// If we used an LFUN, we would not need that
bufferview()->update();
bufferview()->processUpdateFlags(Update::Force | Update::FitCursor);
// fix up the count
--count_;
check();

View File

@ -509,7 +509,7 @@ void GuiWorkArea::updateScreen()
void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape)
{
if (schedule_redraw_) {
buffer_view_->update(Update::Force);
buffer_view_->updateMetrics(false);
updateScreen();
viewport()->update(QRect(0, 0, viewport()->width(), viewport()->height()));
schedule_redraw_ = false;

View File

@ -237,7 +237,7 @@ int replace(BufferView * bv, docstring const & searchstr,
cap::replaceSelectionWithString(cur, replacestr, fw);
bv->buffer().markDirty();
find(bv, searchstr, cs, mw, fw, false);
bv->update();
bv->processUpdateFlags(Update::Force | Update::FitCursor);
return 1;
}