Introduce new function copyInsetToTemp

This is a version of copyInset that does touch the cut stack and the X
selection.

Part of bug #4582.
This commit is contained in:
Jean-Marc Lasgouttes 2022-11-04 21:44:24 +01:00
parent 2c53f0315e
commit 0b27eb7deb
2 changed files with 21 additions and 2 deletions

View File

@ -1037,7 +1037,9 @@ void copySelection(Cursor const & cur)
}
void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext)
namespace {
void copyInsetToStack(Cursor const & cur, CutStack & cutstack, Inset * inset)
{
ParagraphList pars;
Paragraph par;
@ -1046,13 +1048,28 @@ void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext)
Font font(inherit_font, bp.language);
par.insertInset(0, inset, font, Change(Change::UNCHANGED));
pars.push_back(par);
theCuts.push(make_pair(pars, make_pair(bp.documentClassPtr(), bp.authors())));
cutstack.push(make_pair(pars, make_pair(bp.documentClassPtr(), bp.authors())));
}
}
void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext)
{
copyInsetToStack(cur, theCuts, inset);
// stuff the selection onto the X clipboard, from an explicit copy request
BufferParams const & bp = cur.buffer()->params();
putClipboard(theCuts[0].first, theCuts[0].second, plaintext, bp);
}
void copyInsetToTemp(Cursor const & cur, Inset * inset)
{
copyInsetToStack(cur, tempCut, inset);
}
namespace {
void copySelectionToStack(CursorData const & cur, CutStack & cutstack)

View File

@ -79,6 +79,8 @@ void copySelection(Cursor const & cur);
void copySelectionToTemp(Cursor const & cur);
///
void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext);
///
void copyInsetToTemp(Cursor const & cur, Inset * inset);
/**
* Push the current selection to the cut buffer and the system clipboard.
* \param plaintext plain text version of the selection for the system