Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main(): Promise {
let dock = new DockPanel();
dock.id = 'main';
// Attach the widget to the dom.
Widget.attach(dock, document.body);
// Handle resize events.
window.addEventListener('resize', () => {
dock.fit();
});
const manager = new TerminalManager();
const s1 = await manager.startNew();
const term1 = new Terminal(s1, { theme: 'light' });
term1.title.closable = true;
dock.addWidget(term1);
const s2 = await manager.startNew();
const term2 = new Terminal(s2, { theme: 'dark' });
term2.title.closable = true;
dock.addWidget(term2, { mode: 'tab-before' });
console.log('Example started!');
}
// Attach the widget to the dom.
Widget.attach(dock, document.body);
// Handle resize events.
window.addEventListener('resize', () => {
dock.fit();
});
const manager = new TerminalManager();
const s1 = await manager.startNew();
const term1 = new Terminal(s1, { theme: 'light' });
term1.title.closable = true;
dock.addWidget(term1);
const s2 = await manager.startNew();
const term2 = new Terminal(s2, { theme: 'dark' });
term2.title.closable = true;
dock.addWidget(term2, { mode: 'tab-before' });
console.log('Example started!');
}
private async setupTerminalSession() {
// Abort if somehow no terminals available.
if (!this.app.serviceManager.terminals.isAvailable()) {
// tslint:disable-next-line:no-console
console.log("Disabling jupyterlab_black plugin because lack of terminal access.");
this.loaded = false;
return;
}
this.term = new Terminal();
try {
this.term.session = await this.app.serviceManager.terminals.startNew();
// NOTE: unset HISTFILE so user's shell history is no longer as polluted
// when we dump codecell content though terminal.
this.term.session.send({type: "stdin", content: ["unset HISTFILE\r"]});
this.loaded = true;
// tslint:disable-next-line:no-console
console.log("Terminal session started.", this.term.session.name);
} catch (e) {
this.term.dispose();
this.term = undefined;
this.loaded = false;
}
}
async load_linter(){
// Bail if there are no terminals available.
if (!this.app.serviceManager.terminals.isAvailable()) {
console.log('Disabling jupyterlab-flake8 plugin because it cant access terminal');
this.loaded = false;
this.toggled = false;
return;
}
this.term = new Terminal();
try {
this.term.session = await this.app.serviceManager.terminals.startNew();
console.log('loaded terminal session');
// wait 2 seconds for terminal to load and get initial commands out of its system
setTimeout(() => {
this.check_flake8();
}, 2000)
}
catch(e) {
this.term.dispose();
this.term = undefined;
}
}
function main(): void {
let term1 = new Terminal({ theme: 'light' });
let term2 = new Terminal({ theme: 'dark' });
TerminalSession.startNew().then(session => {
term1.session = session;
});
TerminalSession.startNew().then(session => {
term2.session = session;
});
term1.title.closable = true;
term2.title.closable = true;
let dock = new DockPanel();
dock.addWidget(term1);
dock.addWidget(term2, { mode: 'tab-before' });
dock.id = 'main';
// Attach the widget to the dom.
execute: args => {
let name = args ? args['name'] as string : '';
let term = new Terminal();
term.title.closable = true;
term.title.icon = TERMINAL_ICON_CLASS;
term.title.label = '...';
shell.addToMainArea(term);
let promise = name ?
services.terminals.connectTo(name)
: services.terminals.startNew();
return promise.then(session => {
term.session = session;
tracker.add(term);
shell.activateById(term.id);
return term;
}).catch(() => { term.dispose(); });
}
function main(): void {
let term1 = new Terminal({ theme: 'light' });
let term2 = new Terminal({ theme: 'dark' });
TerminalSession.startNew().then(session => {
term1.session = session;
});
TerminalSession.startNew().then(session => {
term2.session = session;
});
term1.title.closable = true;
term2.title.closable = true;
let dock = new DockPanel();
dock.addWidget(term1);
dock.addWidget(term2, { mode: 'tab-before' });
dock.id = 'main';