int new_id = cur.paragraph().id();
// if bottom_pit, bottom_pos or top_id has been changed, update bookmark
- // see http://bugzilla.lyx.org/show_bug.cgi?id=3092
+ // see http://www.lyx.org/trac/ticket/3092
if (bm.bottom_pit != new_pit || bm.bottom_pos != new_pos
|| bm.top_id != new_id) {
const_cast<BookmarksSection::Bookmark &>(bm).updatePos(
case LFUN_REPEAT:
case LFUN_PREFERENCES_SAVE:
case LFUN_BUFFER_SAVE_AS_DEFAULT:
+ case LFUN_DEBUG_LEVEL_SET:
// these are handled in our dispatch()
break;
void LyXFunc::dispatch(FuncRequest const & cmd)
+{
+ DispatchResult dr;
+ // redraw the screen at the end (first of the two drawing steps).
+ //This is done unless explicitely requested otherwise
+ dr.update(Update::FitCursor);
+ dispatch(cmd, dr);
+
+ LyXView * lv = theApp()->currentWindow();
+ if (lv && lv->currentBufferView()) {
+ // BufferView::update() updates the ViewMetricsInfo and
+ // also initializes the position cache for all insets in
+ // (at least partially) visible top-level paragraphs.
+ // We will redraw the screen only if needed.
+ lv->currentBufferView()->processUpdateFlags(dr.update());
+
+ // Do we have a selection?
+ theSelection().haveSelection(
+ lv->currentBufferView()->cursor().selection());
+
+ // update gui
+ lv->restartCursor();
+ }
+}
+
+
+void LyXFunc::dispatch(FuncRequest const & cmd, DispatchResult & dr)
{
string const argument = to_utf8(cmd.argument());
FuncCode const action = cmd.action;
errorstat = false;
dispatch_buffer.erase();
- // redraw the screen at the end (first of the two drawing steps).
- //This is done unless explicitely requested otherwise
- Update::flags updateFlags = Update::FitCursor;
-
LyXView * lv = theApp()->currentWindow();
FuncStatus const flag = getStatus(cmd);
LYXERR(Debug::ACTION, "LyXFunc::dispatch: "
<< lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location");
+ //FIXME: pass this using the DispatchResult object
setErrorMessage(flag.message());
if (lv)
lv->restartCursor();
+ dr.dispatched(false);
+ dr.update(Update::None);
} else {
switch (action) {
case LFUN_BOOKMARK_GOTO:
// go to bookmark, open unopened file and switch to buffer if necessary
gotoBookmark(convert<unsigned int>(to_utf8(cmd.argument())), true, true);
- updateFlags = Update::FitCursor;
+ dr.update(Update::FitCursor);
break;
case LFUN_BOOKMARK_CLEAR:
theSession().bookmarks().clear();
break;
- default:
- DispatchResult dr;
+ case LFUN_DEBUG_LEVEL_SET:
+ lyxerr.setLevel(Debug::value(to_utf8(cmd.argument())));
+ break;
+ default:
LASSERT(theApp(), /**/);
// Let the frontend dispatch its own actions.
theApp()->dispatch(cmd, dr);
break;
// Let the current LyXView dispatch its own actions.
+ //FIXME: pass dr to LyXView::dispatch
if (lv->dispatch(cmd)) {
BufferView * bv = lv->currentBufferView();
if (bv)
- updateFlags = bv->cursor().result().update();
+ dr = bv->cursor().result();
break;
}
LASSERT(bv, /**/);
// Let the current BufferView dispatch its own actions.
- if (bv->dispatch(cmd)) {
- // The BufferView took care of its own updates if needed.
- updateFlags = Update::None;
+ bv->dispatch(cmd, dr);
+ if (dr.dispatched())
break;
- }
BufferView * doc_bv = lv->documentBufferView();
// Try with the document BufferView dispatch if any.
- if (doc_bv && doc_bv->dispatch(cmd)) {
- updateFlags = Update::None;
- break;
+ if (doc_bv) {
+ doc_bv->dispatch(cmd, dr);
+ if (dr.dispatched())
+ break;
}
// OK, so try the current Buffer itself...
bv->buffer().dispatch(cmd, dr);
- if (dr.dispatched()) {
- updateFlags = dr.update();
+ if (dr.dispatched())
break;
- }
+
// and with the document Buffer.
if (doc_bv) {
doc_bv->buffer().dispatch(cmd, dr);
- if (dr.dispatched()) {
- updateFlags = dr.update();
+ if (dr.dispatched())
break;
- }
- }
-
- // Is this a function that acts on inset at point?
- Inset * inset = bv->cursor().nextInset();
- if (lyxaction.funcHasFlag(action, LyXAction::AtPoint)
- && inset) {
- bv->cursor().result().dispatched(true);
- bv->cursor().result().update(Update::FitCursor | Update::Force);
- FuncRequest tmpcmd = cmd;
- inset->dispatch(bv->cursor(), tmpcmd);
- if (bv->cursor().result().dispatched()) {
- updateFlags = bv->cursor().result().update();
- break;
- }
}
// Let the current Cursor dispatch its own actions.
lv->updateCompletion(bv->cursor(), false, false);
}
- updateFlags = bv->cursor().result().update();
+ dr = bv->cursor().result();
}
// if we executed a mutating lfun, mark the buffer as dirty
&& flag.enabled()
&& !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
&& !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
- doc_buffer->markDirty();
-
- if (lv && lv->currentBufferView()) {
- // BufferView::update() updates the ViewMetricsInfo and
- // also initializes the position cache for all insets in
- // (at least partially) visible top-level paragraphs.
- // We will redraw the screen only if needed.
- lv->currentBufferView()->processUpdateFlags(updateFlags);
-
- // Do we have a selection?
- theSelection().haveSelection(
- lv->currentBufferView()->cursor().selection());
-
- // update gui
- lv->restartCursor();
- }
+ lv->currentBufferView()->buffer().markDirty();
}
if (lv) {
// Some messages may already be translated, so we cannot use _()