Browse Source

added commands to move to next/prev tab bar in shell

qntnrbns 5 years ago
parent
commit
77a6557d3b

+ 10 - 0
packages/application-extension/schema/main.json

@@ -13,6 +13,16 @@
       "keys": ["Ctrl Shift ["],
       "selector": "body"
     },
+    {
+      "command": "application:activate-next-tab-bar",
+      "keys": ["Ctrl Shift ."],
+      "selector": "body"
+    },
+    {
+      "command": "application:activate-previous-tab-bar",
+      "keys": ["Ctrl Shift ,"],
+      "selector": "body"
+    },
     {
       "command": "application:close",
       "keys": ["Alt W"],

+ 21 - 0
packages/application-extension/src/index.tsx

@@ -46,6 +46,11 @@ namespace CommandIDs {
   export const activatePreviousTab: string =
     'application:activate-previous-tab';
 
+  export const activateNextTabBar: string = 'application:activate-next-tab-bar';
+
+  export const activatePreviousTabBar: string =
+    'application:activate-previous-tab-bar';
+
   export const close = 'application:close';
 
   export const closeOtherTabs = 'application:close-other-tabs';
@@ -551,6 +556,22 @@ function addCommands(app: JupyterLab, palette: ICommandPalette): void {
   });
   palette.addItem({ command: CommandIDs.activatePreviousTab, category });
 
+  commands.addCommand(CommandIDs.activateNextTabBar, {
+    label: 'Activate Next Tab Bar',
+    execute: () => {
+      shell.activateNextTabBar();
+    }
+  });
+  palette.addItem({ command: CommandIDs.activateNextTabBar, category });
+
+  commands.addCommand(CommandIDs.activatePreviousTabBar, {
+    label: 'Activate Previous Tab Bar',
+    execute: () => {
+      shell.activatePreviousTabBar();
+    }
+  });
+  palette.addItem({ command: CommandIDs.activatePreviousTabBar, category });
+
   // A CSS selector targeting tabs in the main area. This is a very
   // specific selector since we really only want tabs that are
   // in the main area, as opposed to those in sidebars, ipywidgets, etc.

+ 24 - 0
packages/application/src/shell.ts

@@ -499,6 +499,30 @@ export class LabShell extends Widget implements JupyterFrontEnd.IShell {
     }
   }
 
+  /*
+   * Activate the next TabBar.
+   */
+  activateNextTabBar(): void {
+    let nextBar = this._adjacentBar('next');
+    if (nextBar) {
+      if (nextBar.currentTitle) {
+        nextBar.currentTitle.owner.activate();
+      }
+    }
+  }
+
+  /*
+   * Activate the next TabBar.
+   */
+  activatePreviousTabBar(): void {
+    let nextBar = this._adjacentBar('previous');
+    if (nextBar) {
+      if (nextBar.currentTitle) {
+        nextBar.currentTitle.owner.activate();
+      }
+    }
+  }
+
   add(
     widget: Widget,
     area: ILabShell.Area = 'main',

+ 2 - 0
packages/mainmenu-extension/src/index.ts

@@ -723,6 +723,8 @@ export function createTabsMenu(
     [
       { command: 'application:activate-next-tab' },
       { command: 'application:activate-previous-tab' },
+      { command: 'application:activate-next-tab-bar' },
+      { command: 'application:activate-previous-tab-bar' },
       { command: CommandIDs.activatePreviouslyUsedTab }
     ],
     0