mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Adding the capability to paste as simple unformatted text.
Documentation (and perhaps menu items) need still to be a bit clarified in order to distinguish the various paste options for the average user. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40060 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
37c4b71a3e
commit
824d640227
@ -157,6 +157,9 @@ Menuset
|
|||||||
Item "Selection|S" "primary-selection-paste"
|
Item "Selection|S" "primary-selection-paste"
|
||||||
Item "Selection, Join Lines|i" "primary-selection-paste paragraph"
|
Item "Selection, Join Lines|i" "primary-selection-paste paragraph"
|
||||||
Separator
|
Separator
|
||||||
|
Item "Unformatted Text|U" "clipboard-paste-simple"
|
||||||
|
Item "Unformatted, Join Lines|o" "clipboard-paste-simple paragraph"
|
||||||
|
Separator
|
||||||
Item "Paste as LinkBack PDF" "paste linkback"
|
Item "Paste as LinkBack PDF" "paste linkback"
|
||||||
Item "Paste as PDF" "paste pdf"
|
Item "Paste as PDF" "paste pdf"
|
||||||
Item "Paste as PNG" "paste png"
|
Item "Paste as PNG" "paste png"
|
||||||
|
@ -1049,6 +1049,39 @@ void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void pasteSimpleText(Cursor & cur, bool asParagraphs)
|
||||||
|
{
|
||||||
|
docstring text;
|
||||||
|
// Use internal clipboard if it is the most recent one
|
||||||
|
if (theClipboard().isInternal()) {
|
||||||
|
if (!checkPastePossible(0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ParagraphList const & pars = theCuts[0].first;
|
||||||
|
ParagraphList::const_iterator it = pars.begin();
|
||||||
|
for (; it != pars.end(); ++it) {
|
||||||
|
if (it != pars.begin())
|
||||||
|
text += "\n";
|
||||||
|
text += (*it).asString();
|
||||||
|
}
|
||||||
|
asParagraphs = false;
|
||||||
|
} else {
|
||||||
|
// Then try plain text
|
||||||
|
text = theClipboard().getAsText();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
cur.recordUndo();
|
||||||
|
cutSelection(cur, true, false);
|
||||||
|
if (asParagraphs)
|
||||||
|
cur.text()->insertStringAsParagraphs(cur, text, cur.current_font);
|
||||||
|
else
|
||||||
|
cur.text()->insertStringAsLines(cur, text, cur.current_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */,
|
void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */,
|
||||||
Clipboard::GraphicsType preferedType)
|
Clipboard::GraphicsType preferedType)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,8 @@ void pasteClipboardGraphics(Cursor & cur, ErrorList & errorList,
|
|||||||
/// Replace the current selection with cut buffer \c sel_index
|
/// Replace the current selection with cut buffer \c sel_index
|
||||||
/// Does handle undo. Does only work in text, not mathed.
|
/// Does handle undo. Does only work in text, not mathed.
|
||||||
void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
|
void pasteFromStack(Cursor & cur, ErrorList & errorList, size_t sel_index);
|
||||||
|
/// Paste the clipboard as simple text, removing any formatting
|
||||||
|
void pasteSimpleText(Cursor & cur, bool asParagraphs);
|
||||||
|
|
||||||
/// Paste the paragraph list \p parlist at the position given by \p cur.
|
/// Paste the paragraph list \p parlist at the position given by \p cur.
|
||||||
/// Does not handle undo. Does only work in text, not mathed.
|
/// Does not handle undo. Does only work in text, not mathed.
|
||||||
|
@ -448,9 +448,10 @@ enum FuncCode
|
|||||||
LFUN_PREVIEW_INSERT, // vfr, 20100328
|
LFUN_PREVIEW_INSERT, // vfr, 20100328
|
||||||
LFUN_FORWARD_SEARCH,
|
LFUN_FORWARD_SEARCH,
|
||||||
LFUN_SCRIPT_INSERT, // gb, 20101123
|
LFUN_SCRIPT_INSERT, // gb, 20101123
|
||||||
// 350
|
|
||||||
|
|
||||||
LFUN_BUFFER_EXPORT_AS, // tommaso 20111006
|
LFUN_BUFFER_EXPORT_AS, // tommaso 20111006
|
||||||
|
// 350
|
||||||
|
LFUN_CLIPBOARD_PASTE_SIMPLE, // tommaso, 20111028
|
||||||
|
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1209,6 +1209,14 @@ void LyXAction::init()
|
|||||||
* \endvar
|
* \endvar
|
||||||
*/
|
*/
|
||||||
{ LFUN_SELECTION_PASTE, "selection-paste", Noop, Edit },
|
{ LFUN_SELECTION_PASTE, "selection-paste", Noop, Edit },
|
||||||
|
/*!
|
||||||
|
* \var lyx::FuncCode lyx::LFUN_CLIPBOARD_PASTE_SIMPLE
|
||||||
|
* \li Action: Pastes simple unformatted text from the active clipboard.
|
||||||
|
* \li Syntax: clipboard-paste-simple [<ARG>]
|
||||||
|
* \li Params: <ARG>: "paragraph" will cause pasting as one paragraph, i.e. "Join lines".
|
||||||
|
* \endvar
|
||||||
|
*/
|
||||||
|
{ LFUN_CLIPBOARD_PASTE_SIMPLE, "clipboard-paste-simple", Noop, Edit },
|
||||||
/*!
|
/*!
|
||||||
* \var lyx::FuncCode lyx::LFUN_UNDO
|
* \var lyx::FuncCode lyx::LFUN_UNDO
|
||||||
* \li Action: Undoes the last edit.
|
* \li Action: Undoes the last edit.
|
||||||
|
@ -93,6 +93,7 @@ using cap::pasteClipboardGraphics;
|
|||||||
using cap::replaceSelection;
|
using cap::replaceSelection;
|
||||||
using cap::grabAndEraseSelection;
|
using cap::grabAndEraseSelection;
|
||||||
using cap::selClearOrDel;
|
using cap::selClearOrDel;
|
||||||
|
using cap::pasteSimpleText;
|
||||||
|
|
||||||
// globals...
|
// globals...
|
||||||
static Font freefont(ignore_font, ignore_language);
|
static Font freefont(ignore_font, ignore_language);
|
||||||
@ -1318,6 +1319,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
bv->buffer().errors("Paste");
|
bv->buffer().errors("Paste");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_CLIPBOARD_PASTE_SIMPLE:
|
||||||
|
cur.clearSelection();
|
||||||
|
pasteSimpleText(cur, cmd.argument() == "paragraph");
|
||||||
|
break;
|
||||||
|
|
||||||
case LFUN_PRIMARY_SELECTION_PASTE:
|
case LFUN_PRIMARY_SELECTION_PASTE:
|
||||||
pasteString(cur, theSelection().get(),
|
pasteString(cur, theSelection().get(),
|
||||||
cmd.argument() == "paragraph");
|
cmd.argument() == "paragraph");
|
||||||
@ -2583,6 +2589,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_CLIPBOARD_PASTE:
|
case LFUN_CLIPBOARD_PASTE:
|
||||||
|
case LFUN_CLIPBOARD_PASTE_SIMPLE:
|
||||||
enable = !theClipboard().empty();
|
enable = !theClipboard().empty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user