Options
All
  • Public
  • Public/Protected
  • All
Menu

Module statusbar-extension

Index

Variables

Const STATUSBAR_PLUGIN_ID

STATUSBAR_PLUGIN_ID: "@jupyterlab/statusbar-extension:plugin" = "@jupyterlab/statusbar-extension:plugin"

Const default

default: JupyterFrontEndPlugin<any>[] = [statusBar,lineColItem,kernelStatus,runningSessionsItem,modeSwitch]

Const kernelStatus

kernelStatus: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/statusbar-extension:kernel-status',autoStart: true,requires: [IStatusBar,INotebookTracker,IConsoleTracker,ILabShell,ITranslator],optional: [ISessionContextDialogs],activate: (app: JupyterFrontEnd,statusBar: IStatusBar,notebookTracker: INotebookTracker,consoleTracker: IConsoleTracker,labShell: ILabShell,translator: ITranslator,sessionDialogs: ISessionContextDialogs | null) => {// When the status item is clicked, launch the kernel// selection dialog for the current session.let currentSession: ISessionContext | null = null;const changeKernel = async () => {if (!currentSession) {return;}await (sessionDialogs || sessionContextDialogs).selectKernel(currentSession,translator);};// Create the status item.const item = new KernelStatus({ onClick: changeKernel }, translator);// When the title of the active widget changes, update the label// of the hover text.const onTitleChanged = (title: Title<Widget>) => {item.model!.activityName = title.label;};// Keep the session object on the status item up-to-date.labShell.currentChanged.connect((_, change) => {const { oldValue, newValue } = change;// Clean up after the old value if it exists,// listen for changes to the title of the activityif (oldValue) {oldValue.title.changed.disconnect(onTitleChanged);}if (newValue) {newValue.title.changed.connect(onTitleChanged);}// Grab the session off of the current widget, if it exists.if (newValue && consoleTracker.has(newValue)) {currentSession = (newValue as ConsolePanel).sessionContext;} else if (newValue && notebookTracker.has(newValue)) {currentSession = (newValue as NotebookPanel).sessionContext;} else {currentSession = null;}item.model!.sessionContext = currentSession;});statusBar.registerStatusItem('@jupyterlab/statusbar-extension:kernel-status',{item,align: 'left',rank: 1,isActive: () => {const current = labShell.currentWidget;return (!!current &&(notebookTracker.has(current) || consoleTracker.has(current)));}});}}

A plugin that provides a kernel status item to the status bar.

Const lineColItem

lineColItem: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/statusbar-extension:line-col-status',autoStart: true,requires: [IStatusBar,INotebookTracker,IEditorTracker,IConsoleTracker,ILabShell,ITranslator],activate: (_: JupyterFrontEnd,statusBar: IStatusBar,notebookTracker: INotebookTracker,editorTracker: IEditorTracker,consoleTracker: IConsoleTracker,labShell: ILabShell,translator: ITranslator) => {const item = new LineCol(translator);const onActiveCellChanged = (notebook: Notebook, cell: Cell) => {item.model!.editor = cell && cell.editor;};const onPromptCreated = (console: CodeConsole, prompt: CodeCell) => {item.model!.editor = prompt && prompt.editor;};labShell.currentChanged.connect((_, change) => {const { oldValue, newValue } = change;// Check if we need to disconnect the console listener// or the notebook active cell listenerif (oldValue && consoleTracker.has(oldValue)) {(oldValue as ConsolePanel).console.promptCellCreated.disconnect(onPromptCreated);} else if (oldValue && notebookTracker.has(oldValue)) {(oldValue as NotebookPanel).content.activeCellChanged.disconnect(onActiveCellChanged);}// Wire up the new editor to the model if it existsif (newValue && consoleTracker.has(newValue)) {(newValue as ConsolePanel).console.promptCellCreated.connect(onPromptCreated);const prompt = (newValue as ConsolePanel).console.promptCell;item.model!.editor = prompt && prompt.editor;} else if (newValue && notebookTracker.has(newValue)) {(newValue as NotebookPanel).content.activeCellChanged.connect(onActiveCellChanged);const cell = (newValue as NotebookPanel).content.activeCell;item.model!.editor = cell && cell.editor;} else if (newValue && editorTracker.has(newValue)) {item.model!.editor = (newValue as IDocumentWidget<FileEditor>).content.editor;} else {item.model!.editor = null;}});// Add the status item to the status bar.statusBar.registerStatusItem('@jupyterlab/statusbar-extension:line-col-status',{item,align: 'right',rank: 2,isActive: () => {const current = labShell.currentWidget;return (!!current &&(notebookTracker.has(current) ||editorTracker.has(current) ||consoleTracker.has(current)));}});}}

A plugin providing a line/column status item to the application.

Const runningSessionsItem

runningSessionsItem: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/statusbar-extension:running-sessions-status',autoStart: true,requires: [IStatusBar, ITranslator],activate: (app: JupyterFrontEnd,statusBar: IStatusBar,translator: ITranslator) => {const item = new RunningSessions({onClick: () => app.shell.activateById('jp-running-sessions'),serviceManager: app.serviceManager,translator});statusBar.registerStatusItem('@jupyterlab/statusbar-extension:running-sessions-status',{item,align: 'left',rank: 0});}}

Generated using TypeDoc