[LyX master] Fix display of counters for included listings.
Richard Kimberly Heck
rikiheck at lyx.org
Sat Feb 10 00:55:01 UTC 2024
The branch, master, has been updated.
- Log -----------------------------------------------------------------
commit 91bd457a674579e1bc9e61aab19c272cd0d342dd
Author: Richard Kimberly Heck <rikiheck at lyx.org>
Date: Fri Feb 9 19:53:55 2024 -0500
Fix display of counters for included listings.
diff --git a/lib/layouts/stdcounters.inc b/lib/layouts/stdcounters.inc
index dbebe25b03..ee143f6b0f 100644
--- a/lib/layouts/stdcounters.inc
+++ b/lib/layouts/stdcounters.inc
@@ -79,6 +79,7 @@ End
Counter listing
GuiName Listing
+ PrettyFormat "Listing ##"
End
Counter equation
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 916196211a..92ec17169c 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1444,22 +1444,28 @@ void InsetInclude::updateBuffer(ParIterator const & it, UpdateType utype, bool c
if (!isListings(params()))
return;
+ Buffer const & master = *buffer().masterBuffer();
+ listings_label_ = master.B_("Program Listing");
+ Counters & counters = master.params().documentClass().counters();
+ docstring const cnt = from_ascii("listing");
+ bool const hasCounter = counters.hasCounter(cnt);
+ if (hasCounter) {
+ counters.saveLastCounter();
+ counters.step(cnt, utype);
+ listings_label_ += " " + convert<docstring>(counters.value(cnt));
+ }
+
if (label_)
label_->updateBuffer(it, utype, deleted);
+ if (hasCounter)
+ counters.restoreLastCounter();
+
InsetListingsParams const par(to_utf8(params()["lstparams"]));
if (par.getParamValue("caption").empty()) {
listings_label_ = buffer().B_("Program Listing");
return;
}
- Buffer const & master = *buffer().masterBuffer();
- Counters & counters = master.params().documentClass().counters();
- docstring const cnt = from_ascii("listing");
- listings_label_ = master.B_("Program Listing");
- if (counters.hasCounter(cnt)) {
- counters.step(cnt, utype);
- listings_label_ += " " + convert<docstring>(counters.value(cnt));
- }
}
-----------------------------------------------------------------------
Summary of changes:
lib/layouts/stdcounters.inc | 1 +
src/insets/InsetInclude.cpp | 22 ++++++++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
hooks/post-receive
--
The LyX Source Repository
More information about the lyx-cvs
mailing list