@@ -22,8 +22,7 @@ export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
22
22
* - scroll position
23
23
*/
24
24
export class Buffer implements IBuffer {
25
- private _lines : CircularList < LineData > ;
26
-
25
+ public lines : CircularList < LineData > ;
27
26
public ydisp : number ;
28
27
public ybase : number ;
29
28
public y : number ;
@@ -48,10 +47,6 @@ export class Buffer implements IBuffer {
48
47
this . clear ( ) ;
49
48
}
50
49
51
- public get lines ( ) : CircularList < LineData > {
52
- return this . _lines ;
53
- }
54
-
55
50
public get hasScrollback ( ) : boolean {
56
51
return this . _hasScrollback && this . lines . maxLength > this . _terminal . rows ;
57
52
}
@@ -81,7 +76,7 @@ export class Buffer implements IBuffer {
81
76
* Fills the buffer's viewport with blank lines.
82
77
*/
83
78
public fillViewportRows ( ) : void {
84
- if ( this . _lines . length === 0 ) {
79
+ if ( this . lines . length === 0 ) {
85
80
let i = this . _terminal . rows ;
86
81
while ( i -- ) {
87
82
this . lines . push ( this . _terminal . blankLine ( ) ) ;
@@ -97,7 +92,7 @@ export class Buffer implements IBuffer {
97
92
this . ybase = 0 ;
98
93
this . y = 0 ;
99
94
this . x = 0 ;
100
- this . _lines = new CircularList < LineData > ( this . _getCorrectBufferLength ( this . _terminal . rows ) ) ;
95
+ this . lines = new CircularList < LineData > ( this . _getCorrectBufferLength ( this . _terminal . rows ) ) ;
101
96
this . scrollTop = 0 ;
102
97
this . scrollBottom = this . _terminal . rows - 1 ;
103
98
this . setupTabStops ( ) ;
@@ -112,19 +107,19 @@ export class Buffer implements IBuffer {
112
107
// Increase max length if needed before adjustments to allow space to fill
113
108
// as required.
114
109
const newMaxLength = this . _getCorrectBufferLength ( newRows ) ;
115
- if ( newMaxLength > this . _lines . maxLength ) {
116
- this . _lines . maxLength = newMaxLength ;
110
+ if ( newMaxLength > this . lines . maxLength ) {
111
+ this . lines . maxLength = newMaxLength ;
117
112
}
118
113
119
114
// The following adjustments should only happen if the buffer has been
120
115
// initialized/filled.
121
- if ( this . _lines . length > 0 ) {
116
+ if ( this . lines . length > 0 ) {
122
117
// Deal with columns increasing (we don't do anything when columns reduce)
123
118
if ( this . _terminal . cols < newCols ) {
124
119
const ch : CharData = [ this . _terminal . defAttr , ' ' , 1 , 32 ] ; // does xterm use the default attr?
125
- for ( let i = 0 ; i < this . _lines . length ; i ++ ) {
126
- while ( this . _lines . get ( i ) . length < newCols ) {
127
- this . _lines . get ( i ) . push ( ch ) ;
120
+ for ( let i = 0 ; i < this . lines . length ; i ++ ) {
121
+ while ( this . lines . get ( i ) . length < newCols ) {
122
+ this . lines . get ( i ) . push ( ch ) ;
128
123
}
129
124
}
130
125
}
@@ -133,8 +128,8 @@ export class Buffer implements IBuffer {
133
128
let addToY = 0 ;
134
129
if ( this . _terminal . rows < newRows ) {
135
130
for ( let y = this . _terminal . rows ; y < newRows ; y ++ ) {
136
- if ( this . _lines . length < newRows + this . ybase ) {
137
- if ( this . ybase > 0 && this . _lines . length <= this . ybase + this . y + addToY + 1 ) {
131
+ if ( this . lines . length < newRows + this . ybase ) {
132
+ if ( this . ybase > 0 && this . lines . length <= this . ybase + this . y + addToY + 1 ) {
138
133
// There is room above the buffer and there are no empty elements below the line,
139
134
// scroll up
140
135
this . ybase -- ;
@@ -146,16 +141,16 @@ export class Buffer implements IBuffer {
146
141
} else {
147
142
// Add a blank line if there is no buffer left at the top to scroll to, or if there
148
143
// are blank lines after the cursor
149
- this . _lines . push ( this . _terminal . blankLine ( undefined , undefined , newCols ) ) ;
144
+ this . lines . push ( this . _terminal . blankLine ( undefined , undefined , newCols ) ) ;
150
145
}
151
146
}
152
147
}
153
148
} else { // (this._terminal.rows >= newRows)
154
149
for ( let y = this . _terminal . rows ; y > newRows ; y -- ) {
155
- if ( this . _lines . length > newRows + this . ybase ) {
156
- if ( this . _lines . length > this . ybase + this . y + 1 ) {
150
+ if ( this . lines . length > newRows + this . ybase ) {
151
+ if ( this . lines . length > this . ybase + this . y + 1 ) {
157
152
// The line is a blank line below the cursor, remove it
158
- this . _lines . pop ( ) ;
153
+ this . lines . pop ( ) ;
159
154
} else {
160
155
// The line is the cursor, scroll down
161
156
this . ybase ++ ;
@@ -167,15 +162,15 @@ export class Buffer implements IBuffer {
167
162
168
163
// Reduce max length if needed after adjustments, this is done after as it
169
164
// would otherwise cut data from the bottom of the buffer.
170
- if ( newMaxLength < this . _lines . maxLength ) {
165
+ if ( newMaxLength < this . lines . maxLength ) {
171
166
// Trim from the top of the buffer and adjust ybase and ydisp.
172
- const amountToTrim = this . _lines . length - newMaxLength ;
167
+ const amountToTrim = this . lines . length - newMaxLength ;
173
168
if ( amountToTrim > 0 ) {
174
- this . _lines . trimStart ( amountToTrim ) ;
169
+ this . lines . trimStart ( amountToTrim ) ;
175
170
this . ybase = Math . max ( this . ybase - amountToTrim , 0 ) ;
176
171
this . ydisp = Math . max ( this . ydisp - amountToTrim , 0 ) ;
177
172
}
178
- this . _lines . maxLength = newMaxLength ;
173
+ this . lines . maxLength = newMaxLength ;
179
174
}
180
175
181
176
// Make sure that the cursor stays on screen
@@ -310,7 +305,7 @@ export class Buffer implements IBuffer {
310
305
public addMarker ( y : number ) : Marker {
311
306
const marker = new Marker ( y ) ;
312
307
this . markers . push ( marker ) ;
313
- marker . disposables . push ( this . _lines . addDisposableListener ( 'trim' , amount => {
308
+ marker . disposables . push ( this . lines . addDisposableListener ( 'trim' , amount => {
314
309
marker . line -= amount ;
315
310
// The marker should be disposed when the line is trimmed from the buffer
316
311
if ( marker . line < 0 ) {
0 commit comments