Page 1 of 1

Code Snippet - Ellipsing Paths at Popupmenu

Posted: 28 Jul 2014 11:23
by SkyFrontier
Bothered with popping an unfriendly menu to your fellow mates, chap?
So here's a plugin code you may easily integrate into yours avoiding stress, relieving from boring time, increasing life span, making more money, working less, making friends, influencing people and having more time to spend with your...
...social network. ¬¬

Tech notes:
-$a contains the input paths;
- $pathLENmax = "35";
$pathLENmaxP2 = "35";
can be tweaked, controlling the length of right and left sides of $mid (which I usually put in the upper part, but this time is out of reach as it's unusual to see any other separator than "...");
-$pathLENmax+$pathLENmaxP2 are the limits for the path length - any pathname longer than this will be ellipsed, shorter will not;
-the last component, folder or file, will never be ellipsed for better user control over targets;
-labels can easily be substr'ed, if they turn into a problem for you with displaying longish targets.

Enhancements are welcome.

Here's an example. Bear in mind that the path is delivered by variable '$b', which works independently from the echo'ed stuff:
The solution.
The solution.
XYss_Method_EllipsingPathsAtPopupMenu_v2.png (49.82 KiB) Viewed 2147 times
A non-ellipsed menu looks like this (the problem becomes more evident the longer the actual paths are):
The problem.
The problem.
XYss_Method_EllipsingPathsAtPopupMenu_yourOldMenu.png (37.27 KiB) Viewed 2147 times
Method_EllipsingPathsAtPopupMenu_v2.xys
The code.
(3.44 KiB) Downloaded 205 times
________
keywords: snippet ; plugin ; plug-in ; method

Re: Code Snippet - Ellipsing Paths at Popupmenu

Posted: 20 Oct 2014 11:18
by PeterH
Just an idea: for deciding whether to ellipse a string or not you could add about 2 characters. As for your 3rd example an "a" is replaced by ellipses - so the resultant string is longer than the original.

By the way: could be a nice function.
Too bad XY doesn't allow user-written functions :evil:
(Sorry: I didn't mention this for quite a long time, so I did here :ninja: )

Re: Code Snippet - Ellipsing Paths at Popupmenu

Posted: 22 Jun 2015 20:14
by SkyFrontier
PeterH wrote:Just an idea: for deciding whether to ellipse a string or not you could add about 2 characters. As for your 3rd example an "a" is replaced by ellipses - so the resultant string is longer than the original.

By the way: could be a nice function.
Too bad XY doesn't allow user-written functions :evil:
(Sorry: I didn't mention this for quite a long time, so I did here :ninja: )
Hi, Peter.
Missed your comment here back then, sorry.
Yes, I noticed this but didn't care enough to fix it. Will do, anytime soon (as time permits).
By the way, I updated the ellipsing code logic on another script.
Thanks for the feedback. :cup:

Re: Code Snippet - Ellipsing Paths at Popupmenu

Posted: 23 Jun 2015 01:32
by PeterH
Hey: a feedback to myself: in between the time user functions are there :biggrin:

Very very fine :beer: