]> git.lyx.org Git - features.git/commitdiff
Add pref to keep ct markup on copy/paste
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 13 Jan 2020 14:20:48 +0000 (15:20 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:50 +0000 (15:48 +0200)
Fixes #10278, #10128

lib/RELEASE-NOTES
lib/doc/UserGuide.lyx
lib/doc/de/UserGuide.lyx
lib/scripts/prefs2prefs_prefs.py
src/CutAndPaste.cpp
src/LyXRC.cpp
src/LyXRC.h
src/Text.cpp
src/frontends/qt/GuiPrefs.cpp
src/frontends/qt/ui/PrefEditUi.ui

index 30e294840d6dc2bf22597d57685c8232bbb02679..3fa80abe7a64ec37be40582ea3b511ed049e9bc2 100644 (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:
 
index a514d0c21ce161cfb276948e3c9350b0e9424aab..3ee3df489e70e8e3b134c482daba0e3b1cbab102 100644 (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
index 4d74e2e60cecddd45753a7de020e7588a9629297..408ca50e204f0e1716e26c6923ed25792e4c91d8 100644 (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
index 1eac80cde351c92949c523b9cb7f8835bc6165c9..6bbb8ac0bc5471b74d3c5ec2c5f9cc9ced2826c4 100644 (file)
 #   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, []]
 ]
index 41019338514297097ad2580f0fa325774981cf3c..8e0a72d6dda5068d155af22cb8081521f1b8a120 100644 (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();
index 7b7b2627102dbab9c5b562e83d8a168731ac3cc5..f7c085c64c3cb6e4c3aa372b126ea1ffc66ff216 100644 (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:
index 1ae79b05000e69a61c054067641dd0931bad952b..ed7511a6d11a9d454fdff3e0f079d9a79a6ec85a 100644 (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 {
index b29e002a494e38fb793b881beb1e719a4222fa1b..dc296384b266a22f76fecdd688677d12ccd1f048 100644 (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
index abd9ff4013c7828f6c0edb49b5b7a6df9cf9f25d..6ba54e3d21428263b455891d8370e0ced399b58b 100644 (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);
index 2db2dd6b64d1bcf0459dcdb745f729681c632601..69aa6f5bdea361f13d314f4f3c0361ed91ef8f53 100644 (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">
       <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">
         </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>
         </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">
         </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>