commit 6a8c10f0d6178dc261f089fe8245de1000ef1941
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Sat Jul 22 16:53:14 2023 +0200

    Display footnote labels as superscripts
    
    A new counter type \superarabic is introduced, that transforms the
    counter into superscript Unicode numbers.
    
    This is used for the footnote counter.
    
    The Foot inset layout is modified to use an empty LabelString (in size
    Normal, since the numbers could be too small).
    
    We use this occasion to set footnote text in footnotesize, as it should.
    
    A couple of changes are done to the code to make the button label and
    tooltip look better.
    
    Fixes bug #12238.
---
 lib/layouts/numreport.inc    |    1 -
 lib/layouts/stdcounters.inc  |    1 +
 lib/layouts/stdinsets.inc    |    6 +++---
 src/Counters.cpp             |    3 +++
 src/insets/InsetFoot.cpp     |    6 ++++--
 src/support/counter_reps.cpp |   13 +++++++++++++
 src/support/counter_reps.h   |    1 +
 7 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/lib/layouts/numreport.inc b/lib/layouts/numreport.inc
index 44ee0fb..9788d8f 100644
--- a/lib/layouts/numreport.inc
+++ b/lib/layouts/numreport.inc
@@ -41,5 +41,4 @@ End
 Counter footnote
        GuiName Footnote
        Within                chapter
-       LabelString           "\arabic{footnote}"
 End
diff --git a/lib/layouts/stdcounters.inc b/lib/layouts/stdcounters.inc
index 4ee63d0..dc730c7 100644
--- a/lib/layouts/stdcounters.inc
+++ b/lib/layouts/stdcounters.inc
@@ -84,6 +84,7 @@ End
 
 Counter footnote
        GuiName Footnote
+       LabelString          "\superarabic{footnote}"
        PrettyFormat         "Footnote ##"
 End
 
diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index 8fafff8..68c3660 100644
--- a/lib/layouts/stdinsets.inc
+++ b/lib/layouts/stdinsets.inc
@@ -49,17 +49,17 @@ InsetLayout Marginal
 End
 
 InsetLayout Foot
-       LabelString           Foot
+       LabelString           ""
        LatexType             Command
        LatexName             footnote
        Counter               footnote
        InheritFont           false
        Font
-         Size                Small
+         Size                FootnoteSize
        EndFont
        LabelFont
          Color               footlabel
-         Size                Small
+         Size                Normal
        EndFont
        MultiPar              true
        RefPrefix             fn
diff --git a/src/Counters.cpp b/src/Counters.cpp
index 0133f76..d7f8630 100644
--- a/src/Counters.cpp
+++ b/src/Counters.cpp
@@ -476,6 +476,9 @@ docstring Counters::labelItem(docstring const & ctr,
        if (numbertype == "fnsymbol")
                return fnsymbolCounter(val);
 
+       if (numbertype == "superarabic")
+               return superarabicCounter(val);
+
        return convert<docstring>(val);
 }
 
diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp
index a0f3435..0f5c706 100644
--- a/src/insets/InsetFoot.cpp
+++ b/src/insets/InsetFoot.cpp
@@ -88,7 +88,9 @@ void InsetFoot::updateBuffer(ParIterator const & it, 
UpdateType utype, bool cons
        int val = cnts.value(count);
        if (cnts.hasCounter(count)) {
                cnts.step(count, utype);
-               custom_label_ += ' ' + cnts.theCounter(count, lang->code());
+               if (!custom_label_.empty())
+                       custom_label_ += ' ';
+               custom_label_ += cnts.theCounter(count, lang->code());
                if (deleted)
                        // un-step after deleted counter
                        cnts.set(count, val);
@@ -107,7 +109,7 @@ docstring InsetFoot::toolTip(BufferView const & bv, int x, 
int y) const
        if (isOpen(bv))
                // this will give us something useful if there is no button
                return InsetCollapsible::toolTip(bv, x, y);
-       return toolTipText(custom_label_+ ": ");
+       return toolTipText(custom_label_+ " ");
 }
 
 
diff --git a/src/support/counter_reps.cpp b/src/support/counter_reps.cpp
index 96cbe24..0d13c10 100644
--- a/src/support/counter_reps.cpp
+++ b/src/support/counter_reps.cpp
@@ -12,6 +12,8 @@
 #include <config.h>
 
 #include "support/counter_reps.h"
+
+#include "support/convert.h"
 #include "support/docstring.h"
 #include "support/lstrings.h"
 
@@ -132,4 +134,15 @@ docstring const fnsymbolCounter(int const n)
        };
 }
 
+
+docstring const superarabicCounter(int const n)
+{
+       docstring superarabic = convert<docstring>(n);
+       static char_type map[] = {0x2070, 0x00b9, 0x00b2, 0x00b3, 0x2074,
+                                 0x2075, 0x2076, 0x2077, 0x2078, 0x2079 };
+       for (char_type & c : superarabic)
+               c = map[c - char_type('0')];
+       return superarabic;
+}
+
 } // namespace lyx
diff --git a/src/support/counter_reps.h b/src/support/counter_reps.h
index e6a3f67..59305dc 100644
--- a/src/support/counter_reps.h
+++ b/src/support/counter_reps.h
@@ -27,6 +27,7 @@ char hebrewCounter(int const n);
 docstring const romanCounter(int const n);
 docstring const lowerromanCounter(int const n);
 docstring const fnsymbolCounter(int const n);
+docstring const superarabicCounter(int const n);
 
 } // namespace lyx
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to