commit e020efc855868a7efa64362495f44268778059d8 Author: Juergen Spitzmueller <sp...@lyx.org> Date: Sun Aug 24 09:40:07 2025 +0200
Use '##' syntax for counter in InsetLayout LabelString (part of #12532) Until now, if the inset had a counter, it was blindly appended to the label string after a space. This (undocumented) behavior is not only too unflexible (e.g. cases such as "Subequations (1)"), it is arguably also too anglo-centric. --- lib/doc/Customization.lyx | 33 +++++++++++++++++++++++++++++++++ lib/doc/de/Customization.lyx | 21 +++++++++++++++++++++ lib/layouts/endnotes.module | 2 +- lib/layouts/enotez.module | 2 +- lib/layouts/jlreq-common.inc | 2 +- lib/layouts/litinsets.inc | 2 +- lib/layouts/memoir.layout | 2 +- lib/layouts/stdinsets.inc | 2 +- lib/layouts/subequations.module | 2 +- src/insets/InsetFlex.cpp | 8 ++++---- src/insets/InsetFoot.cpp | 15 ++++++++------- 11 files changed, 73 insertions(+), 18 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 8997d3311f..26343659e1 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -20383,6 +20383,8 @@ status collapsed \change_inserted -712698321 1756018883 Counter +\change_unchanged + \end_layout \end_inset @@ -20395,6 +20397,8 @@ status collapsed \change_inserted -712698321 1756018878 <name> +\change_unchanged + \end_layout \end_inset @@ -21891,6 +21895,35 @@ Branch \end_inset ) modify this label on the fly. + +\change_inserted -712698321 1756021044 + If the inset has a counter, + it can be added to the label via the placeholder +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1756021044 +## +\change_unchanged + +\end_layout + +\end_inset + + (e.g., + +\begin_inset Quotes eld +\end_inset + +Foot ## +\begin_inset Quotes erd +\end_inset + +). +\change_unchanged + \end_layout \begin_layout Description diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx index 138b8eeaab..9729929330 100644 --- a/lib/doc/de/Customization.lyx +++ b/lib/doc/de/Customization.lyx @@ -19879,6 +19879,27 @@ string =""] wird auf dem Knopf der Einfügung und anderswo als Marke angezeigt. Einige Einfügungstypen (\SpecialChar TeX -Code und Zweig) ändern diese Marke temporär. + Falls die Einfügung einen Zähler verwendet, + kann dieser der Marke über den Platzhalter +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout +## +\end_layout + +\end_inset + + hinzugefügt werden (bspw. + +\begin_inset Quotes gld +\end_inset + +Fußnote ## +\begin_inset Quotes grd +\end_inset + +). \end_layout \begin_layout Description diff --git a/lib/layouts/endnotes.module b/lib/layouts/endnotes.module index 9130bbbb5a..c0248fa874 100644 --- a/lib/layouts/endnotes.module +++ b/lib/layouts/endnotes.module @@ -26,7 +26,7 @@ InsetLayout Flex:Endnote Size Small EndFont MultiPar true - LabelString endnote + LabelString "Endnote ##" Requires endnotes LangPreamble \providecommand{\notesname}{_(Notes[[Endnotes]])} diff --git a/lib/layouts/enotez.module b/lib/layouts/enotez.module index e9cdeaede0..294622e532 100644 --- a/lib/layouts/enotez.module +++ b/lib/layouts/enotez.module @@ -26,7 +26,7 @@ InsetLayout Flex:Endnote Size Small EndFont MultiPar true - LabelString endnote + LabelString "Endnote ##" Requires enotez End diff --git a/lib/layouts/jlreq-common.inc b/lib/layouts/jlreq-common.inc index 7837220005..d3d65efd46 100644 --- a/lib/layouts/jlreq-common.inc +++ b/lib/layouts/jlreq-common.inc @@ -136,7 +136,7 @@ InsetLayout Flex:Endnote LatexName endnote Counter footnote Decoration Classic - LabelString "Endnote" + LabelString "Endnote ##" ForcePlain 1 BgColor background ResetsFont true diff --git a/lib/layouts/litinsets.inc b/lib/layouts/litinsets.inc index 4c00727078..bc56d5b351 100644 --- a/lib/layouts/litinsets.inc +++ b/lib/layouts/litinsets.inc @@ -16,7 +16,7 @@ End OutlinerName literate "Literate programming" InsetLayout "Flex:Chunk" - LabelString "Chunk" + LabelString "Chunk ##" LatexType none LyXType Custom Counter chunk diff --git a/lib/layouts/memoir.layout b/lib/layouts/memoir.layout index 45d3291b82..4f5f5fa51f 100644 --- a/lib/layouts/memoir.layout +++ b/lib/layouts/memoir.layout @@ -320,7 +320,7 @@ InsetLayout Flex:Endnote Size Small EndFont MultiPar true - LabelString endnote + LabelString "Endnote ##" Preamble \makepagenote EndPreamble diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index 715f5fd44e..752d478c4e 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -49,7 +49,7 @@ InsetLayout Marginal End InsetLayout Foot - LabelString Foot + LabelString "Foot ##" LatexType Command LatexName footnote Counter footnote diff --git a/lib/layouts/subequations.module b/lib/layouts/subequations.module index b16bba6ab9..35261fe446 100644 --- a/lib/layouts/subequations.module +++ b/lib/layouts/subequations.module @@ -22,7 +22,7 @@ InsetLayout Flex:Subequations LyxType custom Decoration classic Counter equation - LabelString Subequations + LabelString "Subequations (##)" LatexType Environment LatexName subequations MultiPar true diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 3383fb6289..fd9d4677c9 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -159,14 +159,14 @@ void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype, bool cons } if (have_counter) { + docstring val = from_ascii("#"); if (!deleted) { cnts.step(count, utype); if (il.stepParentCounter()) cnts.stepParent(count, utype); - custom_label += ' ' + - cnts.theCounter(count, it.paragraph().getParLanguage(bp)->code()); - } else - custom_label += ' ' + from_ascii("#"); + val = cnts.theCounter(count, it.paragraph().getParLanguage(bp)->code()); + } + custom_label = support::subst(custom_label, from_ascii("##"), val); } setLabel(custom_label); diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 08bd2915b7..4bac2a4a2b 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -26,6 +26,7 @@ #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" +#include "support/lstrings.h" using namespace std; @@ -80,17 +81,17 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype, bool cons docstring const & count = il.counter(); custom_label_ = translateIfPossible(il.labelstring()); - int val = cnts.value(count); + docstring val = from_ascii("#"); if (cnts.hasCounter(count)) { + int v = cnts.value(count); cnts.step(count, utype); - if (!custom_label_.empty()) - custom_label_ += ' '; - custom_label_ += cnts.theCounter(count, lang->code()); + val = cnts.theCounter(count, lang->code()); if (deleted) // un-step after deleted counter - cnts.set(count, val); - } else - custom_label_ += ' ' + from_ascii("#"); + cnts.set(count, v); + } + + custom_label_ = support::subst(custom_label_, from_ascii("##"), val); setLabel(custom_label_); InsetCollapsible::updateBuffer(it, utype, deleted); -- lyx-cvs mailing list lyx-cvs@lists.lyx.org https://lists.lyx.org/mailman/listinfo/lyx-cvs