mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Implement master-buffer-forall
Similar to buffer-forall with the notable exception that its scope is limited to the files of a project (master and all children)
This commit is contained in:
parent
0e6a7aa85a
commit
69792bbaa5
@ -69,6 +69,8 @@
|
||||
|
||||
* export-cancel: Used to cancel background export processes.
|
||||
|
||||
* master-buffer-forall executes an lfun in the master and all children of a document.
|
||||
|
||||
* paragraph-select is a new convenience function to select the paragraph
|
||||
surrounding the actual cursor position.
|
||||
|
||||
|
@ -488,6 +488,7 @@ enum FuncCode
|
||||
LFUN_BIDI,
|
||||
// 380
|
||||
LFUN_BUFFER_RESET_EXPORT, // spitz 20191226
|
||||
LFUN_MASTER_BUFFER_FORALL, // spitz 20191231
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
||||
|
@ -2588,6 +2588,26 @@ void LyXAction::init()
|
||||
*/
|
||||
{ LFUN_MASTER_BUFFER_EXPORT, "master-buffer-export", ReadOnly, Buffer },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_MASTER_BUFFER_FORALL
|
||||
* \li Action: Applies a command to a buffer and all it children, starting from the master.
|
||||
* \li Syntax: master-buffer-forall <LFUN-COMMAND>
|
||||
* \li Params: <LFUN-COMMAND>: The command to be applied to the buffers.
|
||||
* \li Sample: Close all Notes in buffers: \n
|
||||
master-buffer-forall inset-forall Note inset-toggle close \n
|
||||
Toggle change tracking on buffers: \n
|
||||
master-buffer-forall changes-track \n
|
||||
Toggle read-only for buffers: \n
|
||||
master-buffer-forall buffer-toggle-read-only \n
|
||||
Show statistics for individual buffers: \n
|
||||
master-buffer-forall statistics \n
|
||||
Activate the branch named "Solutions" in buffers: \n
|
||||
master-buffer-forall branch-activate Solutions \n
|
||||
* \li Origin: spitz, 31 Dec 2019
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_MASTER_BUFFER_FORALL, "master-buffer-forall", ReadOnly | Argument, Buffer },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_MASTER_BUFFER_UPDATE
|
||||
* \li Action: Update (export) the document built from the master buffer,
|
||||
|
@ -1967,6 +1967,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
||||
enable = doc_buffer != 0;
|
||||
break;
|
||||
|
||||
case LFUN_MASTER_BUFFER_FORALL:
|
||||
enable = doc_buffer != 0;
|
||||
break;
|
||||
|
||||
case LFUN_BUFFER_WRITE:
|
||||
enable = doc_buffer && (doc_buffer->isUnnamed() || !doc_buffer->isClean());
|
||||
break;
|
||||
@ -4179,6 +4183,25 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MASTER_BUFFER_FORALL: {
|
||||
if (!doc_buffer)
|
||||
break;
|
||||
|
||||
FuncRequest funcToRun = lyxaction.lookupFunc(cmd.getLongArg(0));
|
||||
funcToRun.allowAsync(false);
|
||||
|
||||
for (Buffer const * buf : doc_buffer->allRelatives()) {
|
||||
// Switch to other buffer view and resend cmd
|
||||
lyx::dispatch(FuncRequest(
|
||||
LFUN_BUFFER_SWITCH, buf->absFileName()));
|
||||
lyx::dispatch(funcToRun);
|
||||
}
|
||||
// switch back
|
||||
lyx::dispatch(FuncRequest(
|
||||
LFUN_BUFFER_SWITCH, doc_buffer->absFileName()));
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_BUFFER_EXTERNAL_MODIFICATION_CLEAR:
|
||||
LASSERT(doc_buffer, break);
|
||||
doc_buffer->clearExternalModification();
|
||||
|
Loading…
Reference in New Issue
Block a user