66import { createProgram , PROJECTION_MATRIX , throwIfFalsy } from './WebglUtils' ;
77import { WebglCharAtlas } from './atlas/WebglCharAtlas' ;
88import { IWebGL2RenderingContext , IWebGLVertexArrayObject , IRenderModel , IRasterizedGlyph } from './Types' ;
9- import { COMBINED_CHAR_BIT_MASK , RENDER_MODEL_INDICIES_PER_CELL , RENDER_MODEL_FG_OFFSET , RENDER_MODEL_BG_OFFSET } from './RenderModel' ;
109import { fill } from 'common/TypedArrayUtils' ;
11- import { slice } from './TypedArray' ;
12- import { NULL_CELL_CODE , WHITESPACE_CELL_CODE , Attributes , FgFlags } from 'common/buffer/Constants' ;
10+ import { NULL_CELL_CODE } from 'common/buffer/Constants' ;
1311import { Terminal , IBufferLine } from 'xterm' ;
14- import { IColorSet , IColor } from 'browser/Types' ;
12+ import { IColorSet } from 'browser/Types' ;
1513import { IRenderDimensions } from 'browser/renderer/Types' ;
16- import { AttributeData } from 'common/buffer/AttributeData' ;
1714
1815interface IVertices {
1916 attributes : Float32Array ;
@@ -24,7 +21,6 @@ interface IVertices {
2421 * working on the next frame.
2522 */
2623 attributesBuffers : Float32Array [ ] ;
27- selectionAttributes : Float32Array ;
2824 count : number ;
2925}
3026
@@ -91,8 +87,7 @@ export class GlyphRenderer {
9187 attributesBuffers : [
9288 new Float32Array ( 0 ) ,
9389 new Float32Array ( 0 )
94- ] ,
95- selectionAttributes : new Float32Array ( 0 )
90+ ]
9691 } ;
9792
9893 constructor (
@@ -187,6 +182,8 @@ export class GlyphRenderer {
187182 if ( ! this . _atlas ) {
188183 return ;
189184 }
185+
186+ // Get the glyph
190187 if ( chars && chars . length > 1 ) {
191188 rasterizedGlyph = this . _atlas . getRasterizedGlyphCombinedChar ( chars , bg , fg ) ;
192189 } else {
@@ -214,91 +211,6 @@ export class GlyphRenderer {
214211 // a_cellpos only changes on resize
215212 }
216213
217- public updateSelection ( model : IRenderModel ) : void {
218- const terminal = this . _terminal ;
219-
220- this . _vertices . selectionAttributes = slice ( this . _vertices . attributes , 0 ) ;
221-
222- const bg = ( this . _colors . selectionOpaque . rgba >>> 8 ) | Attributes . CM_RGB ;
223-
224- if ( model . selection . columnSelectMode ) {
225- const startCol = model . selection . startCol ;
226- const width = model . selection . endCol - startCol ;
227- const height = model . selection . viewportCappedEndRow - model . selection . viewportCappedStartRow + 1 ;
228- for ( let y = model . selection . viewportCappedStartRow ; y < model . selection . viewportCappedStartRow + height ; y ++ ) {
229- this . _updateSelectionRange ( startCol , startCol + width , y , model , bg ) ;
230- }
231- } else {
232- // Draw first row
233- const startCol = model . selection . viewportStartRow === model . selection . viewportCappedStartRow ? model . selection . startCol : 0 ;
234- const startRowEndCol = model . selection . viewportCappedStartRow === model . selection . viewportCappedEndRow ? model . selection . endCol : terminal . cols ;
235- this . _updateSelectionRange ( startCol , startRowEndCol , model . selection . viewportCappedStartRow , model , bg ) ;
236-
237- // Draw middle rows
238- const middleRowsCount = Math . max ( model . selection . viewportCappedEndRow - model . selection . viewportCappedStartRow - 1 , 0 ) ;
239- for ( let y = model . selection . viewportCappedStartRow + 1 ; y <= model . selection . viewportCappedStartRow + middleRowsCount ; y ++ ) {
240- this . _updateSelectionRange ( 0 , startRowEndCol , y , model , bg ) ;
241- }
242-
243- // Draw final row
244- if ( model . selection . viewportCappedStartRow !== model . selection . viewportCappedEndRow ) {
245- // Only draw viewportEndRow if it's not the same as viewportStartRow
246- const endCol = model . selection . viewportEndRow === model . selection . viewportCappedEndRow ? model . selection . endCol : terminal . cols ;
247- this . _updateSelectionRange ( 0 , endCol , model . selection . viewportCappedEndRow , model , bg ) ;
248- }
249- }
250- }
251-
252- private _updateSelectionRange ( startCol : number , endCol : number , y : number , model : IRenderModel , bg : number ) : void {
253- const terminal = this . _terminal ;
254- const row = y + terminal . buffer . active . viewportY ;
255- let line : IBufferLine | undefined ;
256- for ( let x = startCol ; x < endCol ; x ++ ) {
257- const offset = ( y * this . _terminal . cols + x ) * RENDER_MODEL_INDICIES_PER_CELL ;
258- const code = model . cells [ offset ] ;
259- let fg = model . cells [ offset + RENDER_MODEL_FG_OFFSET ] ;
260- if ( fg & FgFlags . INVERSE ) {
261- const workCell = new AttributeData ( ) ;
262- workCell . fg = fg ;
263- workCell . bg = model . cells [ offset + RENDER_MODEL_BG_OFFSET ] ;
264- // Get attributes from fg (excluding inverse) and resolve inverse by pullibng rgb colors
265- // from bg. This is needed since the inverse fg color should be based on the original bg
266- // color, not on the selection color
267- fg &= ~ ( Attributes . CM_MASK | Attributes . RGB_MASK | FgFlags . INVERSE ) ;
268- switch ( workCell . getBgColorMode ( ) ) {
269- case Attributes . CM_P16 :
270- case Attributes . CM_P256 :
271- const c = this . _getColorFromAnsiIndex ( workCell . getBgColor ( ) ) . rgba ;
272- fg |= ( c >> 8 ) & Attributes . RED_MASK | ( c >> 8 ) & Attributes . GREEN_MASK | ( c >> 8 ) & Attributes . BLUE_MASK ;
273- case Attributes . CM_RGB :
274- const arr = AttributeData . toColorRGB ( workCell . getBgColor ( ) ) ;
275- fg |= arr [ 0 ] << Attributes . RED_SHIFT | arr [ 1 ] << Attributes . GREEN_SHIFT | arr [ 2 ] << Attributes . BLUE_SHIFT ;
276- case Attributes . CM_DEFAULT :
277- default :
278- const c2 = this . _colors . background . rgba ;
279- fg |= ( c2 >> 8 ) & Attributes . RED_MASK | ( c2 >> 8 ) & Attributes . GREEN_MASK | ( c2 >> 8 ) & Attributes . BLUE_MASK ;
280- }
281- fg |= Attributes . CM_RGB ;
282- }
283- if ( code & COMBINED_CHAR_BIT_MASK ) {
284- if ( ! line ) {
285- line = terminal . buffer . active . getLine ( row ) ;
286- }
287- const chars = line ! . getCell ( x ) ! . getChars ( ) ;
288- this . _updateCell ( this . _vertices . selectionAttributes , x , y , model . cells [ offset ] , bg , fg , chars ) ;
289- } else {
290- this . _updateCell ( this . _vertices . selectionAttributes , x , y , model . cells [ offset ] , bg , fg ) ;
291- }
292- }
293- }
294-
295- private _getColorFromAnsiIndex ( idx : number ) : IColor {
296- if ( idx >= this . _colors . ansi . length ) {
297- throw new Error ( 'No color found for idx ' + idx ) ;
298- }
299- return this . _colors . ansi [ idx ] ;
300- }
301-
302214 public clear ( force ?: boolean ) : void {
303215 const terminal = this . _terminal ;
304216 const newCount = terminal . cols * terminal . rows * INDICES_PER_CELL ;
@@ -333,7 +245,7 @@ export class GlyphRenderer {
333245 public setColors ( ) : void {
334246 }
335247
336- public render ( renderModel : IRenderModel , isSelectionVisible : boolean ) : void {
248+ public render ( renderModel : IRenderModel ) : void {
337249 if ( ! this . _atlas ) {
338250 return ;
339251 }
@@ -357,7 +269,7 @@ export class GlyphRenderer {
357269 let bufferLength = 0 ;
358270 for ( let y = 0 ; y < renderModel . lineLengths . length ; y ++ ) {
359271 const si = y * this . _terminal . cols * INDICES_PER_CELL ;
360- const sub = ( isSelectionVisible ? this . _vertices . selectionAttributes : this . _vertices . attributes ) . subarray ( si , si + renderModel . lineLengths [ y ] * INDICES_PER_CELL ) ;
272+ const sub = this . _vertices . attributes . subarray ( si , si + renderModel . lineLengths [ y ] * INDICES_PER_CELL ) ;
361273 activeBuffer . set ( sub , bufferLength ) ;
362274 bufferLength += sub . length ;
363275 }
0 commit comments