commit 00f1a3d320c653a04c7775ba03d74affcaea7e46
Author: Juergen Spitzmueller <[email protected]>
Date:   Fri Aug 22 08:21:15 2025 +0200

    Add StepOtherCounter to counter
    
    This allows to unidirectionally step a different counter with
    a given one (needed to sync linguistic examples with equations)
---
 lib/doc/Customization.lyx    | 173 ++++++++++++++++++++++++++++++++++++++++++-
 lib/doc/de/Customization.lyx |  52 ++++++++++++-
 lib/scripts/layout2layout.py |   7 +-
 src/Counters.cpp             |  11 +++
 src/Counters.h               |   4 +
 src/TextClass.cpp            |   2 +-
 6 files changed, 244 insertions(+), 5 deletions(-)

diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 9f68cfa032..99b400246e 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -1,5 +1,5 @@
 #LyX 2.5 created this file. For more info see https://www.lyx.org/
-\lyxformat 642
+\lyxformat 643
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -9473,6 +9473,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -9489,6 +9491,8 @@ status collapsed
 
 \change_inserted -849685795 1754369458
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -11338,6 +11342,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -11354,6 +11360,8 @@ status collapsed
 
 \change_inserted -849685795 1754369459
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -13478,6 +13486,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -13494,6 +13504,8 @@ status collapsed
 
 \change_inserted -849685795 1754369461
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20756,6 +20768,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20772,6 +20786,8 @@ status collapsed
 
 \change_inserted -849685795 1754369524
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20865,6 +20881,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20881,6 +20899,8 @@ status collapsed
 
 \change_inserted -849685795 1754369525
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20966,6 +20986,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -20982,6 +21004,8 @@ status collapsed
 
 \change_inserted -849685795 1754369526
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21061,6 +21085,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21077,6 +21103,8 @@ status collapsed
 
 \change_inserted -849685795 1754369527
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21139,6 +21167,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21155,6 +21185,8 @@ status collapsed
 
 \change_inserted -849685795 1754369528
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21227,6 +21259,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21243,6 +21277,8 @@ status collapsed
 
 \change_inserted -849685795 1754369529
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21333,6 +21369,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21349,6 +21387,8 @@ status collapsed
 
 \change_inserted -849685795 1754369530
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21427,6 +21467,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21443,6 +21485,8 @@ status collapsed
 
 \change_inserted -849685795 1754369532
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21519,6 +21563,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21535,6 +21581,8 @@ status collapsed
 
 \change_inserted -849685795 1754369534
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21601,6 +21649,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21617,6 +21667,8 @@ status collapsed
 
 \change_inserted -849685795 1754369535
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21681,6 +21733,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -21697,6 +21751,8 @@ status collapsed
 
 \change_inserted -849685795 1754369536
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22360,6 +22416,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22376,6 +22434,8 @@ status collapsed
 
 \change_inserted -849685795 1754369538
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22473,6 +22533,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22489,6 +22551,8 @@ status collapsed
 
 \change_inserted -849685795 1754369539
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22734,6 +22798,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -22750,6 +22816,8 @@ status collapsed
 
 \change_inserted -849685795 1754369540
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23037,6 +23105,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23053,6 +23123,8 @@ status collapsed
 
 \change_inserted -849685795 1754369551
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23126,6 +23198,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23142,6 +23216,8 @@ status collapsed
 
 \change_inserted -849685795 1754369552
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23211,6 +23287,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23227,6 +23305,8 @@ status collapsed
 
 \change_inserted -849685795 1754369553
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23374,6 +23454,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23390,6 +23472,8 @@ status collapsed
 
 \change_inserted -849685795 1754369554
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23472,6 +23556,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23488,6 +23574,8 @@ status collapsed
 
 \change_inserted -849685795 1754369557
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23684,6 +23772,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -23700,6 +23790,8 @@ status collapsed
 
 \change_inserted -849685795 1754369559
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24012,6 +24104,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24028,6 +24122,8 @@ status collapsed
 
 \change_inserted -849685795 1754369562
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24415,6 +24511,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24431,6 +24529,8 @@ status collapsed
 
 \change_inserted -849685795 1754369451
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24862,6 +24962,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24878,6 +24980,8 @@ status collapsed
 
 \change_inserted -849685795 1754369451
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24940,6 +25044,8 @@ status collapsed
 
 \emph on
 0
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -24956,6 +25062,8 @@ status collapsed
 
 \change_inserted -849685795 1754369451
 1
+\change_unchanged
+
 \end_layout
 
 \end_inset
@@ -25923,6 +26031,69 @@ PrettyFormat
 \end_inset
 
  is used.
+\change_inserted -712698321 1755842953
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1755843126
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1755842965
+StepOtherCounter
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1755842953
+string
+\end_layout
+
+\end_inset
+
+ = 
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+] Specifies a different counter (by counter name) that is also stepped 
whenever the counter defined here is being stepped.
+ If 
+\begin_inset Quotes eld
+\end_inset
+
+none
+\begin_inset Quotes erd
+\end_inset
+
+ is used,
+ no other counter is being stepped (this can be used to reset an inherited 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1755843121
+StepOtherCounter
+\end_layout
+
+\end_inset
+
+ setting).
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index 63a62072f4..c8c71510d8 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -23516,7 +23516,7 @@ string
 \begin_inset Quotes gld
 \end_inset
 
-Formatierten Querverweisen
+formatierten Querverweisen
 \begin_inset Quotes grd
 \end_inset
 
@@ -23595,6 +23595,56 @@ PrettyFormat
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+StepOtherCounter
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+string
+\end_layout
+
+\end_inset
+
+ = ""] Spezifiziert einen anderen Zähler (mittels des Zählernamens),
+ der ebenfalls erhöht wird,
+ sobald der hier definierte Zähler erhöht wird.
+ Der Wert 
+\begin_inset Quotes gld
+\end_inset
+
+
+\lang english
+none
+\lang ngerman
+
+\begin_inset Quotes grd
+\end_inset
+
+ bedeutet,
+ dass kein anderer Zähler mit erhöht wird (dies kann verwendet werden,
+ um eine ererbte Einstellung von 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+StepOtherCounter
+\end_layout
+
+\end_inset
+
+ zurückzusetzen).
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 Within
 \end_layout
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 938587db72..18f852fa34 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -9,7 +9,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 110
+currentFormat = 111
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -371,6 +371,9 @@ currentFormat = 110
 # Incremented to format 110, 5 July 2025 by spitz
 # New Float tag "Preamble"
 
+# Incremented to format 111, 22 August 2025 by spitz
+# New Counter tag "StepOtherCounter"
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -710,7 +713,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if 101 <= format <= 110:
+        if 101 <= format <= 111:
             # nothing to do.
             i += 1
             continue
diff --git a/src/Counters.cpp b/src/Counters.cpp
index b16042065f..694c8fd9c9 100644
--- a/src/Counters.cpp
+++ b/src/Counters.cpp
@@ -62,6 +62,7 @@ bool Counter::read(Lexer & lex)
                CT_GUINAME,
                CT_LATEXNAME,
                CT_REFFORMAT,
+               CT_STEPOTHERCOUNTER,
                CT_END
        };
 
@@ -74,6 +75,7 @@ bool Counter::read(Lexer & lex)
                { "latexname", CT_LATEXNAME },
                { "prettyformat", CT_PRETTYFORMAT },
                { "refformat", CT_REFFORMAT },
+               { "stepothercounter", CT_STEPOTHERCOUNTER },
                { "within", CT_WITHIN }
        };
 
@@ -137,6 +139,12 @@ bool Counter::read(Lexer & lex)
                                lex.next();
                                latexname_ = lex.getDocString();
                                break;
+                       case CT_STEPOTHERCOUNTER:
+                               lex.next();
+                               stepothercounter_ = lex.getDocString();
+                               if (stepothercounter_ == "none")
+                                       stepothercounter_.erase();
+                               break;
                        case CT_END:
                                getout = true;
                                break;
@@ -382,6 +390,9 @@ void Counters::step(docstring const & ctr, UpdateType /* 
deleted */)
        }
 
        it->second.step();
+       if (!it->second.stepOtherCounter().empty())
+               step(it->second.stepOtherCounter(), InternalUpdate);
+
        LBUFERR(!counter_stack_.empty());
        counter_stack_.pop_back();
        counter_stack_.push_back(ctr);
diff --git a/src/Counters.h b/src/Counters.h
index fadc0b0dbc..60dea5736f 100644
--- a/src/Counters.h
+++ b/src/Counters.h
@@ -75,6 +75,8 @@ public:
        docstring const & guiName() const { return guiname_; }
        ///
        docstring const & latexName() const { return latexname_; }
+       ///
+       docstring const & stepOtherCounter() const { return stepothercounter_; }
 
        /// Returns a map of LaTeX-like strings to format the counter.
        /** For each language, the string is similar to what one gets
@@ -99,6 +101,8 @@ private:
         *  parent is "section".
         */
        docstring parent_;
+       /// Another counter that is stepped with this
+       docstring stepothercounter_;
        /// Contains a LaTeX-like string to format the counter.
        docstring labelstring_;
        /// The same as labelstring_, but in appendices.
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index 1fe0d1a8ae..c52d6de019 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -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 = 110; // spitz: Preamble tag for floats
+int const LAYOUT_FORMAT = 111; // spitz: StepOtherCounters tag for Counter
 
 
 // Layout format for the current lyx file format. Controls which format is
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to