File tree Expand file tree Collapse file tree 4 files changed +51
-10
lines changed Expand file tree Collapse file tree 4 files changed +51
-10
lines changed Original file line number Diff line number Diff line change 7
7
"test" : " test"
8
8
},
9
9
"dependencies" : {
10
- "bs2-serial" : " ^0.6.0 " ,
10
+ "bs2-serial" : " ^0.7.1 " ,
11
11
"codemirror" : " ^4.13.0" ,
12
12
"frylord" : " ^0.5.0" ,
13
13
"holovisor" : " ^0.2.0" ,
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ function ConsoleBuffer ( options ) {
4
+ var opts = options || { } ;
5
+ this . _length = 0 ;
6
+ this . _text = '' ;
7
+ this . _bufferSize = opts . bufferSize || 2048 ;
8
+ this . _trimOffset = opts . trimOffset || 256 ;
9
+
10
+ if ( this . _bufferSize < 1 ) {
11
+ throw new Error ( 'Invalid buffer length!' ) ;
12
+ }
13
+ if ( this . _trimOffset < 0 || this . _trimOffset >= this . _bufferSize ) {
14
+ throw new Error ( 'Invalid trim offset length!' ) ;
15
+ }
16
+ }
17
+
18
+ ConsoleBuffer . prototype . update = function ( evt ) {
19
+ //assume text events for now
20
+ var text = evt . data || '' ;
21
+ this . _text += text ;
22
+
23
+ if ( this . _text . length > this . _bufferSize ) {
24
+ this . _text = this . _text . substr ( this . _text . length - ( this . _bufferSize - this . _trimOffset ) ) ;
25
+ }
26
+ this . _length = this . _text . length ;
27
+ } ;
28
+
29
+ ConsoleBuffer . prototype . clear = function ( ) {
30
+ this . _length = 0 ;
31
+ this . _text = '' ;
32
+ } ;
33
+
34
+ ConsoleBuffer . prototype . getConsoleHTML = function ( ) {
35
+ return this . _text ;
36
+ } ;
37
+
38
+
39
+ module . exports = ConsoleBuffer ;
Original file line number Diff line number Diff line change @@ -10,27 +10,32 @@ require('codemirror/lib/codemirror.css');
10
10
require ( '../../assets/theme/parallax.css' ) ;
11
11
12
12
var CodeMirror = require ( 'codemirror' ) ;
13
+
13
14
var keyExtension = require ( './key-extension' ) ;
15
+ var ConsoleBuffer = require ( './console-buffer' ) ;
14
16
15
17
require ( './pbasic' ) ( CodeMirror ) ;
16
18
17
19
function editor ( app , opts , done ) {
18
20
19
21
var codeEditor ;
20
22
var outputConsole ;
23
+ var buffer = new ConsoleBuffer ( ) ;
21
24
22
25
var space = app . workspace ;
23
26
24
- function output ( text ) {
27
+ function output ( evt ) {
28
+ buffer . update ( evt ) ;
25
29
if ( outputConsole ) {
26
- outputConsole . innerHTML += text ;
30
+ outputConsole . innerHTML = buffer . getConsoleHTML ( ) ;
27
31
outputConsole . scrollTop = outputConsole . scrollHeight ;
28
32
}
29
33
}
30
34
31
35
function clearOutput ( ) {
36
+ buffer . clear ( ) ;
32
37
if ( outputConsole ) {
33
- outputConsole . innerHTML = '' ;
38
+ outputConsole . innerHTML = buffer . getConsoleHTML ( ) ;
34
39
}
35
40
}
36
41
Original file line number Diff line number Diff line change @@ -59,17 +59,14 @@ class DownloadOverlay extends React.Component {
59
59
60
60
const board = irken . getBoard ( device ) ;
61
61
62
- board . on ( 'progress ', this . updateProgress ) ;
62
+ board . removeListener ( 'terminal ', logger ) ;
63
63
64
- const log = through ( function ( chunk , enc , cb ) {
65
- logger ( chunk . toString ( ) ) ;
66
- cb ( null , chunk ) ;
67
- } ) ;
64
+ board . on ( 'progress' , this . updateProgress ) ;
68
65
69
66
board . compile ( source )
70
67
. tap ( ( ) => logger . clear ( ) )
71
68
. then ( ( memory ) => board . bootload ( memory ) )
72
- . then ( ( ) => board . read ( ) . pipe ( log ) )
69
+ . then ( ( ) => board . on ( 'terminal' , logger ) )
73
70
. tap ( ( ) => toast . clear ( ) )
74
71
. tap ( ( ) => handleSuccess ( `'${ name } ' downloaded successfully` ) )
75
72
. catch ( handleError )
You can’t perform that action at this time.
0 commit comments