@@ -10,6 +10,8 @@ $( () ->
10
10
mainConsole .focus ()
11
11
)
12
12
13
+ $ (' .file' ).live (' click' , expandFile);
14
+
13
15
)
14
16
15
17
processEnv = null
@@ -187,7 +189,8 @@ class Console
187
189
return result
188
190
189
191
clearConsole : ->
190
- $ (' .command-set, .incomplete-command-set' , this .el ).remove ()
192
+ # $('.command-set, .incomplete-command-set', this.el).remove()
193
+ $ (' .output' , this .el ).html (' ' )
191
194
this .scroller .reinitialise ()
192
195
this .scroller .scrollToBottom ()
193
196
this .persist ()
@@ -225,6 +228,8 @@ class Console
225
228
# alt-R
226
229
return false
227
230
231
+ commandRegistry : {}
232
+
228
233
runInputCommand : ->
229
234
inputEl = $ (' input.input' , this .el )
230
235
input = inputEl .val ()
@@ -248,6 +253,13 @@ class Console
248
253
this .writeEl (div)
249
254
parts = node .toArgsNoInterpolate ()
250
255
command = new Command (parts[0 ], parts[1 ... ], this .cwd (), this .env ())
256
+ this .commandRegistry [sym] = command
257
+ filters = commandSet .match (command .command , command)
258
+ if filters .length
259
+ for filter in filters
260
+ if filter .changeCommand
261
+ # # FIXME: should be asyncable
262
+ filter .changeCommand (command)
251
263
command .runCommand (
252
264
callback : this .boundReceiver ,
253
265
id : this .callbackId + ' .' + sym,
@@ -314,6 +326,7 @@ class Console
314
326
p .save (' history' , this .history )
315
327
p .save (' cwd' , this .cwd ())
316
328
p .save (' env' , this .env ())
329
+ p .save (' genSym' , genSym .counter )
317
330
318
331
restore : ->
319
332
p = this .persister
@@ -324,29 +337,57 @@ class Console
324
337
this .scroller .reinitialise ()
325
338
this .scroller .scrollToBottom ()
326
339
this .persistRestored = true
340
+ c = p .get (' genSym' , 0 )
341
+ if c > genSym .counter
342
+ genSym .counter = c
327
343
328
344
dataReceived : (id , data ) ->
329
345
console .log ' data' , id, data
346
+ command = this .commandRegistry [id]
347
+ if command
348
+ filters = commandSet .match (command .command , command)
349
+ else
350
+ filters = []
330
351
if data .stdout ? or data .stderr ?
331
352
if data .stdout ?
332
353
cls = ' stdout'
333
354
else
334
355
cls = ' stderr'
335
- this .write (data .stdout || data .stderr , cls, id)
356
+ matched = false
357
+ if filters .length
358
+ for filter in filters
359
+ # # FIXME: check for .complete
360
+ if data .stdout and filter .filterStdout
361
+ filter .filterStdout (((el ) =>
362
+ this .writeEl (el, id)
363
+ ),
364
+ command,
365
+ data .stdout )
366
+ matched = true
367
+ break
368
+ if data .stderr and filter .filterStderr
369
+ filter .filterStderr (((el ) =>
370
+ this .writeEl (el)
371
+ ),
372
+ command,
373
+ data .stderr )
374
+ matched = true
375
+ break
376
+ if not matched
377
+ this .write (data .stdout || data .stderr , cls, id)
336
378
# Ignore the other stuff
337
379
if data .code ? and id
338
380
el = $ (' #' + id, this .el )
339
381
el .removeClass (' incomplete-command-set' )
340
382
el .addClass (' command-set' )
341
383
el = $ (' .cmd' , el)
342
- if el .attr (' title' ).search (/ pid/ ) != - 1
384
+ if ( el .attr (' title' ) || ' ' ).search (/ pid/ ) != - 1
343
385
title = el .attr (' title' )
344
386
title = title .replace (/ pid\: \s * \d + \s * / , ' ' )
345
387
el .attr (' title' , title)
346
388
this .persistSoon ()
347
389
if data .pid ? and id
348
390
el = $ (' .cmd' , $ (' #' + id, this .el ))
349
- console .log ' el' , el
350
391
el .attr (title : ' pid: ' + data .pid + ' ' + el .attr (' title' ))
351
392
352
393
expandWildcard = (callback , pattern , cwd , env ) ->
@@ -368,7 +409,6 @@ expandWildcard = (callback, pattern, cwd, env) ->
368
409
command .getOutput (
369
410
((stdout , stderr ) ->
370
411
files = stdout .split (' \u 0000' )
371
- console .log ' result' , stdout, files
372
412
doc = new Node (' span' )
373
413
for file in files
374
414
if file .substr (0 , 2 ) == ' ./'
@@ -425,3 +465,7 @@ class Persister
425
465
return JSON .parse (v)
426
466
else
427
467
return defaultValue
468
+
469
+ expandFile = (event ) ->
470
+ # # FIXME: expand to show some more info
471
+ $ (event .target ).css (" background-color" : " #f00" )
0 commit comments