@@ -136,7 +136,10 @@ export class XTermElement extends LitElement implements TerminalMixin {
136136 terminal : Terminal ;
137137 disabled : boolean = false ;
138138 node : XTermElement ;
139-
139+
140+ bellSound : string ;
141+ bellStyle : 'none' | 'sound'
142+
140143 customKeyEventHandlers : CustomKeyEventHandlerRegistry ;
141144
142145 render ( ) : TemplateResult {
@@ -150,6 +153,12 @@ export class XTermElement extends LitElement implements TerminalMixin {
150153 this . customKeyEventHandlers = new CustomKeyEventHandlerRegistry ( ) ;
151154 this . terminal = new Terminal ( ) ;
152155 this . node = this ;
156+
157+ //https://gist.github.com/literallylara/7ece1983fab47365108c47119afb51c7
158+ //(C) Lara Sophie Schütt 2016, CC0
159+ for ( var i = 44100 * 0.1 , d = "" ; i -- ; ) d += String . fromCharCode ( ~ ~ ( ( Math . sin ( i / 44100 * 2 * Math . PI * 800 ) + 1 ) * 128 ) ) ;
160+ this . bellSound = "data:Audio/WAV;base64," + btoa ( "RIFFdataWAVEfmt " + atob ( "EAAAAAEAAQBErAAARKwAAAEACABkYXRh/////w==" ) + d ) ;
161+ this . bellStyle = 'none' ;
153162 }
154163
155164 connectedCallback ( ) {
@@ -163,11 +172,12 @@ export class XTermElement extends LitElement implements TerminalMixin {
163172 term . onData ( e => {
164173 term . write ( e . replace ( / \r / g, '\x1b[<N\n' ) ) ;
165174 } ) ;
166-
167- //https://gist.github.com/literallylara/7ece1983fab47365108c47119afb51c7
168- //(C) Lara Sophie Schütt 2016, CC0
169- for ( var i = 44100 * 0.1 , d = "" ; i -- ; ) d += String . fromCharCode ( ~ ~ ( ( Math . sin ( i / 44100 * 2 * Math . PI * 800 ) + 1 ) * 128 ) ) ;
170- term . options . bellSound = "data:Audio/WAV;base64," + btoa ( "RIFFdataWAVEfmt " + atob ( "EAAAAAEAAQBErAAARKwAAAEACABkYXRh/////w==" ) + d ) ;
175+
176+ term . onBell ( ( ) => {
177+ if ( this . bellStyle == 'sound' ) {
178+ new Audio ( this . bellSound ) . play ( ) ;
179+ }
180+ } ) ;
171181
172182 term . attachCustomKeyEventHandler ( ev => {
173183 if ( ev . type !== 'keydown' ) return false ;
0 commit comments