Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands to move to next/prev tab bar in shell #7673

Merged
merged 1 commit into from Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/application-extension/schema/main.json
Expand Up @@ -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"],
Expand Down
21 changes: 21 additions & 0 deletions packages/application-extension/src/index.tsx
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions packages/application/src/shell.ts
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions packages/mainmenu-extension/src/index.ts
Expand Up @@ -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
Expand Down