Quellcode durchsuchen

Add executed signal to console widget to indicate time of last prompt execution.

Afshin Darian vor 8 Jahren
Ursprung
Commit
3d695aaf90
1 geänderte Dateien mit 13 neuen und 1 gelöschten Zeilen
  1. 13 1
      src/console/widget.ts

+ 13 - 1
src/console/widget.ts

@@ -6,7 +6,7 @@ import {
 } from 'jupyter-js-services';
 
 import {
-  clearSignalData
+  clearSignalData, defineSignal, ISignal
 } from 'phosphor/lib/core/signaling';
 
 import {
@@ -146,6 +146,12 @@ class ConsoleWidget extends Widget {
     });
   }
 
+  /**
+   * A signal emitted when the console executes its prompt.
+   */
+  executed: ISignal<ConsoleWidget, Date>;
+
+
   /**
    * Get the inspection handler used by the console.
    *
@@ -214,6 +220,7 @@ class ConsoleWidget extends Widget {
     this.newPrompt();
     return prompt.execute(this._session.kernel).then(
       (value: KernelMessage.IExecuteReplyMsg) => {
+        this.executed.emit(new Date());
         if (!value) {
           this._inspectionHandler.handleExecuteReply(null);
           return;
@@ -373,6 +380,11 @@ class ConsoleWidget extends Widget {
   private _session: ISession = null;
 }
 
+
+// Define the signals for the `ConsoleWidget` class.
+defineSignal(ConsoleWidget.prototype, 'executed');
+
+
 /**
  * A namespace for ConsoleWidget statics.
  */