@@ -13,9 +13,9 @@ import { ITerminalOptions } from 'xterm';
1313import { IDisposable } from 'common/Types' ;
1414
1515export class AccessibleBuffer extends Disposable {
16- private _accessiblityBuffer : HTMLElement ;
17- private _isAccessibilityBufferActive : boolean = false ;
18- public get isAccessibilityBufferActive ( ) : boolean { return this . _isAccessibilityBufferActive ; }
16+ private _element : HTMLElement ;
17+ private _isAccessibleBufferActive : boolean = false ;
18+ public get isAccessibleBufferActive ( ) : boolean { return this . _isAccessibleBufferActive ; }
1919 private _provider : IBufferElementProvider | undefined ;
2020 constructor (
2121 private readonly _terminal : ITerminal ,
@@ -25,34 +25,34 @@ export class AccessibleBuffer extends Disposable {
2525 ) {
2626 super ( ) ;
2727 if ( ! this . _terminal . element ) {
28- throw new Error ( 'Cannot enable accessibility buffer before Terminal.open' ) ;
28+ throw new Error ( 'Cannot enable accessible buffer before Terminal.open' ) ;
2929 }
3030
31- this . _accessiblityBuffer = document . createElement ( 'div' ) ;
32- this . _accessiblityBuffer . setAttribute ( 'role' , 'document' ) ;
33- this . _accessiblityBuffer . ariaRoleDescription = Strings . accessibilityBuffer ;
34- this . _accessiblityBuffer . tabIndex = 0 ;
35- this . _accessiblityBuffer . classList . add ( 'xterm-accessibility -buffer' ) ;
36- this . _terminal . element . insertAdjacentElement ( 'afterbegin' , this . _accessiblityBuffer ) ;
31+ this . _element = document . createElement ( 'div' ) ;
32+ this . _element . setAttribute ( 'role' , 'document' ) ;
33+ this . _element . ariaRoleDescription = Strings . accessibleBuffer ;
34+ this . _element . tabIndex = 0 ;
35+ this . _element . classList . add ( 'xterm-accessible -buffer' ) ;
36+ this . _terminal . element . insertAdjacentElement ( 'afterbegin' , this . _element ) ;
3737
38- this . register ( addDisposableDomListener ( this . _accessiblityBuffer , 'keydown' , ( ev : KeyboardEvent ) => {
38+ this . register ( addDisposableDomListener ( this . _element , 'keydown' , ( ev : KeyboardEvent ) => {
3939 if ( ev . key === 'Tab' ) {
40- this . _isAccessibilityBufferActive = false ;
40+ this . _isAccessibleBufferActive = false ;
4141 }
4242 }
4343 ) ) ;
44- this . register ( addDisposableDomListener ( this . _accessiblityBuffer , 'focus' , ( ) => this . _refreshAccessibilityBuffer ( ) ) ) ;
45- this . register ( addDisposableDomListener ( this . _accessiblityBuffer , 'focusout' , ( e ) => {
46- if ( ! this . _accessiblityBuffer . contains ( e . element ) ) {
47- this . _isAccessibilityBufferActive = false ;
44+ this . register ( addDisposableDomListener ( this . _element , 'focus' , ( ) => this . _refreshAccessibleBuffer ( ) ) ) ;
45+ this . register ( addDisposableDomListener ( this . _element , 'focusout' , ( e ) => {
46+ if ( ! this . _element . contains ( e . element ) ) {
47+ this . _isAccessibleBufferActive = false ;
4848 }
4949 } ) ) ;
5050
5151 this . _handleColorChange ( themeService . colors ) ;
5252 this . register ( themeService . onChangeColors ( e => this . _handleColorChange ( e ) ) ) ;
5353 this . _handleFontOptionChange ( optionsService . options ) ;
5454 this . register ( optionsService . onMultipleOptionChange ( [ 'fontSize' , 'fontFamily' , 'letterSpacing' , 'lineHeight' ] , ( ) => this . _handleFontOptionChange ( optionsService . options ) ) ) ;
55- this . register ( toDisposable ( ( ) => this . _accessiblityBuffer . remove ( ) ) ) ;
55+ this . register ( toDisposable ( ( ) => this . _element . remove ( ) ) ) ;
5656 }
5757
5858 public registerBufferElementProvider ( bufferProvider : IBufferElementProvider ) : IDisposable {
@@ -67,12 +67,12 @@ export class AccessibleBuffer extends Disposable {
6767 } ;
6868 }
6969
70- private _refreshAccessibilityBuffer ( ) : void {
70+ private _refreshAccessibleBuffer ( ) : void {
7171 if ( ! this . _terminal . viewport ) {
7272 return ;
7373 }
74- this . _isAccessibilityBufferActive = true ;
75- this . _accessiblityBuffer . scrollTop = this . _accessiblityBuffer . scrollHeight ;
74+ this . _isAccessibleBufferActive = true ;
75+ this . _element . scrollTop = this . _element . scrollHeight ;
7676 const bufferElements = this . _provider ?. provideBufferElements ( ) ;
7777 if ( ! bufferElements ) {
7878 const { bufferElements } = this . _terminal . viewport . getBufferElements ( 0 ) ;
@@ -81,21 +81,21 @@ export class AccessibleBuffer extends Disposable {
8181 element . textContent = element . textContent . replace ( new RegExp ( ' ' , 'g' ) , '\xA0' ) ;
8282 }
8383 }
84- this . _accessiblityBuffer . replaceChildren ( ...bufferElements ) ;
84+ this . _element . replaceChildren ( ...bufferElements ) ;
8585 } else {
86- this . _accessiblityBuffer . replaceChildren ( bufferElements ) ;
86+ this . _element . replaceChildren ( bufferElements ) ;
8787 }
8888 }
8989
9090 private _handleColorChange ( colorSet : ReadonlyColorSet ) : void {
91- this . _accessiblityBuffer . style . backgroundColor = colorSet . background . css ;
92- this . _accessiblityBuffer . style . color = colorSet . foreground . css ;
91+ this . _element . style . backgroundColor = colorSet . background . css ;
92+ this . _element . style . color = colorSet . foreground . css ;
9393 }
9494
9595 private _handleFontOptionChange ( options : Required < ITerminalOptions > ) : void {
96- this . _accessiblityBuffer . style . fontFamily = options . fontFamily ;
97- this . _accessiblityBuffer . style . fontSize = `${ options . fontSize } px` ;
98- this . _accessiblityBuffer . style . lineHeight = `${ options . lineHeight * ( this . _renderService . dimensions . css . cell . height ) } px` ;
99- this . _accessiblityBuffer . style . letterSpacing = `${ options . letterSpacing } px` ;
96+ this . _element . style . fontFamily = options . fontFamily ;
97+ this . _element . style . fontSize = `${ options . fontSize } px` ;
98+ this . _element . style . lineHeight = `${ options . lineHeight * ( this . _renderService . dimensions . css . cell . height ) } px` ;
99+ this . _element . style . letterSpacing = `${ options . letterSpacing } px` ;
100100 }
101101}
0 commit comments