|
@@ -1,14 +1,14 @@
|
|
|
// Copyright (c) Jupyter Development Team.
|
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
-import {
|
|
|
- Kernel, KernelMessage
|
|
|
-} from '@jupyterlab/services';
|
|
|
-
|
|
|
import {
|
|
|
Message
|
|
|
} from '@phosphor/messaging';
|
|
|
|
|
|
+import {
|
|
|
+ Signal
|
|
|
+} from '@phosphor/signaling';
|
|
|
+
|
|
|
import {
|
|
|
Panel, PanelLayout
|
|
|
} from '@phosphor/widgets';
|
|
@@ -29,6 +29,10 @@ import {
|
|
|
IOutputModel, RenderMime
|
|
|
} from '@jupyterlab/rendermime';
|
|
|
|
|
|
+import {
|
|
|
+ Kernel, KernelMessage
|
|
|
+} from '@jupyterlab/services';
|
|
|
+
|
|
|
import {
|
|
|
IOutputAreaModel
|
|
|
} from './model';
|
|
@@ -147,6 +151,15 @@ class OutputArea extends Widget {
|
|
|
return (this.layout as PanelLayout).widgets;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * A public signal used to indicate the number of outputs has changed.
|
|
|
+ *
|
|
|
+ * #### Notes
|
|
|
+ * This is useful for parents who want to apply styling based on the number
|
|
|
+ * of outputs. Emits the current number of outputs.
|
|
|
+ */
|
|
|
+ readonly outputLengthChanged = new Signal<this, number>(this);
|
|
|
+
|
|
|
/**
|
|
|
* Execute code on a client session and handle response messages.
|
|
|
*/
|
|
@@ -172,6 +185,7 @@ class OutputArea extends Widget {
|
|
|
// Make sure there were no input widgets.
|
|
|
if (this.widgets.length) {
|
|
|
this._clear();
|
|
|
+ this.outputLengthChanged.emit(this.model.length);
|
|
|
}
|
|
|
|
|
|
return new Promise<KernelMessage.IExecuteReplyMsg>((resolve, reject) => {
|
|
@@ -201,15 +215,18 @@ class OutputArea extends Widget {
|
|
|
switch (args.type) {
|
|
|
case 'add':
|
|
|
this._insertOutput(args.newIndex, args.newValues[0]);
|
|
|
+ this.outputLengthChanged.emit(this.model.length);
|
|
|
break;
|
|
|
case 'remove':
|
|
|
// Only clear is supported by the model.
|
|
|
if (this.widgets.length) {
|
|
|
this._clear();
|
|
|
+ this.outputLengthChanged.emit(this.model.length);
|
|
|
}
|
|
|
break;
|
|
|
case 'set':
|
|
|
this._setOutput(args.newIndex, args.newValues[0]);
|
|
|
+ this.outputLengthChanged.emit(this.model.length);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|