Browse Source

work in progress

Afshin Darian 8 years ago
parent
commit
03c462bedf
3 changed files with 44 additions and 2 deletions
  1. 4 0
      src/tooltip/index.css
  2. 31 0
      src/tooltip/index.ts
  3. 9 2
      src/tooltip/plugin.ts

+ 4 - 0
src/tooltip/index.css

@@ -5,4 +5,8 @@
 
 .jp-Tooltip {
   background: var(--jp-info-color0);
+  border: 1px solid red;
+  min-width: 200px;
+  min-height: 200px;
+  z-index: 10001;
 }

+ 31 - 0
src/tooltip/index.ts

@@ -1,6 +1,10 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+import {
+  Kernel
+} from '@jupyterlab/services';
+
 import {
   Message
 } from 'phosphor/lib/core/messaging';
@@ -31,6 +35,7 @@ class TooltipWidget extends Widget {
   constructor(options: TooltipWidget.IOptions) {
     super();
     this.editor = options.editor;
+    this.kernel = options.kernel;
     this.addClass(TOOLTIP_CLASS);
   }
 
@@ -39,13 +44,34 @@ class TooltipWidget extends Widget {
    */
   readonly editor: CodeEditor.IEditor;
 
+  /**
+   * The kernel for the tooltip widget.
+   */
+  readonly kernel: Kernel.IKernel;
+
   /**
    * Handle `'activate-request'` messages.
    */
   protected onActivateRequest(msg: Message): void {
+    console.log('activate-request');
     this.node.tabIndex = -1;
     this.node.focus();
   }
+
+  /**
+   * Handle `'after-attach'` messages.
+   */
+  protected onAfterAttach(msg: Message): void {
+    console.log('after-attach');
+  }
+
+  /**
+   * Handle `'update-request'` messages.
+   */
+  protected onUpdateRequest(msg: Message): void {
+    console.log('update-request');
+    super.onUpdateRequest(msg);
+  }
 }
 
 /**
@@ -62,5 +88,10 @@ namespace TooltipWidget {
      * The editor referent of the tooltip widget.
      */
     editor: CodeEditor.IEditor;
+
+    /**
+     * The kernel for the tooltip widget.
+     */
+    kernel: Kernel.IKernel;
   }
 }

+ 9 - 2
src/tooltip/plugin.ts

@@ -1,6 +1,10 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
+import {
+  Kernel
+} from '@jupyterlab/services';
+
 import {
   Widget
 } from 'phosphor/lib/ui/widget';
@@ -58,23 +62,26 @@ function activate(app: JupyterLab, consoles: IConsoleTracker, notebooks: INotebo
   registry.addCommand(launch, {
     execute: args => {
       let notebook = args['notebook'] as boolean;
-      let editor: CodeEditor.IEditor | null = null;
+      let editor: CodeEditor.IEditor = null;
+      let kernel: Kernel.IKernel = null;
       if (notebook) {
         let widget = notebooks.currentWidget;
         if (widget) {
           editor = widget.notebook.activeCell.editor;
+          kernel = widget.kernel;
         }
       } else {
         let widget = consoles.currentWidget;
         if (widget) {
           editor = widget.console.prompt.editor;
+          kernel = widget.console.session.kernel;
         }
       }
       if (tooltip) {
         tooltip.dispose();
       }
       if (editor) {
-        tooltip = new TooltipWidget({ editor });
+        tooltip = new TooltipWidget({ editor, kernel });
         tooltip.id = `tooltip-${++id}`;
         Widget.attach(tooltip, document.body);
         tooltip.activate();