mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
New lfun to copy index insets from ToC
The new function inset-insert-copy can only be invoked from the ToC. It is currently only implemented for Index inset. It is a special lfun because Inset::dispatch is called directly from the ToC widget with cursor pointing to the inset, whereas the patch happens in the workarea at caret position. This function cannot be called directly. Add an entry for this function in the toc context menu. Fixes bug #4582.
This commit is contained in:
parent
d2f05b9e6f
commit
fad170be1a
@ -621,6 +621,8 @@ Menuset
|
||||
#
|
||||
|
||||
Menu "context-toc-index"
|
||||
OptItem "Insert Copy at Cursor Position|I" "inset-insert-copy"
|
||||
Separator
|
||||
OptItem "Settings...|S" "inset-settings"
|
||||
End
|
||||
|
||||
|
@ -502,6 +502,7 @@ enum FuncCode
|
||||
LFUN_SPELLING_REMOVE_LOCAL, // jspitzm 20210307
|
||||
LFUN_BRANCH_SYNC_ALL, // sanda 20220415
|
||||
LFUN_INDEXMACRO_INSERT, // spitz 20220220
|
||||
LFUN_INSET_INSERT_COPY, // spitz 20221101
|
||||
LFUN_LASTACTION // end of the table
|
||||
};
|
||||
|
||||
|
@ -2070,6 +2070,14 @@ void LyXAction::init()
|
||||
*/
|
||||
{ LFUN_INSET_COPY_AS, "inset-copy-as", ReadOnly | NoUpdate | AtPoint, Edit },
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_INSET_INSERT_COPY
|
||||
* \li Action: Inserts the inset's content (in ToC pane) at the position of the cursor.
|
||||
* \li Syntax: inset-insert-copy
|
||||
* \li Origin: spitz, 1 Nov 2022
|
||||
* \endvar
|
||||
*/
|
||||
{ LFUN_INSET_INSERT_COPY, "inset-insert-copy", Noop, Edit},
|
||||
|
||||
/*!
|
||||
* \var lyx::FuncCode lyx::LFUN_INSET_DIALOG_UPDATE
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "BufferView.h"
|
||||
#include "ColorSet.h"
|
||||
#include "Cursor.h"
|
||||
#include "CutAndPaste.h"
|
||||
#include "DispatchResult.h"
|
||||
#include "Encoding.h"
|
||||
#include "ErrorList.h"
|
||||
@ -621,6 +622,16 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_INSET_INSERT_COPY: {
|
||||
Cursor & bvcur = cur.bv().cursor();
|
||||
if (cmd.origin() == FuncRequest::TOC && bvcur.inTexted()) {
|
||||
cap::copyInsetToTemp(cur, clone());
|
||||
cap::pasteFromTemp(bvcur, bvcur.buffer()->errorList("Paste"));
|
||||
} else
|
||||
cur.undispatched();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
InsetCollapsible::doDispatch(cur, cmd);
|
||||
break;
|
||||
@ -668,10 +679,16 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
flag.setEnabled(realbuffer.params().use_indices);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
case LFUN_INSET_INSERT_COPY:
|
||||
// This can only be invoked by ToC widget
|
||||
flag.setEnabled(cmd.origin() == FuncRequest::TOC
|
||||
&& cur.bv().cursor().inset().insetAllowed(lyxCode()));
|
||||
return true;
|
||||
|
||||
case LFUN_PARAGRAPH_BREAK:
|
||||
return macrosPossible("subentry");
|
||||
|
||||
|
||||
case LFUN_INDEXMACRO_INSERT:
|
||||
return macrosPossible(cmd.getArg(0));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user