Custom keyboard shortcut to select named tab?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Reve_Etrange
Posts: 91
Joined: 19 Mar 2008 18:15

Custom keyboard shortcut to select named tab?

Post by Reve_Etrange »

Hi all,

Is it possible to define a custom keyboard shortcut that select (ie. make active) a named tab?
Basically I have a favorite tab with caption an custom icon, and pretty often I am running thru the tab MRU list (Ctrl-Tab) just to go back there.

I have searched a bit, but couldn't find anything; perhaps some script guru has an idea?

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Custom keyboard shortcut to select named tab?

Post by TheQwerty »

Go > Tablist... (#538) might be more useful than your current method.

The Tab SC doesn't have a "select/focus/activate" option, so while you can locate a tab within the current pane, there isn't an easy way to switch to it.

The next best option would be to have a script cycle through all tabs in the pane until the one with the desired name is active - it's not a solution I like since XY will re-draw the tabs.

Code: Select all

"Select Dropbox Tab"
  Global $G_TAB_NAME = 'Dropbox';
  Sub('_selectTab');

"_selectTab"
  Global $G_TAB_NAME;
  End ! $G_TAB_NAME, 'Global variable $G_TAB_NAME is not defined!';
  $i = 0;
  $tCount = Tab('Get', 'Count');
  while ($i < $tCount) {
    $ctName = Tab('Get', 'Name');
    End $G_TAB_NAME LikeI $ctName;
    $i++;
    #1019; //Miscellaneous | Tab Functions | Cycle Tabs Backward
  }

Reve_Etrange
Posts: 91
Joined: 19 Mar 2008 18:15

Re: Custom keyboard shortcut to select named tab?

Post by Reve_Etrange »

Thanks for the reply.
I Ctrl-Tab a lot because it most often does what I need: cycle between the two tabs I am working with (and my fave tab is one of them).
Conceptually, I could have an MRU tab list with my fave tab locked in 2nd position, if you see what I mean.

Anyway, if there is no "select/focus/activate" option for tabs, I guess it cannot be done.
Any chance to have it implemented sometime?

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Custom keyboard shortcut to select named tab?

Post by admin »

seltab

Reve_Etrange
Posts: 91
Joined: 19 Mar 2008 18:15

Re: Custom keyboard shortcut to select named tab?

Post by Reve_Etrange »

\o/

I made a User Command going to location

Code: Select all

::seltab -3
, since my fave tab is the third from the right, and bound it to some key shortcut.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Custom keyboard shortcut to select named tab?

Post by TheQwerty »

Doh - that's right I forgot about SelTab! :oops:

For anyone that wants a solution that does not rely on the tab's position being kept...

Code: Select all

// Examples of how to call the script.
"Select Tab By Name"
  Global $G_TAB_NAME = Input('Select Tab By Name...', 'Name of the tab to select?', 'TabName');
  Sub '_checkBothPanes';

"Select Tab By Name (In Active Pane Only)"
  Global $G_TAB_NAME = Input('Select Tab By Name...', 'Name of the tab to select?', 'TabName');
  Sub '_checkActivePane';

//------------------------------------------------------------------------------

// Checks the active pane for a named tab...
// If not found, activates and searches the inactive pane.
// If still not found, returns the user to the original pane.
"_checkBothPanes"
  // Ensure we have a query.
  Global $G_TAB_NAME;
  End ! $G_TAB_NAME, 'Global variable $G_TAB_NAME not defined!';
  Global $G_CHECKING_BOTH_PANES = true;

  // Check active pane.
  Sub '_checkActivePane';
  Status 'Checking inactive pane...',, 'progress';

  // Try inactive pane.
  Focus 'PI';
  Sub '_checkActivePane';

  // Return to original pane.
  Focus 'PI';
  Status "No tab named '$G_TAB_NAME' found!",, 'alert';
  Sound 'SystemHand';

// Checks for a tab with matching name in the active pane.
"_checkActivePane"
  // Ensure we have a query.
  Global $G_TAB_NAME, $G_CHECKING_BOTH_PANES;
  End ! $G_TAB_NAME, 'Global variable $G_TAB_NAME not defined!';

  // Enumerate over all tabs searching for a match.
  $i = 1;
  $tCount = Tab('Get', 'Count');
  while ($i <= $tCount) {
    $tName = Tab('Get', 'Name', $i);

    // If found select tab and exit.
    if ($tName LikeI $G_TAB_NAME) {
      SelTab $i;
      Status 'Tab found!',, 'ready';
      Sound 'SystemExit';
      End true;
    }

    $i++;
  }

  // If only checking active pane display an alert at the end.
  if (! $G_CHECKING_BOTH_PANES) {
    Status "No tab named '$G_TAB_NAME' found in this pane!",, 'alert';
    Sound 'SystemHand';
  }
Attachments
SelectTabByName.xys
(1.84 KiB) Downloaded 113 times

Post Reply