]> git.lyx.org Git - lyx.git/commitdiff
Add InsertCotext tag to InsetLayout
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 13 Aug 2024 05:26:08 +0000 (07:26 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 13 Aug 2024 05:29:14 +0000 (07:29 +0200)
Avoids hardcoding of insets, and this behavior is possibly useful to
other insets than index and nomencl

We take this on yesterday's layout format change

lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/layouts/stdinsets.inc
lib/scripts/layout2layout.py
src/Text.cpp
src/TextClass.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h

index cef51f803b9264ec89c71116166c1dcfb5010fa9..d27349cd2eaa95b5bb6470b53d73896629a55c65 100644 (file)
@@ -13050,6 +13050,8 @@ status collapsed
 
 \change_inserted -712698321 1723455730
 EscapeChars
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -13062,6 +13064,8 @@ status collapsed
 
 \change_inserted -712698321 1723455616
 string
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -19776,6 +19780,8 @@ status collapsed
 
 \change_inserted -712698321 1723455884
 EscapeChars
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -19788,6 +19794,8 @@ status collapsed
 
 \change_inserted -712698321 1723455884
 string
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20250,6 +20258,82 @@ status collapsed
  export if this parameter is 1,
  as well as on screen.
  Otherwise the document default font is used.
+\change_inserted -712698321 1723525171
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1723526674
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1723525171
+InsertCotext
+\end_layout
+
+\end_inset
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1723525183
+[
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1723525183
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1723525183
+
+\emph on
+1
+\end_layout
+
+\end_inset
+
+]
+\end_layout
+
+\end_inset
+
+ If this is set to 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1723525171
+1
+\end_layout
+
+\end_inset
+
+,
+ a copy of the co-text (either selected text or the word preceding the cursor) is inserted as content on inset creation.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
@@ -22787,6 +22871,8 @@ status collapsed
 
 \change_inserted -712698321 1723455760
 EscapeChars
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22799,6 +22885,8 @@ status collapsed
 
 \change_inserted -712698321 1723455760
 string
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22817,6 +22905,8 @@ status collapsed
 
 \change_inserted -712698321 1723455760
 %!@
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22829,6 +22919,8 @@ status collapsed
 
 \change_inserted -712698321 1723455760
 !
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22841,6 +22933,8 @@ status collapsed
 
 \change_inserted -712698321 1723455760
 @
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22853,6 +22947,8 @@ status collapsed
 
 \change_inserted -712698321 1723455760
 %
+\change_unchanged
+
 \end_layout
 
 \end_inset
index 7932ef56bfeb2eb8ac445e4df1071b935cd146a0..b89a461d6c842c8ba2a761e8afb2f3eadcb93078 100644 (file)
@@ -19026,6 +19026,56 @@ nolink "false"
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+InsertCotext
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\emph on
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+] Wenn dies auf 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+ gesetzt wird,
+ wird eine Kopie des umgebenden Texts (entweder der ausgewählte Text oder das Wort vor dem Cursor) bei der Erstellung als Inhalt eingefügt.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 InToc
 \end_layout
index 8dab576d3d66fc3c54bc7ddc869ccc560374cb17..ea2a3cc50e317eac44573fabb8bf1d3a8dfc1a90 100644 (file)
@@ -421,6 +421,7 @@ InsetLayout Index
        ForcePlain            true
        ContentAsLabel        true
        EscapeChars           \"@|!
+       InsertCotext          1
 End
 
 InsetLayout IndexMacro:see
@@ -482,6 +483,7 @@ InsetLayout Nomenclature
                EscapeChars   %!@|
        EndArgument
        EscapeChars           %!@|
+       InsertCotext          1
 End
 
 InsetLayout Box
index b90350e10984dbd019bc58711cd435f4446b5f94..cc3adaaa0371e776fb8b1e6d1aeb1919fab40141 100644 (file)
@@ -356,7 +356,8 @@ currentFormat = 107
 # New CiteEngine type "notes"
 
 # Incremented to format 107, 12 August 2023 by spitz
-# New InsetLayout and Layout tags "EscapeChars"
+# New InsetLayout, Argument and Layout tags "EscapeChars"
+# New InsetLayout tag "InsertCotext"
 
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
index 3a137202cf5e7743094fa950291e563927bce84b..7c0b18cbfd05fddcdc7a203be19c913d6951bc42 100644 (file)
@@ -3643,8 +3643,7 @@ bool doInsertInset(Cursor & cur, Text * text,
 
        bool gotsel = false;
        bool move_layout = false;
-       bool const copy_cotext = cmd.action() == LFUN_INDEX_INSERT
-                       || cmd.action() == LFUN_NOMENCL_INSERT;
+       bool const copy_cotext = inset->getLayout().insertCotext();
        if (cur.selection()) {
                if (copy_cotext)
                        copySelectionToTemp(cur);
index 8600b64d660202a906b9248aaea5d6dd761a03ce..d58bc28d55ec968736fa428bb0c488c99a804968 100644 (file)
@@ -59,7 +59,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 107; // spitz: EscapeChars
+int const LAYOUT_FORMAT = 107; // spitz: EscapeChars and InsertCotext
 
 
 // Layout format for the current lyx file format. Controls which format is
index 581c01c569427c5a2dc262a84d75550fa3f5fbb7..4b0ef41ae0672d22d844cbb0b0f3064f7de26bb4 100644 (file)
@@ -125,6 +125,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                IL_DOCBOOKRENDERASIMAGE,
                IL_ESCAPE_CHARS,
                IL_INHERITFONT,
+               IL_INSERTCOTEXT,
                IL_INTOC,
                IL_ISTOCCAPTION,
                IL_LABELFONT,
@@ -217,6 +218,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                { "htmlstyle", IL_HTMLSTYLE },
                { "htmltag", IL_HTMLTAG },
                { "inheritfont", IL_INHERITFONT },
+               { "insertcotext", IL_INSERTCOTEXT },
                { "intoc", IL_INTOC },
                { "istoccaption", IL_ISTOCCAPTION },
                { "keepempty", IL_KEEPEMPTY },
@@ -362,6 +364,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_INHERITFONT:
                        lex >> inheritfont_;
                        break;
+               case IL_INSERTCOTEXT:
+                       lex >> insert_cotext_;
+                       break;
                case IL_INTOC:
                        lex >> intoc_;
                        break;
index be9aabfafe882bc6bfd7a6adfa3b42466fd50c46..21f5095d1a8aa6e5eaaf0c9a1fd4f3c0a1fdd3a8 100644 (file)
@@ -271,6 +271,8 @@ public:
        int allowedOccurrences() const { return allowed_occurrences_; }
        ///
        bool allowedOccurrencesPerItem() const { return allowed_occurrences_per_item_; }
+       ///
+       bool insertCotext() const { return insert_cotext_; }
 private:
        ///
        void makeDefaultCSS() const;
@@ -468,6 +470,8 @@ private:
        int allowed_occurrences_ = -1;
        ///
        bool allowed_occurrences_per_item_ = false;
+       ///
+       bool insert_cotext_ = false;
 };
 
 ///