|
@@ -1,6 +1,10 @@
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
|
|
+import {
|
|
|
|
+ find
|
|
|
|
+} from 'phosphor/lib/algorithm/searching';
|
|
|
|
+
|
|
import {
|
|
import {
|
|
Menu
|
|
Menu
|
|
} from 'phosphor/lib/ui/menu';
|
|
} from 'phosphor/lib/ui/menu';
|
|
@@ -59,6 +63,7 @@ function activateTerminal(app: JupyterLab, services: IServiceManager, mainMenu:
|
|
let increaseTerminalFontSize = 'terminal:increase-font';
|
|
let increaseTerminalFontSize = 'terminal:increase-font';
|
|
let decreaseTerminalFontSize = 'terminal:decrease-font';
|
|
let decreaseTerminalFontSize = 'terminal:decrease-font';
|
|
let toggleTerminalTheme = 'terminal:toggle-theme';
|
|
let toggleTerminalTheme = 'terminal:toggle-theme';
|
|
|
|
+ let openTerminalId = 'terminal:open';
|
|
|
|
|
|
let tracker = new WidgetTracker<TerminalWidget>();
|
|
let tracker = new WidgetTracker<TerminalWidget>();
|
|
let options = {
|
|
let options = {
|
|
@@ -70,13 +75,14 @@ function activateTerminal(app: JupyterLab, services: IServiceManager, mainMenu:
|
|
commands.addCommand(newTerminalId, {
|
|
commands.addCommand(newTerminalId, {
|
|
label: 'New Terminal',
|
|
label: 'New Terminal',
|
|
caption: 'Start a new terminal session',
|
|
caption: 'Start a new terminal session',
|
|
- execute: () => {
|
|
|
|
|
|
+ execute: args => {
|
|
|
|
+ let name = args ? args['name'] as string : '';
|
|
let term = new TerminalWidget(options);
|
|
let term = new TerminalWidget(options);
|
|
term.title.closable = true;
|
|
term.title.closable = true;
|
|
term.title.icon = `${LANDSCAPE_ICON_CLASS} ${TERMINAL_ICON_CLASS}`;
|
|
term.title.icon = `${LANDSCAPE_ICON_CLASS} ${TERMINAL_ICON_CLASS}`;
|
|
app.shell.addToMainArea(term);
|
|
app.shell.addToMainArea(term);
|
|
tracker.addWidget(term);
|
|
tracker.addWidget(term);
|
|
- services.terminals.create().then(session => {
|
|
|
|
|
|
+ services.terminals.create({ name }).then(session => {
|
|
term.session = session;
|
|
term.session = session;
|
|
// Trigger an update of the running kernels.
|
|
// Trigger an update of the running kernels.
|
|
services.terminals.listRunning();
|
|
services.terminals.listRunning();
|
|
@@ -127,6 +133,19 @@ function activateTerminal(app: JupyterLab, services: IServiceManager, mainMenu:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ commands.addCommand(openTerminalId, {
|
|
|
|
+ execute: args => {
|
|
|
|
+ let name = args['name'] as string;
|
|
|
|
+ // Check for a running terminal with the given name.
|
|
|
|
+ let widget = find(tracker.widgets, value => value.session.name === name);
|
|
|
|
+ if (widget) {
|
|
|
|
+ app.shell.activateMain(widget.id);
|
|
|
|
+ } else {
|
|
|
|
+ // Otherwise, create a new terminal with a given name.
|
|
|
|
+ commands.execute(newTerminalId, { name });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
let category = 'Terminal';
|
|
let category = 'Terminal';
|
|
[
|
|
[
|