11'use babel' ;
22
3- import { CompositeDisposable } from 'atom' ;
3+ import { CompositeDisposable , Disposable } from 'atom' ;
44
55import CodeContextBuilder from './code-context-builder' ;
66import GrammarUtils from './grammar-utils' ;
@@ -63,6 +63,7 @@ export default {
6363 scriptProfileRunView : null ,
6464 scriptOptions : null ,
6565 scriptProfiles : [ ] ,
66+ terminals : [ ] ,
6667
6768 activate ( state ) {
6869 this . scriptView = new ScriptView ( state . scriptViewState ) ;
@@ -85,7 +86,7 @@ export default {
8586
8687 const observer = new ViewRuntimeObserver ( this . scriptView ) ;
8788
88- this . runtime = new Runtime ( runner , codeContextBuilder , [ observer ] ) ;
89+ this . runtime = new Runtime ( runner , codeContextBuilder , [ observer ] , this . terminals ) ;
8990
9091 this . subscriptions = new CompositeDisposable ( ) ;
9192 this . subscriptions . add ( atom . commands . add ( 'atom-workspace' , {
@@ -153,6 +154,7 @@ export default {
153154 this . scriptOptionsView . close ( ) ;
154155 this . scriptProfileRunView . close ( ) ;
155156 this . subscriptions . dispose ( ) ;
157+ this . terminals . length = 0 ;
156158 GrammarUtils . deleteTempFiles ( ) ;
157159 } ,
158160
@@ -161,6 +163,13 @@ export default {
161163 this . scriptView . removePanel ( ) ;
162164 } ,
163165
166+ consumeTerminal ( terminal ) {
167+ this . terminals . push ( terminal ) ;
168+ return new Disposable ( ( ) => {
169+ this . terminals = this . terminals . filter ( ( t ) => t !== terminal ) ;
170+ } ) ;
171+ } ,
172+
164173 // Public
165174 //
166175 // Service method that provides the default runtime that's configurable through Atom editor
@@ -199,7 +208,7 @@ export default {
199208 const runner = new Runner ( new ScriptOptions ( ) ) ;
200209 const codeContextBuilder = new CodeContextBuilder ( ) ;
201210
202- return new Runtime ( runner , codeContextBuilder , [ ] ) ;
211+ return new Runtime ( runner , codeContextBuilder , [ ] , this . terminals ) ;
203212 } ,
204213
205214 serialize ( ) {
0 commit comments