On Mon, Mar 23, 2020 at 12:36:58PM +0100, Pavel Sanda wrote:
> On Sun, Mar 22, 2020 at 08:26:47PM -0400, Richard Kimberly Heck wrote:
> > On 3/22/20 5:51 PM, Pavel Sanda wrote:
> > > On Sat, Mar 21, 2020 at 11:14:48PM +0100, ??ystein Senneset Haaland wrote:
> > >> When I add a URL as a hyperlink inset and give it a name, I normally 
> > >> would
> > >> like to see the full text of the name in the label. This way, it can to a
> > >> greater extent be part of the surrounding text.
> > >>
> > >> The patch is simple; it only moves the eliding part up where its only the
> > >> target that is set, not the name:
> > > Makes sense. I can commit later if there are no objections. 
> > 
> > Seems sensible to me, too.
> 
> Actually I am not sure anymore about arbitrary lengths. If someone hyperlinks 
> whole
> paragraph, do we really want inset overlaping width of lyx window?
> Wouldn't be enough to make restriction of 'name' case just somewhat longer?
> (Say 80 chars approximating single line in the output.) 

Like this.
Pavel
diff --git a/src/insets/InsetHyperlink.cpp b/src/insets/InsetHyperlink.cpp
index a500f7bd59..65f6c0fe24 100644
--- a/src/insets/InsetHyperlink.cpp
+++ b/src/insets/InsetHyperlink.cpp
@@ -65,14 +65,22 @@ docstring InsetHyperlink::screenLabel() const
        docstring url;
 
        url += getParam("name");
-       if (url.empty())
+       if (url.empty()) {
                url += getParam("target");
 
-       // elide if long
-       if (url.length() > 30) {
-               docstring end = url.substr(url.length() - 17, url.length());
-               support::truncateWithEllipsis(url, 13);
-               url += end;
+               // elide if long and no name was provided
+               if (url.length() > 30) {
+                       docstring end = url.substr(url.length() - 17, 
url.length());
+                       support::truncateWithEllipsis(url, 13);
+                       url += end;
+               }
+       } else {
+               // elide if long (approx number of chars in line of article 
class)
+               if (url.length() > 80) {
+                       docstring end = url.substr(url.length() - 67, 
url.length());
+                       support::truncateWithEllipsis(url, 13);
+                       url += end;
+               }
        }
        return temp + url;
 }
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to