mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
LyXFunc::dispatch(): don't use a buffer pointer set at the beginning of the method as this one could change depending of the LFUN. Instead get the proper Buffer in all cases.
The side effect of this patch is that the undo/redo action are properly recorded only for document Buffers. But as this was a mess already with embedded work area. We might try to properly implement undo/redo for embedded work area later. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31471 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
16c5138508
commit
dffe3ee218
@ -527,9 +527,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
if (lv)
|
if (lv)
|
||||||
lv->restartCursor();
|
lv->restartCursor();
|
||||||
} else {
|
} else {
|
||||||
Buffer * buffer = 0;
|
|
||||||
if (lv && lv->currentBufferView())
|
|
||||||
buffer = &lv->currentBufferView()->buffer();
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
||||||
case LFUN_COMMAND_PREFIX:
|
case LFUN_COMMAND_PREFIX:
|
||||||
@ -539,7 +536,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_CANCEL:
|
case LFUN_CANCEL:
|
||||||
keyseq.reset();
|
keyseq.reset();
|
||||||
meta_fake_bit = NoModifier;
|
meta_fake_bit = NoModifier;
|
||||||
if (buffer)
|
if (lv && lv->currentBufferView())
|
||||||
// cancel any selection
|
// cancel any selection
|
||||||
dispatch(FuncRequest(LFUN_MARK_OFF));
|
dispatch(FuncRequest(LFUN_MARK_OFF));
|
||||||
setMessage(from_ascii(N_("Cancel")));
|
setMessage(from_ascii(N_("Cancel")));
|
||||||
@ -557,13 +554,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// --- lyxserver commands ----------------------------
|
// --- lyxserver commands ----------------------------
|
||||||
case LFUN_SERVER_GET_FILENAME:
|
case LFUN_SERVER_GET_FILENAME: {
|
||||||
LASSERT(lv && buffer, /**/);
|
LASSERT(lv && lv->documentBufferView(), return);
|
||||||
setMessage(from_utf8(buffer->absFileName()));
|
docstring const fname = from_utf8(
|
||||||
LYXERR(Debug::INFO, "FNAME["
|
lv->documentBufferView()->buffer().absFileName());
|
||||||
<< buffer->absFileName() << ']');
|
setMessage(fname);
|
||||||
|
LYXERR(Debug::INFO, "FNAME[" << fname << ']');
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case LFUN_SERVER_NOTIFY:
|
case LFUN_SERVER_NOTIFY:
|
||||||
dispatch_buffer = keyseq.print(KeySequence::Portable);
|
dispatch_buffer = keyseq.print(KeySequence::Portable);
|
||||||
theServer().notifyClient(to_utf8(dispatch_buffer));
|
theServer().notifyClient(to_utf8(dispatch_buffer));
|
||||||
@ -589,7 +587,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
case LFUN_COMMAND_SEQUENCE: {
|
case LFUN_COMMAND_SEQUENCE: {
|
||||||
// argument contains ';'-terminated commands
|
// argument contains ';'-terminated commands
|
||||||
string arg = argument;
|
string arg = argument;
|
||||||
if (theBufferList().isLoaded(buffer))
|
// FIXME: this LFUN should also work without any view.
|
||||||
|
Buffer * buffer = (lv && lv->documentBufferView())
|
||||||
|
? &(lv->documentBufferView()->buffer()) : 0;
|
||||||
|
buffer = &lv->currentBufferView()->buffer();
|
||||||
|
if (buffer && !theBufferList().isLoaded(buffer))
|
||||||
|
buffer = 0;
|
||||||
|
if (buffer)
|
||||||
buffer->undo().beginUndoGroup();
|
buffer->undo().beginUndoGroup();
|
||||||
while (!arg.empty()) {
|
while (!arg.empty()) {
|
||||||
string first;
|
string first;
|
||||||
@ -598,7 +602,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
func.origin = cmd.origin;
|
func.origin = cmd.origin;
|
||||||
dispatch(func);
|
dispatch(func);
|
||||||
}
|
}
|
||||||
if (theBufferList().isLoaded(buffer))
|
if (buffer)
|
||||||
buffer->undo().endUndoGroup();
|
buffer->undo().endUndoGroup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -726,18 +730,22 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
if (lv == 0)
|
if (lv == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Buffer * doc_buffer = (lv && lv->documentBufferView())
|
||||||
|
? &(lv->documentBufferView()->buffer()) : 0;
|
||||||
|
if (doc_buffer && !theBufferList().isLoaded(doc_buffer))
|
||||||
|
doc_buffer = 0;
|
||||||
// Start an undo group. This may be needed for
|
// Start an undo group. This may be needed for
|
||||||
// some stuff like inset-apply on labels.
|
// some stuff like inset-apply on labels.
|
||||||
if (theBufferList().isLoaded(buffer))
|
if (doc_buffer)
|
||||||
buffer->undo().beginUndoGroup();
|
doc_buffer->undo().beginUndoGroup();
|
||||||
|
|
||||||
// Let the current LyXView dispatch its own actions.
|
// Let the current LyXView dispatch its own actions.
|
||||||
if (lv->dispatch(cmd)) {
|
if (lv->dispatch(cmd)) {
|
||||||
BufferView * bv = lv->currentBufferView();
|
BufferView * bv = lv->currentBufferView();
|
||||||
if (bv) {
|
if (bv) {
|
||||||
buffer = &(bv->buffer());
|
Buffer * buffer = &(bv->buffer());
|
||||||
updateFlags = bv->cursor().result().update();
|
updateFlags = bv->cursor().result().update();
|
||||||
if (theBufferList().isLoaded(buffer))
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
||||||
buffer->undo().endUndoGroup();
|
buffer->undo().endUndoGroup();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -749,9 +757,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
// Let the current BufferView dispatch its own actions.
|
// Let the current BufferView dispatch its own actions.
|
||||||
if (bv->dispatch(cmd)) {
|
if (bv->dispatch(cmd)) {
|
||||||
// The BufferView took care of its own updates if needed.
|
// The BufferView took care of its own updates if needed.
|
||||||
buffer = &(bv->buffer());
|
Buffer * buffer = &(bv->buffer());
|
||||||
updateFlags = Update::None;
|
updateFlags = Update::None;
|
||||||
if (theBufferList().isLoaded(buffer))
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
||||||
buffer->undo().endUndoGroup();
|
buffer->undo().endUndoGroup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -760,9 +768,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
// Try with the document BufferView dispatch if any.
|
// Try with the document BufferView dispatch if any.
|
||||||
if (doc_bv && doc_bv->dispatch(cmd)) {
|
if (doc_bv && doc_bv->dispatch(cmd)) {
|
||||||
// The BufferView took care of its own updates if needed.
|
// The BufferView took care of its own updates if needed.
|
||||||
buffer = &(doc_bv->buffer());
|
Buffer * buffer = &(doc_bv->buffer());
|
||||||
updateFlags = Update::None;
|
updateFlags = Update::None;
|
||||||
if (theBufferList().isLoaded(buffer))
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
||||||
buffer->undo().endUndoGroup();
|
buffer->undo().endUndoGroup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -810,8 +818,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
if (badcursor)
|
if (badcursor)
|
||||||
bv->cursor().fixIfBroken();
|
bv->cursor().fixIfBroken();
|
||||||
}
|
}
|
||||||
|
Buffer * buffer = &(bv->buffer());
|
||||||
if (theBufferList().isLoaded(buffer))
|
if (buffer == doc_buffer && theBufferList().isLoaded(buffer))
|
||||||
buffer->undo().endUndoGroup();
|
buffer->undo().endUndoGroup();
|
||||||
|
|
||||||
// update completion. We do it here and not in
|
// update completion. We do it here and not in
|
||||||
@ -831,10 +839,13 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we executed a mutating lfun, mark the buffer as dirty
|
// if we executed a mutating lfun, mark the buffer as dirty
|
||||||
if (theBufferList().isLoaded(buffer) && flag.enabled()
|
Buffer * doc_buffer = (lv && lv->documentBufferView())
|
||||||
|
? &(lv->documentBufferView()->buffer()) : 0;
|
||||||
|
if (doc_buffer && theBufferList().isLoaded(doc_buffer)
|
||||||
|
&& flag.enabled()
|
||||||
&& !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
|
&& !lyxaction.funcHasFlag(action, LyXAction::NoBuffer)
|
||||||
&& !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
|
&& !lyxaction.funcHasFlag(action, LyXAction::ReadOnly))
|
||||||
buffer->markDirty();
|
doc_buffer->markDirty();
|
||||||
|
|
||||||
if (lv && lv->currentBufferView()) {
|
if (lv && lv->currentBufferView()) {
|
||||||
// BufferView::update() updates the ViewMetricsInfo and
|
// BufferView::update() updates the ViewMetricsInfo and
|
||||||
|
Loading…
Reference in New Issue
Block a user