After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 147608 - Customizing ellipsization behavior
Customizing ellipsization behavior
Status: RESOLVED OBSOLETE
Product: pango
Classification: Platform
Component: general
1.5.x
Other Linux
: Normal enhancement
: Medium API
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2004-07-14 22:13 UTC by Owen Taylor
Modified: 2018-05-22 12:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Owen Taylor 2004-07-14 22:13:56 UTC
There is likely a need to allow the exact details of
pango_layout_set_ellipsize() to be customized by the application.

For example, when ellipsizing a filename we might want to ellipsize
before the basename rather than at the very end.

 - Add another PangoLogAttr for "allowed ellipsization position"
   to replace the  
 - Add whatever framework we need to add anyways to allow customizing
   break positions.
 - Change the ellipsization algorithm to deal with the case where
   no ellipsization is allowed at the very start/end. 
   (find_initial_span() and remove_one_span() need to be made a bit 
   more complex)
Comment 1 Matthias Clasen 2004-09-22 13:56:04 UTC
Another example mentioned recently was the desire to ellipsise just a long
filename embedded in an error message:

The file .../foo/bar/baz.txt can't be read.
Comment 2 Christian Neumair 2008-02-14 11:17:57 UTC
How would we expose this functionality to PangoLayout API users?

We have to consider that we may not just allow to ellipsize at a single position, but constraint the collated text range, and the position where collation begins. The PANGO_ELLIPSIZE_MIDDLE API is quite poor in this context.

I think we have some very specific use-cases:

(1) ellipsize URI: file:///foo/bar/somefile.txt => file:///../somefile.txt 
(2) ellipsize paths: /foo/bar/somefile.txt => /../somefile.txt

[mainly used for file operation error messages]

(3) ellipsize basename: somefile.txt => some... .txt

[mainly used by file managers for displaying file names]

(4) ... Do you have any idea for other use-cases?


Considering (1)-(3) suggests that we want complex but very specific ellipsization strategies. So we have two approaches:

(A) Expose generic ellipsization markup: <span ellipsize_positon="start|end">...</span> [essentially replacing PANGO_ELLIPSIZE_MIDDLE]
(B) Expose filename specific markup: <span ellipsize_style="uri|filename|basename">...</span>


(A)

A generic and developer-friendly approach would be to expose a PangoAttribute for this that operates on text ranges, that is wrapped to markup:


Markup Example 1 (Full URI):

This is an error message concerning file://<span ellipsize_position="start">full-path</span>/myfilename.txt

which would ellipsize to

file://full-p.../myfilename.txt

or

file://.../myfilename.txt

depending on the available space.


Markup Example 2 (basename):

<span ellipsize_position="end">myfilename</span>.txt

[to be used for Nautilus].

Again: These semantics would basically replace PANGO_ELLIPSIZE_MIDDLE.


(B)

Even more (file-related) developer friendly is a tag like

Markup Example 1 (URI)

<span ellipsize_style="uri">file://full-path/myfilename.txt</span>

Markup Example 2 (basename)

<span ellipsize_style="basename">myfilename.txt</span>

These would be resolved to (A).1 and (A).2.

best regards,
 Christian
Comment 3 Behdad Esfahbod 2008-02-14 19:27:31 UTC
Humm, I'm not sure I like replacing _MIDDLE.  What I was thinking about was adding some attribute to mark certain parts of text as good places for ellipsis boundary, or disallowing ellipsization inside some parts.

All that requires a much more sophisticated ellipsization algorithm than what we have now.  I'll start thinking about it after I finish the pango_layout_set_height() mess I created.
Comment 4 Matthew Paul Thomas (mpt) 2008-08-28 17:14:22 UTC
I've reported bug 549729 on implementing an ellipsization scheme that would automatically ellipsize the non-unique parts of a string in a set of strings.
Comment 5 GNOME Infrastructure Team 2018-05-22 12:05:35 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/16.