Activate Tab from script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Evolve
Posts: 353
Joined: 27 Feb 2020 09:48

Activate Tab from script

Post by Evolve »

tab([operation], [data], [index], [ID])
operation:
"activate" = activate (foreground) a tab
index: index of the tab to activate (leftmost tab = 1)

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

Re: Activate Tab from script

Post by highend »

seltab ...
One of my scripts helped you out? Please donate via Paypal

Evolve
Posts: 353
Joined: 27 Feb 2020 09:48

Re: Activate Tab from script

Post by Evolve »

Thanks... :)

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

Re: Activate Tab from script

Post by highend »

Moved...
One of my scripts helped you out? Please donate via Paypal

Evolve
Posts: 353
Joined: 27 Feb 2020 09:48

Re: Activate Tab from script

Post by Evolve »

I have some weird stuff going on. Here is my script.

Code: Select all

$path = itematpos();
$number_of_tabs = tab("get", "index", -1);
$index = 0;
while ($number_of_tabs > 0){
	if($path == tab("get", "path", $number_of_tabs)){
		$index = tab("get", "index", $number_of_tabs);
		break;
	}
	$number_of_tabs--;
}
if($index != 0){
	seltab $index;
}else{
	tab("new", $path);
}
I use it for CEA Middle-click on folder. It basically either opens a path in a new tab if no existing tab matches the path or reusing existing tab if there is one which does match. It works fine in List and Unlocked Tree.

PllsMM348I.gif
PllsMM348I.gif (244.93 KiB) Viewed 463 times

But as soon as I lock the Tree it starts behaving weird. The selection in the Locked Tree stops following the path changing.

Y1FhiWC54s.gif
Y1FhiWC54s.gif (166.26 KiB) Viewed 463 times

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

Re: Activate Tab from script

Post by highend »

Works fine here...

Btw, a much more concise script would be:

Code: Select all

    $path    = itematpos();
    $tabs    = get("Tabs", <crlf>);
    $matches = regexmatches($tabs, "^" . regexreplace($path, "([\\.+(){\[^$])", "\$1") . "$", <crlf>);
    if ($matches) { seltab gettokenindex(gettoken($matches, 1, <crlf>), $tabs, <crlf>, ""); }
    else          { tab("new", $path); }
One of my scripts helped you out? Please donate via Paypal

Evolve
Posts: 353
Joined: 27 Feb 2020 09:48

Re: Activate Tab from script

Post by Evolve »

Your script, clean app, same weird stuff...

PDB19bzj1D.gif
PDB19bzj1D.gif (297.6 KiB) Viewed 407 times

Post Reply