mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Factorise external pasting code.
* LyXText::pasteString(): new private method. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16475 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
04afd7af17
commit
61f7ebd4a9
@ -386,6 +386,12 @@ private:
|
||||
void charInserted();
|
||||
/// set 'number' font property
|
||||
void number(LCursor & cur);
|
||||
|
||||
/// paste string at current cursor.
|
||||
/// \param str string to paste
|
||||
/// \param argument method for parsing ("paragraph" is special)
|
||||
void pasteString(LCursor & cur, docstring const & str,
|
||||
docstring const & argument);
|
||||
};
|
||||
|
||||
} // namespace lyx
|
||||
|
39
src/text3.C
39
src/text3.C
@ -860,31 +860,13 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_CLIPBOARD_PASTE: {
|
||||
cur.clearSelection();
|
||||
docstring const clip = theClipboard().get();
|
||||
if (!clip.empty()) {
|
||||
recordUndo(cur);
|
||||
if (cmd.argument() == "paragraph")
|
||||
insertStringAsParagraphs(cur, clip);
|
||||
else
|
||||
insertStringAsLines(cur, clip);
|
||||
}
|
||||
case LFUN_CLIPBOARD_PASTE:
|
||||
pasteString(cur, theClipboard().get(), cmd.argument());
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_PRIMARY_SELECTION_PASTE: {
|
||||
cur.clearSelection();
|
||||
docstring const clip = theSelection().get();
|
||||
if (!clip.empty()) {
|
||||
recordUndo(cur);
|
||||
if (cmd.argument() == "paragraph")
|
||||
insertStringAsParagraphs(cur, clip);
|
||||
else
|
||||
insertStringAsLines(cur, clip);
|
||||
}
|
||||
case LFUN_PRIMARY_SELECTION_PASTE:
|
||||
pasteString(cur, theSelection().get(), cmd.argument());
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_UNICODE_INSERT: {
|
||||
if (cmd.argument().empty())
|
||||
@ -1879,4 +1861,17 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void LyXText::pasteString(LCursor & cur, docstring const & clip,
|
||||
docstring const & argument)
|
||||
{
|
||||
cur.clearSelection();
|
||||
if (!clip.empty()) {
|
||||
recordUndo(cur);
|
||||
if (argument == "paragraph")
|
||||
insertStringAsParagraphs(cur, clip);
|
||||
else
|
||||
insertStringAsLines(cur, clip);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
Loading…
Reference in New Issue
Block a user