On 11/25/2009 10:38 AM, Rob wrote:
Hi,

The citation reference box is the gray box in the editing screen that holds the
reference label(s).  I have numerous references and some of these are nearly
half a line long and are clouding up my screen with too much gray space.  How do
I change the length of the citation reference box as it appears in my screen?
Ideally, I would be able to reduce it to just a few character lengths.

Do you mean the Insert>Citation box or the Insert>Cross-Reference box? If the former, it should be limited to 45 characters. If the latter, I don't think we do limit it, but maybe we should. In any event, this can only be done by editing the code.

Attached is a patch (for trunk) that would limit the label to 25 characters and display the whole thing as a tooltip.

Richard

Index: src/insets/InsetRef.h
===================================================================
--- src/insets/InsetRef.h       (revision 32197)
+++ src/insets/InsetRef.h       (working copy)
@@ -41,8 +41,11 @@
        ///
        bool isLabeled() const { return true; }
        ///
-       docstring screenLabel() const;
+       docstring screenLabel() const { return screen_label_; }
        ///
+       docstring toolTip(BufferView const &, int, int) const
+               { return tooltip_; }
+       ///
        bool hasSettings() const { return true; }
        ///
        InsetCode lyxCode() const { return REF_CODE; }
@@ -80,6 +83,8 @@
        bool isLatex;
        ///
        mutable docstring screen_label_;
+       ///
+       mutable docstring tooltip_;
 };
 
 } // namespace lyx
Index: src/insets/InsetRef.cpp
===================================================================
--- src/insets/InsetRef.cpp     (revision 32199)
+++ src/insets/InsetRef.cpp     (working copy)
@@ -66,12 +66,6 @@
 }
 
 
-docstring InsetRef::screenLabel() const
-{
-       return screen_label_;
-}
-
-
 int InsetRef::latex(odocstream & os, OutputParams const &) const
 {
        // We don't want to output p_["name"], since that is only used 
@@ -134,22 +128,36 @@
 
 void InsetRef::updateLabels(ParIterator const & it)
 {
-       docstring const & label = getParam("reference");
+       docstring const & ref = getParam("reference");
        // register this inset into the buffer reference cache.
-       buffer().references(label).push_back(make_pair(this, it));
+       buffer().references(ref).push_back(make_pair(this, it));
 
+       docstring label;
        for (int i = 0; !types[i].latex_name.empty(); ++i) {
                if (getCmdName() == types[i].latex_name) {
-                       screen_label_ = _(types[i].short_gui_name);
+                       label = _(types[i].short_gui_name);
                        break;
                }
        }
-       screen_label_ += label;
+       label += ref;
 
        if (!isLatex && !getParam("name").empty()) {
-               screen_label_ += "||";
-               screen_label_ += getParam("name");
+               label += "||";
+               label += getParam("name");
        }
+       
+       screen_label_ = label;
+       bool shortened = false;
+       unsigned int const maxLabelChars = 25;
+       if (screen_label_.size() > maxLabelChars) {
+               screen_label_.erase(maxLabelChars-3);
+               screen_label_ += "...";
+               shortened = true;
+       }
+       if (shortened)
+               tooltip_ = label;
+       else 
+               tooltip_ = from_ascii("");
 }
 
 
@@ -184,7 +192,7 @@
        { "pageref",   N_("Page Number"),           N_("Page: ")},
        { "vpageref",  N_("Textual Page Number"),   N_("TextPage: ")},
        { "vref",      N_("Standard+Textual Page"), N_("Ref+Text: ")},
-       { "prettyref", N_("PrettyRef"),             N_("FormatRef: ")},
+       { "prettyref", N_("PrettyRef"),             N_("FrmtRef: ")},
        { "", "", "" }
 };
 

Reply via email to