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.
#
Menu "context-toc-index"
+ OptItem "Insert Copy at Cursor Position|I" "inset-insert-copy"
+ Separator
OptItem "Settings...|S" "inset-settings"
End
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
};
*/
{ 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
#include "BufferView.h"
#include "ColorSet.h"
#include "Cursor.h"
+#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "Encoding.h"
#include "ErrorList.h"
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;
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));