Code Snippet - Ellipsing Paths at Popupmenu

Discuss and share scripts and script files...
Post Reply
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Code Snippet - Ellipsing Paths at Popupmenu

Post 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 2145 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 2145 times
Method_EllipsingPathsAtPopupMenu_v2.xys
The code.
(3.44 KiB) Downloaded 205 times
________
keywords: snippet ; plugin ; plug-in ; method
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Code Snippet - Ellipsing Paths at Popupmenu

Post 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: )

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Code Snippet - Ellipsing Paths at Popupmenu

Post 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:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Code Snippet - Ellipsing Paths at Popupmenu

Post by PeterH »

Hey: a feedback to myself: in between the time user functions are there :biggrin:

Very very fine :beer:

Post Reply