Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/debug/common/debugAccessibilityAnnouncer.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IDebugService } from './debug.js';
7
import { Disposable, IDisposable, MutableDisposable } from '../../../../base/common/lifecycle.js';
8
import { IWorkbenchContribution } from '../../../common/contributions.js';
9
import { ILogService } from '../../../../platform/log/common/log.js';
10
import { IAccessibilityService } from '../../../../platform/accessibility/common/accessibility.js';
11
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
12
import { Expression } from './debugModel.js';
13
14
export class DebugWatchAccessibilityAnnouncer extends Disposable implements IWorkbenchContribution {
15
static ID = 'workbench.contrib.debugWatchAccessibilityAnnouncer';
16
private readonly _listener: MutableDisposable<IDisposable> = this._register(new MutableDisposable());
17
constructor(
18
@IDebugService private readonly _debugService: IDebugService,
19
@ILogService private readonly _logService: ILogService,
20
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
21
@IConfigurationService private readonly _configurationService: IConfigurationService
22
) {
23
super();
24
this._setListener();
25
this._register(_configurationService.onDidChangeConfiguration(e => {
26
if (e.affectsConfiguration('accessibility.debugWatchVariableAnnouncements')) {
27
this._setListener();
28
}
29
}));
30
}
31
32
private _setListener(): void {
33
const value = this._configurationService.getValue('accessibility.debugWatchVariableAnnouncements');
34
if (value && !this._listener.value) {
35
this._listener.value = this._debugService.getModel().onDidChangeWatchExpressionValue((e) => {
36
if (!e || e.value === Expression.DEFAULT_VALUE) {
37
return;
38
}
39
40
// TODO: get user feedback, perhaps setting to configure verbosity + whether value, name, neither, or both are announced
41
this._accessibilityService.alert(`${e.name} = ${e.value}`);
42
this._logService.trace(`debugAccessibilityAnnouncerValueChanged ${e.name} ${e.value}`);
43
});
44
} else {
45
this._listener.clear();
46
}
47
}
48
}
49
50