Prevent duplicate tabs

Features wanted...
highend
Posts: 14593
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Prevent duplicate tabs

Post by highend »

to "live with that temporary solution"
Just wrong. A lot of requests make it into the core. Even trivial ones that can be easily solved by scripting. I for myself post snippets / scripts for things that
a.) Probably won't make it into the core because they are to special for the normal user base
1.) I don't think that preventing opening duplicates is too special! (but I never needed it myself because I know what tabs are open and I simply don't open duplicates because of that)
2.) Tab reordering by a specific rule (like my last script) is too special. Why? 99% of the userbase won't ever need / use them
b.) Solve the current problem while waiting to get implemented by Don (if enough users request the same / support a request)
One of my scripts helped you out? Please donate via Paypal

binocular222
Posts: 1419
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Prevent duplicate tabs

Post by binocular222 »

You said I'm wrong while your point "b)" repeat my point.

You said Don implemented trivial features from times to times? That depend on his own judgment.
I want to point out that "ordinary user" cannot have enough support to affect Don's judgment:

When Don considers whether to invest his time to implement feature A or feature B base on "how many users make request". The problem is if feature A has a workaround/script, while feature B has not, then more users will raise their voice for feature B. And feature A get stuck in "to do list" until all the unable-to-workaround features get implemented. ==> Features get implemented base on whether it has workaround instead of whether it's essential to ordinary user (workarounds are never easy to ordinary users)
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Prevent duplicate tabs

Post by LittleBiG »

binocular222 wrote:That depend on his own judgment.
I want to point out that "ordinary user" cannot have enough support to affect Don's judgment:
Do you know what the problem is? That for other companies and developers we all are ordinary user and cannot affect ANY decisions. We are spoiled with the best license agreement we can get ever, the possibility of even daily contact and with a do-it-yourself possibility if every other ways fail. So here at least we have a chance to be more than an ordinary user.

EDIT: oops, sorry, this has nothing about preventing duplicate tabs. I stop now.

Acecool
Posts: 43
Joined: 25 May 2016 11:13

Re: Prevent duplicate tabs

Post by Acecool »

SammaySarkar wrote:
Acecool wrote:and now with double-checking the ini file and it appears that some of the settings were reset O_o;
Because you have to follow the correct procedure, as layed out in the "How to Tweak" link in my earlier post. You have to restart/exit XYplorer WITHOUT saving settings after you've edited the ini. Because otherwise XY would overwrite your changes with the current settings it has in memory.
I'm aware how to modify config files; but are you saying that it overwrites the ini when it opens again? Because I closed XY prior to modifying the settings last time..

Cheers highend, I was going to give it a go but this is nice of you! and it seems I need to look over all available flags to check for lock/unlock status as it seems there may be more to it... I haven't found a wiki which lists all of the scripting functions yet, does one exist? So far it's just been Google: <func> (arguments|parameters) -- using XYplorer in the name, or site:xyplorer.com

Edit: I don't believe the folder-size or the caching system is "trivial"... It is one of the features I actually do like because QTTabbar doesn't have it, or it doesn't work properly when enabled... Although, when caching is set, there are issues with it... Example: If I enabled caching of folder-sizes and load a folder, and I have the auto-sizing of columns enabled, the auto-sizer resizes everything twice instead of waiting until the folder-sizes are loaded from cache or calculated before performing the resizing action... Those types of issues with existing features should be addressed in my opinion...

I have a lot of folders open at any given time because of a car accident which leaves me stuck in bed for days at a time.. when I sit down to use my computer and to code in various languages I keep everything up and running 24/7 so that there isn't any time wasted opening tabs, launching applications, etc... But when you spend a few days between working on code and you come back, you may not remember every tab open which is why navigating to duplicates can be a problem... It may not be for everyone because you know what you have open, but consider the benefits for a moment...

Instead of navigating and having to remember what tabs you have open, you could simply navigate through as you would normally... If a tab is open, an on-address-changed hook / callback / broadcast could alter the behavior and close the tab you're in and use the tab that already exists and when you navigate away it'll reopen and focus the tab so you have uninterrupted browsing without paying that much attention..

In terms of cost for running the logic, if done properly it'd be O( 1 )..

highend
Posts: 14593
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Prevent duplicate tabs

Post by highend »

I haven't found a wiki which lists all of the scripting functions yet
It's in the help file...

Advanced Topics - Scripting Commands Reference

+

http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13581
One of my scripts helped you out? Please donate via Paypal

Acecool
Posts: 43
Joined: 25 May 2016 11:13

Re: Prevent duplicate tabs

Post by Acecool »

Thanks, that is quite helpful ( help > Scripting reference ; contains everything ).. Although some of the args seem unintuitive ( as noted within code below )..


I decided to go ahead and write one up from scratch ( using your locked line ) and using the secondary part from the original script.. I need to look up and play around with arrays a bit more because everything I want to do is easily possible using 1 while-loop with the checks within as O( 1 ) if the arrays are built right... if not then I need to derive an alternative method ( maybe by using variable variables which is also O( 1 ) if varvars can work )...

Heavily commented for those that want to learn.

Code: Select all

//
// Move all locked tabs to the left, and remove duplicates... Josh 'Acecool' Moser
// Remove duped / second-while based almost entirely on highend initial script...
//
	// Base list and clean-list vars...
	$_list = "";
	$_list_clean = "";

	// How many tabs are we dealing with?
	$_count = tab( "get", "count" );

	// Where should the locked tab be moved to? Index starts at 1...
	$_locki = 1;

	// Build our list and move the locked tabs left...
	while ( $i++ < $_count )
	{
		// Build up the list ( since we're moving locked tabs left, we won't run into any issues )..
		$_list = $_list . tab( "get", "path", $i ) . "<crlf>";

		// Is locked...
		$_locked = regexmatches( tab( "get", "flags", $i ), "(1|3|5|7)" ) ? 1 : 0;

		// If locked, we move it to the first position available and increment the first pos available...
		if ( $_locked )
		{
			// IF a move is necessary
			if ( $i > $_locki )
			{
				// Honestly this is backwards.. Move tab at index $i to index $_locki...
				tab( "move", $_locki, $i );
			}

			// Increment our counter...
			$_locki++;
		}
	}

	// Parse the list...
	$_list_clean = formatlist( $_list, "d", "<crlf>" );

	// So we can re-use i...
	$i = 0; $k = 0;

	// Note: By moving the locked tabs leftward, it should prevent them from being removed prior to unlocked tabs which will be seen as duplicates of the left-most tabs..
	// Now remove duplicates... I need to read up on tables in this scripting lang to see about parsing everything in a single while... Not a fan of this...
	while ( $i++ < $_count )
	{
		$curTab = tab( "get", "path", $i - $k );
		if ( strpos( $_list_clean, "$curTab<crlf>" ) != -1 )
		{
			$_list_clean = replace( $_list_clean, "$curTab<crlf>", "" );
		}
		else
		{
			tab( "close", "0", $i - $k );
			$k++;
		}
	}

Post Reply