Skip to content

Commit fafa7ef

Browse files
authored
Merge pull request #3941 from Tyriar/v5_bell
Remove bell settings and sound service in favor of Terminal.onBell
2 parents ceeb858 + 841cd63 commit fafa7ef

File tree

10 files changed

+18
-173
lines changed

10 files changed

+18
-173
lines changed

demo/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ function initOptions(term: TerminalType): void {
324324
'windowOptions'
325325
];
326326
const stringOptions = {
327-
bellSound: null,
328-
bellStyle: ['none', 'sound'],
329327
cursorStyle: ['block', 'underline', 'bar'],
330328
fastScrollModifier: ['alt', 'ctrl', 'shift', undefined],
331329
fontFamily: null,

src/browser/Terminal.ts

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { SelectionService } from 'browser/services/SelectionService';
3434
import * as Browser from 'common/Platform';
3535
import { addDisposableDomListener } from 'browser/Lifecycle';
3636
import * as Strings from 'browser/LocalizableStrings';
37-
import { SoundService } from 'browser/services/SoundService';
3837
import { MouseZoneManager } from 'browser/MouseZoneManager';
3938
import { AccessibilityManager } from './AccessibilityManager';
4039
import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider, IDecorationOptions, IDecoration } from 'xterm';
@@ -45,7 +44,7 @@ import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
4544
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
4645
import { ColorManager } from 'browser/ColorManager';
4746
import { RenderService } from 'browser/services/RenderService';
48-
import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService, ICharacterJoinerService } from 'browser/services/Services';
47+
import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ICoreBrowserService, ICharacterJoinerService } from 'browser/services/Services';
4948
import { CharSizeService } from 'browser/services/CharSizeService';
5049
import { IBuffer } from 'common/buffer/Types';
5150
import { MouseService } from 'browser/services/MouseService';
@@ -89,7 +88,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
8988
private _renderService: IRenderService | undefined;
9089
private _characterJoinerService: ICharacterJoinerService | undefined;
9190
private _selectionService: ISelectionService | undefined;
92-
private _soundService: ISoundService | undefined;
9391

9492
/**
9593
* Records whether the keydown event has already been handled and triggered a data event, if so
@@ -174,7 +172,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
174172
this._instantiationService.setService(IDecorationService, this._decorationService);
175173

176174
// Setup InputHandler listeners
177-
this.register(this._inputHandler.onRequestBell(() => this.bell()));
175+
this.register(this._inputHandler.onRequestBell(() => this._onBell.fire()));
178176
this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)));
179177
this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus()));
180178
this.register(this._inputHandler.onRequestReset(() => this.reset()));
@@ -537,8 +535,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
537535
// Performance: Add viewport and helper elements from the fragment
538536
this.element.appendChild(fragment);
539537

540-
this._soundService = this._instantiationService.createInstance(SoundService);
541-
this._instantiationService.setService(ISoundService, this._soundService);
542538
this._mouseService = this._instantiationService.createInstance(MouseService);
543539
this._instantiationService.setService(IMouseService, this._mouseService);
544540

@@ -1285,26 +1281,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
12851281
return false;
12861282
}
12871283

1288-
/**
1289-
* Ring the bell.
1290-
* Note: We could do sweet things with webaudio here
1291-
*/
1292-
public bell(): void {
1293-
if (this._soundBell()) {
1294-
this._soundService?.playBellSound();
1295-
}
1296-
1297-
this._onBell.fire();
1298-
1299-
// if (this._visualBell()) {
1300-
// this.element.classList.add('visual-bell-active');
1301-
// clearTimeout(this._visualBellTimer);
1302-
// this._visualBellTimer = window.setTimeout(() => {
1303-
// this.element.classList.remove('visual-bell-active');
1304-
// }, 200);
1305-
// }
1306-
}
1307-
13081284
/**
13091285
* Resizes the terminal.
13101286
*
@@ -1422,18 +1398,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
14221398
ev.stopPropagation();
14231399
return false;
14241400
}
1425-
1426-
private _visualBell(): boolean {
1427-
return false;
1428-
// return this.options.bellStyle === 'visual' ||
1429-
// this.options.bellStyle === 'both';
1430-
}
1431-
1432-
private _soundBell(): boolean {
1433-
return this.options.bellStyle === 'sound';
1434-
// return this.options.bellStyle === 'sound' ||
1435-
// this.options.bellStyle === 'both';
1436-
}
14371401
}
14381402

14391403
/**

src/browser/public/Terminal.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,19 @@ export class Terminal implements ITerminalApi {
241241
public paste(data: string): void {
242242
this._core.paste(data);
243243
}
244-
public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
245-
public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean;
244+
public getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
245+
public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord'): boolean;
246246
public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
247247
public getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight;
248248
public getOption(key: string): any;
249249
public getOption(key: any): any {
250250
return this._core.optionsService.getOption(key);
251251
}
252-
public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
252+
public setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
253253
public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
254254
public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void;
255-
public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;
256255
public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;
257-
public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void;
256+
public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord', value: boolean): void;
258257
public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
259258
public setOption(key: 'theme', value: ITheme): void;
260259
public setOption(key: 'cols' | 'rows', value: number): void;

src/browser/services/Services.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ export interface ISelectionService {
105105
isCellInSelection(x: number, y: number): boolean;
106106
}
107107

108-
export const ISoundService = createDecorator<ISoundService>('SoundService');
109-
export interface ISoundService {
110-
serviceBrand: undefined;
111-
112-
playBellSound(): void;
113-
}
114-
115-
116108
export const ICharacterJoinerService = createDecorator<ICharacterJoinerService>('CharacterJoinerService');
117109
export interface ICharacterJoinerService {
118110
serviceBrand: undefined;

src/browser/services/SoundService.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/common/services/OptionsService.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,13 @@ import { EventEmitter, IEvent } from 'common/EventEmitter';
88
import { isMac } from 'common/Platform';
99
import { CursorStyle } from 'common/Types';
1010

11-
// Source: https://freesound.org/people/altemark/sounds/45759/
12-
// This sound is released under the Creative Commons Attribution 3.0 Unported
13-
// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been
14-
// made, apart from the conversion to base64.
15-
export const DEFAULT_BELL_SOUND = 'data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq';
16-
1711
export const DEFAULT_OPTIONS: Readonly<ITerminalOptions> = {
1812
cols: 80,
1913
rows: 24,
2014
cursorBlink: false,
2115
cursorStyle: 'block',
2216
cursorWidth: 1,
2317
customGlyphs: true,
24-
bellSound: DEFAULT_BELL_SOUND,
25-
bellStyle: 'none',
2618
drawBoldTextInBrightColors: true,
2719
fastScrollModifier: 'alt',
2820
fastScrollSensitivity: 5,
@@ -132,7 +124,6 @@ export class OptionsService implements IOptionsService {
132124
throw new Error(`"${value}" is not a valid value for ${key}`);
133125
}
134126
break;
135-
case 'bellStyle':
136127
case 'cursorStyle':
137128
case 'rendererType':
138129
case 'wordSeparator':

src/common/services/Services.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ export interface ITerminalOptions {
212212
allowProposedApi: boolean;
213213
allowTransparency: boolean;
214214
altClickMovesCursor: boolean;
215-
bellSound: string;
216-
bellStyle: 'none' | 'sound' /* | 'visual' | 'both' */;
217215
cols: number;
218216
convertEol: boolean;
219217
cursorBlink: boolean;

src/headless/public/Terminal.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,18 @@ export class Terminal implements ITerminalApi {
179179
this._core.write(data);
180180
this._core.write('\r\n', callback);
181181
}
182-
public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
183-
public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean;
182+
public getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
183+
public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord'): boolean;
184184
public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
185185
public getOption(key: string): any;
186186
public getOption(key: any): any {
187187
return this._core.optionsService.getOption(key);
188188
}
189-
public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
189+
public setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
190190
public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
191191
public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void;
192-
public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void;
193192
public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void;
194-
public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void;
193+
public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord', value: boolean): void;
195194
public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
196195
public setOption(key: 'cols' | 'rows', value: number): void;
197196
public setOption(key: string, value: any): void;

typings/xterm-headless.d.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ declare module 'xterm-headless' {
3838
*/
3939
altClickMovesCursor?: boolean;
4040

41-
/**
42-
* A data uri of the sound to use for the bell when `bellStyle = 'sound'`.
43-
*/
44-
bellSound?: string;
45-
46-
/**
47-
* The type of the bell notification the terminal will use.
48-
*/
49-
bellStyle?: 'none' | 'sound';
50-
5141
/**
5242
* When enabled the cursor will be set to the beginning of the next line
5343
* with every new line. This is equivalent to sending '\r\n' for each '\n'.
@@ -723,12 +713,12 @@ declare module 'xterm-headless' {
723713
* Retrieves an option's value from the terminal.
724714
* @param key The option key.
725715
*/
726-
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
716+
getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
727717
/**
728718
* Retrieves an option's value from the terminal.
729719
* @param key The option key.
730720
*/
731-
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean;
721+
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode'): boolean;
732722
/**
733723
* Retrieves an option's value from the terminal.
734724
* @param key The option key.
@@ -745,7 +735,7 @@ declare module 'xterm-headless' {
745735
* @param key The option key.
746736
* @param value The option value.
747737
*/
748-
setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
738+
setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
749739
/**
750740
* Sets an option on the terminal.
751741
* @param key The option key.
@@ -758,12 +748,6 @@ declare module 'xterm-headless' {
758748
* @param value The option value.
759749
*/
760750
setOption(key: 'logLevel', value: LogLevel): void;
761-
/**
762-
* Sets an option on the terminal.
763-
* @param key The option key.
764-
* @param value The option value.
765-
*/
766-
setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void;
767751
/**
768752
* Sets an option on the terminal.
769753
* @param key The option key.
@@ -775,7 +759,7 @@ declare module 'xterm-headless' {
775759
* @param key The option key.
776760
* @param value The option value.
777761
*/
778-
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void;
762+
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode', value: boolean): void;
779763
/**
780764
* Sets an option on the terminal.
781765
* @param key The option key.

typings/xterm.d.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ declare module 'xterm' {
5050
*/
5151
altClickMovesCursor?: boolean;
5252

53-
/**
54-
* A data uri of the sound to use for the bell when `bellStyle = 'sound'`.
55-
*/
56-
bellSound?: string;
57-
58-
/**
59-
* The type of the bell notification the terminal will use.
60-
*/
61-
bellStyle?: 'none' | 'sound';
62-
6353
/**
6454
* When enabled the cursor will be set to the beginning of the next line
6555
* with every new line. This is equivalent to sending '\r\n' for each '\n'.
@@ -1128,13 +1118,13 @@ declare module 'xterm' {
11281118
* @param key The option key.
11291119
* @deprecated Use `options` instead.
11301120
*/
1131-
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
1121+
getOption(key: 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
11321122
/**
11331123
* Retrieves an option's value from the terminal.
11341124
* @param key The option key.
11351125
* @deprecated Use `options` instead.
11361126
*/
1137-
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean;
1127+
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode'): boolean;
11381128
/**
11391129
* Retrieves an option's value from the terminal.
11401130
* @param key The option key.
@@ -1160,7 +1150,7 @@ declare module 'xterm' {
11601150
* @param value The option value.
11611151
* @deprecated Use `options` instead.
11621152
*/
1163-
setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
1153+
setOption(key: 'fontFamily' | 'termName' | 'wordSeparator', value: string): void;
11641154
/**
11651155
* Sets an option on the terminal.
11661156
* @param key The option key.
@@ -1175,13 +1165,6 @@ declare module 'xterm' {
11751165
* @deprecated Use `options` instead.
11761166
*/
11771167
setOption(key: 'logLevel', value: LogLevel): void;
1178-
/**
1179-
* Sets an option on the terminal.
1180-
* @param key The option key.
1181-
* @param value The option value.
1182-
* @deprecated Use `options` instead.
1183-
*/
1184-
setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void;
11851168
/**
11861169
* Sets an option on the terminal.
11871170
* @param key The option key.
@@ -1195,7 +1178,7 @@ declare module 'xterm' {
11951178
* @param value The option value.
11961179
* @deprecated Use `options` instead.
11971180
*/
1198-
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void;
1181+
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'windowsMode', value: boolean): void;
11991182
/**
12001183
* Sets an option on the terminal.
12011184
* @param key The option key.

0 commit comments

Comments
 (0)