Add pref to keep ct markup on copy/paste

Fixes #10278, #10128
This commit is contained in:
Juergen Spitzmueller 2020-01-13 15:20:48 +01:00
parent 1baa8cdc93
commit 5fc2662b13
10 changed files with 150 additions and 55 deletions

View File

@ -35,6 +35,9 @@
* \ct_additions_underlined true|false: determines whether additions in change tracking
are underlined in the workarea (default: true).
* \ct_markup_copied true|false: determines whether change tracking markup should be
preserved on copy/paste (default: false).
!!!The following pref variables were changed in 2.4:

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 591
\lyxformat 592
\begin_document
\begin_header
\save_transient_properties true
@ -8485,14 +8485,12 @@ Verbatim
\end_layout
\begin_layout Verbatim
This is Verbatim.
\end_layout
\begin_layout Verbatim
\noindent
\align block
The following 2 lines are empty:
\end_layout
@ -8505,7 +8503,6 @@ The following 2 lines are empty:
\end_layout
\begin_layout Verbatim
Almost everything is allowed in Verbatim:"%&$§#~'`
\backslash
}][{|
@ -8529,7 +8526,6 @@ Verbatim
\end_layout
\begin_layout Verbatim*
This is Verbatim*.
\end_layout
@ -48920,6 +48916,29 @@ Ctrl+arrow key
\family default
the cursor jumps from the end of a word to the end of the next word.
Normally it jumps from the beginning to the beginning.
\change_inserted -712698321 1578924606
\end_layout
\begin_layout Standard
\change_inserted -712698321 1578924785
The option
\family sans
Keep change tracking markup on copy and paste
\family default
is for users who don't want tracked changes to be dissolved on copy and
paste operations (i.
\begin_inset space \thinspace{}
\end_inset
e., inserted as new text with the deletions removed).
If this is checked, the change-tracked text will be copied and pasted as
is, independent if changes are currently tracked or not.
This also applies to wrapping to\SpecialChar breakableslash
dissolving from insets.
\change_unchanged
\end_layout
\begin_layout Standard

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 591
\lyxformat 592
\begin_document
\begin_header
\save_transient_properties true
@ -8638,10 +8638,12 @@ Unformatiert
\end_layout
\begin_layout Verbatim
Dies ist Unformatiert.
\end_layout
\begin_layout Verbatim
Die folgenden 2 Zeilen sind leer:
\end_layout
@ -8654,6 +8656,7 @@ Die folgenden 2 Zeilen sind leer:
\end_layout
\begin_layout Verbatim
Fast alles ist in Unformatiert erlaubt:"%&$§#~'`
\backslash
}][{|
@ -8677,6 +8680,7 @@ Unformatiert
\end_layout
\begin_layout Verbatim*
Dies ist Unformatiert*.
\end_layout
@ -46114,6 +46118,24 @@ Cursornavigation zwischen Wörtern im Mac-Stil
Normalerweise springt er von Anfang zu Anfang.
\end_layout
\begin_layout Standard
Die Option
\family sans
Änderungsmarkierungen beim Kopieren und Einfügen behalten
\family default
können Sie auswählen, wenn Sie nicht möchten, dass verfolgte Änderungen
beim Kopieren und Einfügen aufgelöst werden (d.
\begin_inset space \thinspace{}
\end_inset
h., dass als gelöscht markierter Text entfernt und alles andere als neu eingefügt
wird).
Wenn dies ausgewählt ist, wird der kopierte Text mit den Markierungen eingefügt
, unabhängig davon, ob Änderungen gerade verfolgt werden oder nicht.
Das betrifft auch das Umwandeln von Text in\SpecialChar breakableslash
von Einfügungen.
\end_layout
\begin_layout Standard
Die Option
\family sans

View File

@ -125,6 +125,10 @@
# Add ct_additions_underlined.
# No convergence necessary.
# Incremented to format 32, by spitz
# Add ct_markup_copied.
# No convergence necessary.
# NOTE: The format should also be updated in LYXRC.cpp and
# in configure.py.
@ -474,5 +478,6 @@ conversions = [
[ 28, [remove_date_insert_format]],
[ 29, [remove_use_pixmap_cache]],
[ 30, []],
[ 31, []]
[ 31, []],
[ 32, []]
]

View File

@ -287,8 +287,9 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
tmpbuf->eraseChar(i--, false);
}
tmpbuf->setChange(Change(buffer.params().track_changes ?
Change::INSERTED : Change::UNCHANGED));
if (lyxrc.ct_markup_copied)
tmpbuf->setChange(Change(buffer.params().track_changes ?
Change::INSERTED : Change::UNCHANGED));
}
bool const empty = pars[pit].empty();
@ -606,7 +607,8 @@ Buffer * copyToTempBuffer(ParagraphList const & paragraphs, DocumentClassConstPt
void putClipboard(ParagraphList const & paragraphs,
DocumentClassConstPtr docclass, docstring const & plaintext)
DocumentClassConstPtr docclass, docstring const & plaintext,
BufferParams const bp)
{
Buffer * buffer = copyToTempBuffer(paragraphs, docclass);
if (!buffer) // already asserted in copyToTempBuffer()
@ -617,6 +619,12 @@ void putClipboard(ParagraphList const & paragraphs,
// applications, the number that can parse it should go up in the future.
buffer->params().html_math_output = BufferParams::MathML;
if (lyxrc.ct_markup_copied) {
// Copy authors to the params. We need those pointers.
for (Author const & a : bp.authors())
buffer->params().authors().record(a);
}
// Make sure MarkAsExporting is deleted before buffer is
{
// The Buffer is being used to export. This is necessary so that the
@ -711,10 +719,12 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
// do not copy text (also nested in insets) which is marked as
// deleted, unless the whole selection was deleted
if (!isFullyDeleted(copy_pars))
acceptChanges(copy_pars, buf.params());
else
rejectChanges(copy_pars, buf.params());
if (!lyxrc.ct_markup_copied) {
if (!isFullyDeleted(copy_pars))
acceptChanges(copy_pars, buf.params());
else
rejectChanges(copy_pars, buf.params());
}
// do some final cleanup now, to make sure that the paragraphs
@ -950,7 +960,7 @@ void cutSelectionHelper(Cursor & cur, CutStack & cuts, bool realcut, bool putcli
// Even if there is no selection.
if (putclip)
putClipboard(cuts[0].first, cuts[0].second,
cur.selectionAsString(true, true));
cur.selectionAsString(true, true), bp);
}
if (begpit != endpit)
@ -1027,7 +1037,7 @@ void copyInset(Cursor const & cur, Inset * inset, docstring const & plaintext)
theCuts.push(make_pair(pars, bp.documentClassPtr()));
// stuff the selection onto the X clipboard, from an explicit copy request
putClipboard(theCuts[0].first, theCuts[0].second, plaintext);
putClipboard(theCuts[0].first, theCuts[0].second, plaintext, bp);
}
@ -1110,7 +1120,8 @@ void copySelection(Cursor const & cur, docstring const & plaintext)
}
// stuff the selection onto the X clipboard, from an explicit copy request
putClipboard(theCuts[0].first, theCuts[0].second, plaintext);
putClipboard(theCuts[0].first, theCuts[0].second, plaintext,
cur.buffer()->params());
}
@ -1162,8 +1173,8 @@ docstring selection(size_t sel_index, DocumentClassConstPtr docclass)
void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
DocumentClassConstPtr docclass, ErrorList & errorList,
cap::BranchAction branchAction)
DocumentClassConstPtr docclass, ErrorList & errorList,
cap::BranchAction branchAction)
{
if (cur.inTexted()) {
Text * text = cur.text();

View File

@ -61,7 +61,7 @@ namespace {
// The format should also be updated in configure.py, and conversion code
// should be added to prefs2prefs_prefs.py.
static unsigned int const LYXRC_FILEFORMAT = 31; // lasgouttes: add \ct_additions_underlined
static unsigned int const LYXRC_FILEFORMAT = 32; // spitz: add \ct_markup_copied
// when adding something to this array keep it sorted!
LexerKeyword lyxrcTags[] = {
{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@ -93,6 +93,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
{ "\\copier", LyXRC::RC_COPIER },
{ "\\ct_additions_underlined", LyXRC::RC_CT_ADDITIONS_UNDERLINED },
{ "\\ct_markup_copied", LyXRC::RC_CT_MARKUP_COPIED },
{ "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
{ "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
{ "\\def_file", LyXRC::RC_DEFFILE },
@ -676,6 +677,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
lexrc >> ct_additions_underlined;
break;
case RC_CT_MARKUP_COPIED:
lexrc >> ct_markup_copied;
break;
case RC_CURSOR_FOLLOWS_SCROLLBAR:
lexrc >> cursor_follows_scrollbar;
break;
@ -1601,6 +1606,16 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
if (tag != RC_LAST)
break;
// fall through
case RC_CT_MARKUP_COPIED:
if (ignore_system_lyxrc ||
ct_markup_copied
!= system_lyxrc.ct_markup_copied) {
os << "\\ct_markup_copied "
<< convert<string>(ct_markup_copied) << '\n';
}
if (tag != RC_LAST)
break;
// fall through
case RC_CURSOR_FOLLOWS_SCROLLBAR:
if (ignore_system_lyxrc ||
cursor_follows_scrollbar
@ -2771,6 +2786,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
case LyXRC::RC_COPIER:
case LyXRC::RC_CT_ADDITIONS_UNDERLINED:
case LyXRC::RC_CT_MARKUP_COPIED:
case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
case LyXRC::RC_GUI_LANGUAGE:

View File

@ -67,6 +67,7 @@ public:
RC_CONVERTER_CACHE_MAXAGE,
RC_COPIER,
RC_CT_ADDITIONS_UNDERLINED,
RC_CT_MARKUP_COPIED,
RC_CURSOR_FOLLOWS_SCROLLBAR,
RC_CURSOR_WIDTH,
RC_DEFAULT_DECIMAL_SEP,
@ -422,6 +423,8 @@ public:
///
bool ct_additions_underlined = true;
///
bool ct_markup_copied = false;
///
bool scroll_below_document = false;
///
enum MacroEditStyle {

View File

@ -1813,8 +1813,9 @@ bool Text::dissolveInset(Cursor & cur)
// but we'll try the cheaper solution here.
cur.buffer()->clearReferenceCache();
// Do not revive deleted text
lyx::acceptChanges(plist, b.params());
if (!lyxrc.ct_markup_copied)
// Do not revive deleted text
lyx::acceptChanges(plist, b.params());
// ERT paragraphs have the Language latex_language.
// This is invalid outside of ERT, so we need to

View File

@ -2746,6 +2746,8 @@ PrefEdit::PrefEdit(GuiPreferences * form)
this, SIGNAL(changed()));
connect(macLikeCursorMovementCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(copyCTMarkupCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(sortEnvironmentsCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(groupEnvironmentsCB, SIGNAL(clicked()),
@ -2776,6 +2778,7 @@ void PrefEdit::applyRC(LyXRC & rc) const
rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
rc.scroll_below_document = scrollBelowCB->isChecked();
rc.mac_like_cursor_movement = macLikeCursorMovementCB->isChecked();
rc.ct_markup_copied = copyCTMarkupCB->isChecked();
rc.sort_layouts = sortEnvironmentsCB->isChecked();
rc.group_layouts = groupEnvironmentsCB->isChecked();
switch (macroEditStyleCO->currentIndex()) {
@ -2799,6 +2802,7 @@ void PrefEdit::updateRC(LyXRC const & rc)
cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
scrollBelowCB->setChecked(rc.scroll_below_document);
macLikeCursorMovementCB->setChecked(rc.mac_like_cursor_movement);
copyCTMarkupCB->setChecked(rc.ct_markup_copied);
sortEnvironmentsCB->setChecked(rc.sort_layouts);
groupEnvironmentsCB->setChecked(rc.group_layouts);
macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PrefEditUi</class>
<widget class="QWidget" name="PrefEditUi">
@ -5,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>385</width>
<height>435</height>
<width>494</width>
<height>583</height>
</rect>
</property>
<property name="sizePolicy">
@ -31,6 +32,33 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="scrollBelowCB">
<property name="text">
<string>Scroll &amp;below end of document</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="sortEnvironmentsCB">
<property name="text">
<string>Sort &amp;environments alphabetically</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>200</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cursorFollowsCB">
<property name="text">
@ -71,23 +99,23 @@
</item>
</layout>
</item>
<item row="1" column="1" colspan="2">
<spacer name="horizontalSpacer_3">
<item row="7" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>200</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="scrollBelowCB">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="groupEnvironmentsCB">
<property name="text">
<string>Scroll &amp;below end of document</string>
<string>&amp;Group environments by their category</string>
</property>
</widget>
</item>
@ -101,21 +129,7 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="sortEnvironmentsCB">
<property name="text">
<string>Sort &amp;environments alphabetically</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="groupEnvironmentsCB">
<property name="text">
<string>&amp;Group environments by their category</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QComboBox" name="macroEditStyleCO">
<item>
<property name="text">
@ -134,18 +148,15 @@
</item>
</widget>
</item>
<item row="6" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="4" column="0">
<widget class="QCheckBox" name="copyCTMarkupCB">
<property name="toolTip">
<string>If this is checked, deleted and added text in change tracking mde will not be resolved on copy/paste operations and when moving content from/to insets</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="text">
<string>&amp;Keep change tracking markup on copy and paste</string>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>