@@ -40,6 +40,7 @@ class Cut extends React.Component<CutProps, CutState> {
40
40
}
41
41
interface RowProps {
42
42
row : List < Char > ;
43
+ hasCursor : boolean ;
43
44
status : Status ;
44
45
job : Job ;
45
46
}
@@ -48,11 +49,22 @@ const charGrouper = (a: Char, b: Char) => a.attributes === b.attributes;
48
49
49
50
class RowComponent extends React . Component < RowProps , { } > {
50
51
shouldComponentUpdate ( nextProps : RowProps ) {
51
- return this . props . row !== nextProps . row || this . props . status !== nextProps . status ;
52
+ return this . props . row !== nextProps . row ||
53
+ this . props . status !== nextProps . status ||
54
+ this . props . hasCursor !== nextProps . hasCursor ;
52
55
}
53
56
54
57
render ( ) {
55
- const rowWithoutHoles = this . props . row . toArray ( ) . map ( char => char || Char . empty ) ;
58
+ const rowWithoutHoles = this . props . row . toArray ( ) . map ( ( char , index ) => {
59
+ const char2 = char || Char . empty ;
60
+ const attributes = ( this . props . hasCursor && index === this . props . job . screenBuffer . cursorColumn ) ?
61
+ { ...char2 . attributes , cursor : true } :
62
+ char2 . attributes ;
63
+
64
+ return Char . flyweight ( char2 . toString ( ) , attributes ) ;
65
+
66
+ } ) ;
67
+
56
68
const charGroups = groupWhen ( charGrouper , rowWithoutHoles ) . map ( ( charGroup : Char [ ] , index : number ) =>
57
69
< CharGroupComponent job = { this . props . job } group = { charGroup } key = { index } /> ,
58
70
) ;
@@ -78,14 +90,17 @@ export class BufferComponent extends React.Component<Props, State> {
78
90
}
79
91
80
92
render ( ) {
93
+ const buffer = this . props . job . screenBuffer ;
94
+
81
95
return (
82
96
< div className = "output"
83
97
style = { css . output ( this . props . job . screenBuffer . activeScreenBufferType , this . props . job . status ) } >
84
98
{ this . shouldCutOutput ? < Cut job = { this . props . job } clickHandler = { ( ) => this . setState ( { expandButtonPressed : true } ) } /> : undefined }
85
- { this . renderableRows . map ( ( row , index ) =>
99
+ { this . renderableRows . map ( ( row , index : number ) =>
86
100
< RowComponent
87
101
key = { index }
88
102
row = { row || List < Char > ( ) }
103
+ hasCursor = { index === buffer . cursorRow && this . props . job . status === Status . InProgress && ( buffer . _showCursor || buffer . _blinkCursor ) }
89
104
status = { this . props . job . status }
90
105
job = { this . props . job } /> ,
91
106
) }
@@ -98,6 +113,6 @@ export class BufferComponent extends React.Component<Props, State> {
98
113
}
99
114
100
115
private get renderableRows ( ) : List < List < Char > > {
101
- return this . shouldCutOutput ? this . props . job . screenBuffer . toCutRenderable ( this . props . job . status ) : this . props . job . screenBuffer . toRenderable ( this . props . job . status ) ;
116
+ return this . shouldCutOutput ? this . props . job . screenBuffer . toCutRenderable ( ) : this . props . job . screenBuffer . toRenderable ( ) ;
102
117
}
103
118
}
0 commit comments