close multi tabs

Features wanted...
Post Reply
zzjean
Posts: 104
Joined: 22 Nov 2009 14:56

close multi tabs

Post by zzjean »

Good evening
Is it possible to close any multiple tabs with a single command or click?
For example in Firefox, I can select tabs (with + CRTL click) and then with a single click, close them all at once.
Maybe it already exists - I searched, but couldn't find anything like it.
I think that would be handy
Thank you

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

Re: close multi tabs

Post by highend »

No there isn't but XY has scripting support?

Code: Select all

    $cntTabs = gettoken(get("tabs"), "count", "|");
    $paths = "";
    while ($i++ < $cntTabs) {
        $name = tab("get", "name", $i);
        if ($name == "") { $name = tab("get", "caption", $i); }
        $paths .= $name . "|" . $i . "|" . "*" . <crlf>;
    }

    $ids = inputselect("Check tab(s) to close...", $paths, <crlf>, 1+2+32+128+1024+8192+16384, , 500, 600);
    $cntClosed   = 1;
    $firstClosed = false;
    foreach($id, $ids, <crlf>, "e") {
        if ($firstClosed) {
            $id -= $cntClosed;
            $cntClosed++;
        }
        tab("close", 0, $id);
        $firstClosed = true;
    }
One of my scripts helped you out? Please donate via Paypal

zzjean
Posts: 104
Joined: 22 Nov 2009 14:56

Re: close multi tabs

Post by zzjean »

ok thank you. Its Nice and it does what I want. But it don't give me the name of the pane
Attachments
Presse-papiers-20231212.png
Presse-papiers-20231212.png (13.14 KiB) Viewed 430 times

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

Re: close multi tabs

Post by highend »

Get the code again, I've changed it slightly
One of my scripts helped you out? Please donate via Paypal

zzjean
Posts: 104
Joined: 22 Nov 2009 14:56

Re: close multi tabs

Post by zzjean »

Hi,
Thank you very much it works perfectly now
It's fine and very useful.

zzjean
Posts: 104
Joined: 22 Nov 2009 14:56

Re: close multi tabs

Post by zzjean »

Bonjour,
I used parts of 2 scripts kindly given by Highend (thanks to him).
This allows me to close the tabs in one panel then in the other.
script.png
script.png (39.35 KiB) Viewed 157 times
I get this:
ecran1.png
ecran1.png (17.13 KiB) Viewed 157 times
Then :
ecran2.png
ecran2.png (22.76 KiB) Viewed 157 times
1 - Is it possible to change the “?” icon. » for p1 and p2 and also for virtual folders.
2 – I have to empty the variables so that the script runs correctly a second time. Is there a command to reset all variables?

Thank you for your help

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

Re: close multi tabs

Post by highend »

Check the inputselect() options to show generic icons. Maybe that fixes that.

Empty variables to let it run a second time? Em, what?
Be more specific, show the relevant code where something doesn't work as expected and generally, post code in text form, not as an image^^
One of my scripts helped you out? Please donate via Paypal

zzjean
Posts: 104
Joined: 22 Nov 2009 14:56

Re: close multi tabs

Post by zzjean »

It took me a long time to understand how to use inputselect() with style 1024 but I succeeded for the first part p1 and p2.
On the other hand, I don't see how to do it with the second part.

For variables, in fact it's only $i of the loop :

while ($i++ < $cntTabs) {
$name = tab("get", "name", $i);
if ($name == "") { $name = tab("get","caption" , $i); }
$paths .= $name . "|" . $i. "|" . "*". <crlf>;
}

which does not reset. i.e. if I have 4 tabs in the first panel, the count starts again at 5 for the second iteration of the loop. So I display 5 fewer panels.
But maybe this is normal.

The script :

While($n<2) { $n++;

$dstpanes = <<<>>>
p1|p1|C:\Users\Utilisateur\AppData\Roaming\XYplorer\Icons\cd.ico
p2|p2|C:\Users\Utilisateur\AppData\Roaming\XYplorer\Icons\cd.ico
>>>;
$dstpanes = inputselect("Select pane(s)", $dstpanes, <crlf>, 1+2+32+16384, , 600, 500);

focus "$dstpanes";


$cntTabs = gettoken(get("tabs"), "count", "|");
$paths = "";
while ($i++ < $cntTabs) {
$name = tab("get", "name", $i);
if ($name == "") { $name = tab("get","caption" , $i); }
$paths .= $name . "|" . $i . "|" . "*" . <crlf>;
}

$ids = inputselect("Check tab(s) to close...", $paths, <crlf>, 1+2+32+128+1024+8192+16384, , 500, 600);
$cntClosed = 1;
$firstClosed = false;
foreach($id, $ids, <crlf>, "e") {
if ($firstClosed) {
$id -= $cntClosed;
$cntClosed++;
}
tab("close", 0, $id);
$firstClosed = true;
}

$i=""; } ;

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

Re: close multi tabs

Post by highend »

If you need to reset a variable before it's e.g. counted up in a next loop again, just set it to e.g. 0 before

Code: Select all

    while ($i++ < $cntTabs) {
    ...
    }
    
    $i = 0;
    while ($i++ < $cntTabs) {
    ...
    }
One of my scripts helped you out? Please donate via Paypal

zzjean
Posts: 104
Joined: 22 Nov 2009 14:56

Re: close multi tabs

Post by zzjean »

OK Thank you

Post Reply