55import { NULL_CELL_CHAR , NULL_CELL_WIDTH , NULL_CELL_CODE , DEFAULT_ATTR , Content , UnderlineStyle , BgFlags , Attributes , FgFlags } from 'common/buffer/Constants' ;
66import { BufferLine } from 'common/buffer//BufferLine' ;
77import { CellData } from 'common/buffer/CellData' ;
8- import { CharData , IBufferLine } from '../Types' ;
8+ import { CharData , IBufferLine , IExtendedAttrs } from '../Types' ;
99import { assert } from 'chai' ;
1010import { AttributeData } from 'common/buffer/AttributeData' ;
1111import { createCellData , NULL_CELL_DATA } from 'common/TestUtils.test' ;
@@ -25,6 +25,12 @@ class TestBufferLine extends BufferLine {
2525 }
2626}
2727
28+ function extendedAttributes ( line : IBufferLine , index : number ) : IExtendedAttrs | undefined {
29+ const cell = new CellData ( ) ;
30+ line . loadCell ( index , cell ) ;
31+ return cell . hasExtendedAttrs ( ) !== 0 ? cell . extended : undefined ;
32+ }
33+
2834describe ( 'AttributeData' , ( ) => {
2935 describe ( 'extended attributes' , ( ) => {
3036 it ( 'hasExtendedAttrs' , ( ) => {
@@ -632,15 +638,15 @@ describe('BufferLine', function(): void {
632638 [ 1 , 'A' , 1 , 'A' . charCodeAt ( 0 ) ] ,
633639 [ 1 , 'A' , 1 , 'A' . charCodeAt ( 0 ) ]
634640 ] ) ;
635- assert . equal ( ( line as any ) . _extendedAttrs [ 0 ] , undefined ) ;
636- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] . underlineStyle , UnderlineStyle . CURLY ) ;
637- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] . underlineStyle , UnderlineStyle . CURLY ) ;
638- assert . equal ( ( line as any ) . _extendedAttrs [ 3 ] . underlineStyle , UnderlineStyle . DOTTED ) ;
639- assert . equal ( ( line as any ) . _extendedAttrs [ 4 ] , undefined ) ;
641+ assert . equal ( extendedAttributes ( line , 0 ) , undefined ) ;
642+ assert . equal ( extendedAttributes ( line , 1 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
643+ assert . equal ( extendedAttributes ( line , 2 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
644+ assert . equal ( extendedAttributes ( line , 3 ) ? .underlineStyle , UnderlineStyle . DOTTED ) ;
645+ assert . equal ( extendedAttributes ( line , 4 ) ?. underlineStyle , undefined ) ;
640646 // should be ref to the same object
641- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] , ( line as any ) . _extendedAttrs [ 2 ] ) ;
647+ assert . equal ( extendedAttributes ( line , 1 ) , extendedAttributes ( line , 2 ) ) ;
642648 // should be a different obj
643- assert . notEqual ( ( line as any ) . _extendedAttrs [ 1 ] , ( line as any ) . _extendedAttrs [ 3 ] ) ;
649+ assert . notEqual ( extendedAttributes ( line , 1 ) , extendedAttributes ( line , 3 ) ) ;
644650 } ) ;
645651 it ( 'loadCell' , ( ) => {
646652 const line = new TestBufferLine ( 5 ) ;
@@ -691,27 +697,27 @@ describe('BufferLine', function(): void {
691697 cell . extended . underlineStyle = UnderlineStyle . CURLY ;
692698 cell . bg |= BgFlags . HAS_EXTENDED ;
693699 line . fill ( cell ) ;
694- assert . equal ( ( line as any ) . _extendedAttrs [ 0 ] . underlineStyle , UnderlineStyle . CURLY ) ;
695- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] . underlineStyle , UnderlineStyle . CURLY ) ;
696- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] . underlineStyle , UnderlineStyle . CURLY ) ;
700+ assert . equal ( extendedAttributes ( line , 0 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
701+ assert . equal ( extendedAttributes ( line , 1 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
702+ assert . equal ( extendedAttributes ( line , 2 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
697703 } ) ;
698704 it ( 'insertCells' , ( ) => {
699705 const line = new TestBufferLine ( 5 ) ;
700706 const cell = createCellData ( 1 , 'a' , 1 ) ;
701707 cell . extended . underlineStyle = UnderlineStyle . CURLY ;
702708 cell . bg |= BgFlags . HAS_EXTENDED ;
703709 line . insertCells ( 1 , 3 , cell ) ;
704- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] . underlineStyle , UnderlineStyle . CURLY ) ;
705- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] . underlineStyle , UnderlineStyle . CURLY ) ;
706- assert . equal ( ( line as any ) . _extendedAttrs [ 3 ] . underlineStyle , UnderlineStyle . CURLY ) ;
707- assert . equal ( ( line as any ) . _extendedAttrs [ 4 ] , undefined ) ;
710+ assert . equal ( extendedAttributes ( line , 1 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
711+ assert . equal ( extendedAttributes ( line , 2 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
712+ assert . equal ( extendedAttributes ( line , 3 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
713+ assert . equal ( extendedAttributes ( line , 4 ) , undefined ) ;
708714 cell . extended = cell . extended . clone ( ) ;
709715 cell . extended . underlineStyle = UnderlineStyle . DOTTED ;
710716 line . insertCells ( 2 , 2 , cell ) ;
711- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] . underlineStyle , UnderlineStyle . CURLY ) ;
712- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] . underlineStyle , UnderlineStyle . DOTTED ) ;
713- assert . equal ( ( line as any ) . _extendedAttrs [ 3 ] . underlineStyle , UnderlineStyle . DOTTED ) ;
714- assert . equal ( ( line as any ) . _extendedAttrs [ 4 ] . underlineStyle , UnderlineStyle . CURLY ) ;
717+ assert . equal ( extendedAttributes ( line , 1 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
718+ assert . equal ( extendedAttributes ( line , 2 ) ? .underlineStyle , UnderlineStyle . DOTTED ) ;
719+ assert . equal ( extendedAttributes ( line , 3 ) ? .underlineStyle , UnderlineStyle . DOTTED ) ;
720+ assert . equal ( extendedAttributes ( line , 4 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
715721 } ) ;
716722 it ( 'deleteCells' , ( ) => {
717723 const line = new TestBufferLine ( 5 ) ;
@@ -722,11 +728,11 @@ describe('BufferLine', function(): void {
722728 fillCell . extended = fillCell . extended . clone ( ) ;
723729 fillCell . extended . underlineStyle = UnderlineStyle . DOUBLE ;
724730 line . deleteCells ( 1 , 3 , fillCell ) ;
725- assert . equal ( ( line as any ) . _extendedAttrs [ 0 ] . underlineStyle , UnderlineStyle . CURLY ) ;
726- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] . underlineStyle , UnderlineStyle . CURLY ) ;
727- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] . underlineStyle , UnderlineStyle . DOUBLE ) ;
728- assert . equal ( ( line as any ) . _extendedAttrs [ 3 ] . underlineStyle , UnderlineStyle . DOUBLE ) ;
729- assert . equal ( ( line as any ) . _extendedAttrs [ 4 ] . underlineStyle , UnderlineStyle . DOUBLE ) ;
731+ assert . equal ( extendedAttributes ( line , 0 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
732+ assert . equal ( extendedAttributes ( line , 1 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
733+ assert . equal ( extendedAttributes ( line , 2 ) ? .underlineStyle , UnderlineStyle . DOUBLE ) ;
734+ assert . equal ( extendedAttributes ( line , 3 ) ? .underlineStyle , UnderlineStyle . DOUBLE ) ;
735+ assert . equal ( extendedAttributes ( line , 4 ) ? .underlineStyle , UnderlineStyle . DOUBLE ) ;
730736 } ) ;
731737 it ( 'replaceCells' , ( ) => {
732738 const line = new TestBufferLine ( 5 ) ;
@@ -737,11 +743,11 @@ describe('BufferLine', function(): void {
737743 fillCell . extended = fillCell . extended . clone ( ) ;
738744 fillCell . extended . underlineStyle = UnderlineStyle . DOUBLE ;
739745 line . replaceCells ( 1 , 3 , fillCell ) ;
740- assert . equal ( ( line as any ) . _extendedAttrs [ 0 ] . underlineStyle , UnderlineStyle . CURLY ) ;
741- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] . underlineStyle , UnderlineStyle . DOUBLE ) ;
742- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] . underlineStyle , UnderlineStyle . DOUBLE ) ;
743- assert . equal ( ( line as any ) . _extendedAttrs [ 3 ] . underlineStyle , UnderlineStyle . CURLY ) ;
744- assert . equal ( ( line as any ) . _extendedAttrs [ 4 ] . underlineStyle , UnderlineStyle . CURLY ) ;
746+ assert . equal ( extendedAttributes ( line , 0 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
747+ assert . equal ( extendedAttributes ( line , 1 ) ? .underlineStyle , UnderlineStyle . DOUBLE ) ;
748+ assert . equal ( extendedAttributes ( line , 2 ) ? .underlineStyle , UnderlineStyle . DOUBLE ) ;
749+ assert . equal ( extendedAttributes ( line , 3 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
750+ assert . equal ( extendedAttributes ( line , 4 ) ? .underlineStyle , UnderlineStyle . CURLY ) ;
745751 } ) ;
746752 it ( 'clone' , ( ) => {
747753 const line = new TestBufferLine ( 5 ) ;
@@ -768,11 +774,11 @@ describe('BufferLine', function(): void {
768774 line . setCell ( 4 , cell ) ;
769775
770776 const nLine = line . clone ( ) ;
771- assert . equal ( ( nLine as any ) . _extendedAttrs [ 0 ] , ( line as any ) . _extendedAttrs [ 0 ] ) ;
772- assert . equal ( ( nLine as any ) . _extendedAttrs [ 1 ] , ( line as any ) . _extendedAttrs [ 1 ] ) ;
773- assert . equal ( ( nLine as any ) . _extendedAttrs [ 2 ] , ( line as any ) . _extendedAttrs [ 2 ] ) ;
774- assert . equal ( ( nLine as any ) . _extendedAttrs [ 3 ] , ( line as any ) . _extendedAttrs [ 3 ] ) ;
775- assert . equal ( ( nLine as any ) . _extendedAttrs [ 4 ] , ( line as any ) . _extendedAttrs [ 4 ] ) ;
777+ assert . equal ( extendedAttributes ( nLine , 0 ) , extendedAttributes ( line , 0 ) ) ;
778+ assert . equal ( extendedAttributes ( nLine , 1 ) , extendedAttributes ( line , 1 ) ) ;
779+ assert . equal ( extendedAttributes ( nLine , 2 ) , extendedAttributes ( line , 2 ) ) ;
780+ assert . equal ( extendedAttributes ( nLine , 3 ) , extendedAttributes ( line , 3 ) ) ;
781+ assert . equal ( extendedAttributes ( nLine , 4 ) , extendedAttributes ( line , 4 ) ) ;
776782 } ) ;
777783 it ( 'copyFrom' , ( ) => {
778784 const initial = new TestBufferLine ( 5 ) ;
@@ -801,11 +807,11 @@ describe('BufferLine', function(): void {
801807 const line = new TestBufferLine ( 5 ) ;
802808 line . fill ( createCellData ( 1 , 'b' , 1 ) ) ;
803809 line . copyFrom ( initial ) ;
804- assert . equal ( ( line as any ) . _extendedAttrs [ 0 ] , ( initial as any ) . _extendedAttrs [ 0 ] ) ;
805- assert . equal ( ( line as any ) . _extendedAttrs [ 1 ] , ( initial as any ) . _extendedAttrs [ 1 ] ) ;
806- assert . equal ( ( line as any ) . _extendedAttrs [ 2 ] , ( initial as any ) . _extendedAttrs [ 2 ] ) ;
807- assert . equal ( ( line as any ) . _extendedAttrs [ 3 ] , ( initial as any ) . _extendedAttrs [ 3 ] ) ;
808- assert . equal ( ( line as any ) . _extendedAttrs [ 4 ] , ( initial as any ) . _extendedAttrs [ 4 ] ) ;
810+ assert . equal ( extendedAttributes ( line , 0 ) , extendedAttributes ( initial , 0 ) ) ;
811+ assert . equal ( extendedAttributes ( line , 1 ) , extendedAttributes ( initial , 1 ) ) ;
812+ assert . equal ( extendedAttributes ( line , 2 ) , extendedAttributes ( initial , 2 ) ) ;
813+ assert . equal ( extendedAttributes ( line , 3 ) , extendedAttributes ( initial , 3 ) ) ;
814+ assert . equal ( extendedAttributes ( line , 4 ) , extendedAttributes ( initial , 4 ) ) ;
809815 } ) ;
810816 } ) ;
811817} ) ;
0 commit comments