Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alert & update help menu when screen reader mode/config changes, give info on this in all help menus #187614

Merged
merged 6 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/vs/editor/common/standaloneStrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ export namespace AccessibilityHelpNLS {
export const editableDiffEditor = nls.localize("editableDiffEditor", "You are in a pane of a diff editor.");
export const readonlyEditor = nls.localize("readonlyEditor", "You are in a read-only code editor");
export const editableEditor = nls.localize("editableEditor", "You are in a code editor");
export const changeConfigToOnMac = nls.localize("changeConfigToOnMac", "To configure the editor to be optimized for usage with a Screen Reader press Command+E now.");
export const changeConfigToOnWinLinux = nls.localize("changeConfigToOnWinLinux", "To configure the editor to be optimized for usage with a Screen Reader press Control+E now.");
export const auto_on = nls.localize("auto_on", "The editor is configured to be optimized for usage with a Screen Reader.");
export const auto_off = nls.localize("auto_off", "The editor is configured to never be optimized for usage with a Screen Reader");
export const changeConfigToOnMac = nls.localize("changeConfigToOnMac", "To configure the application to be optimized for usage with a Screen Reader press Command+E now.");
export const changeConfigToOnWinLinux = nls.localize("changeConfigToOnWinLinux", "To configure the application to be optimized for usage with a Screen Reader press Control+E now.");
export const auto_on = nls.localize("auto_on", "The application is configured to be optimized for usage with a Screen Reader.");
export const auto_off = nls.localize("auto_off", "The application is configured to never be optimized for usage with a Screen Reader");
export const screenReaderModeEnabled = nls.localize("screenReaderModeEnabled", "Screen Reader Optimized Mode enabled.");
export const screenReaderModeDisabled = nls.localize("screenReaderModeDisabled", "Screen Reader Optimized Mode disabled.");
export const tabFocusModeOnMsg = nls.localize("tabFocusModeOnMsg", "Pressing Tab in the current editor will move focus to the next focusable element. Toggle this behavior by pressing {0}.");
export const tabFocusModeOnMsgNoKb = nls.localize("tabFocusModeOnMsgNoKb", "Pressing Tab in the current editor will move focus to the next focusable element. The command {0} is currently not triggerable by a keybinding.");
export const tabFocusModeOffMsg = nls.localize("tabFocusModeOffMsg", "Pressing Tab in the current editor will insert the tab character. Toggle this behavior by pressing {0}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings';
import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/browser/toggleTabFocusMode';
import { localize } from 'vs/nls';
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { AccessibilityHelpAction, AccessibleViewAction, registerAccessibilityConfiguration } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
import { AccessibleViewService, AccessibleViewType, IAccessibleContentProvider, IAccessibleViewOptions, IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
import * as strings from 'vs/base/common/strings';
import * as platform from 'vs/base/common/platform';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
Expand All @@ -29,18 +27,16 @@ import { withNullAsUndefined } from 'vs/base/common/types';
registerAccessibilityConfiguration();
registerSingleton(IAccessibleViewService, AccessibleViewService, InstantiationType.Delayed);

class AccessibilityHelpProvider extends Disposable implements IAccessibleContentProvider {
class AccessibilityHelpProvider implements IAccessibleContentProvider {
onClose() {
this._editor.focus();
this.dispose();
}
options: IAccessibleViewOptions = { type: AccessibleViewType.HelpMenu, ariaLabel: localize('editor-help', "editor accessibility help"), readMoreUrl: 'https://go.microsoft.com/fwlink/?linkid=851010' };
id: string = 'editor';
constructor(
private readonly _editor: ICodeEditor,
@IKeybindingService private readonly _keybindingService: IKeybindingService
) {
super();
}

private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string {
Expand Down Expand Up @@ -69,23 +65,6 @@ class AccessibilityHelpProvider extends Disposable implements IAccessibleContent
}
}

const turnOnMessage = (
platform.isMacintosh
? AccessibilityHelpNLS.changeConfigToOnMac
: AccessibilityHelpNLS.changeConfigToOnWinLinux
);
switch (options.get(EditorOption.accessibilitySupport)) {
case AccessibilitySupport.Unknown:
content.push(turnOnMessage);
break;
case AccessibilitySupport.Enabled:
content.push(AccessibilityHelpNLS.auto_on);
break;
case AccessibilitySupport.Disabled:
content.push(AccessibilityHelpNLS.auto_off, turnOnMessage);
break;
}

if (options.get(EditorOption.tabFocusMode)) {
content.push(this._descriptionForCommand(ToggleTabFocusModeAction.ID, AccessibilityHelpNLS.tabFocusModeOnMsg, AccessibilityHelpNLS.tabFocusModeOnMsgNoKb));
} else {
Expand Down
38 changes: 36 additions & 2 deletions src/vs/workbench/contrib/accessibility/browser/accessibleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { isMacintosh } from 'vs/base/common/platform';
import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
Expand All @@ -15,6 +16,7 @@ import { IModelService } from 'vs/editor/common/services/model';
import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings';
import { LinkDetector } from 'vs/editor/contrib/links/browser/links';
import { localize } from 'vs/nls';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IContextViewDelegate, IContextViewService } from 'vs/platform/contextview/browser/contextView';
Expand Down Expand Up @@ -62,13 +64,16 @@ class AccessibleView extends Disposable {
private _accessiblityHelpIsShown: IContextKey<boolean>;
get editorWidget() { return this._editorWidget; }
private _editorContainer: HTMLElement;
private _currentProvider: IAccessibleContentProvider | undefined;

constructor(
@IOpenerService private readonly _openerService: IOpenerService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IModelService private readonly _modelService: IModelService,
@IContextViewService private readonly _contextViewService: IContextViewService,
@IContextKeyService private readonly _contextKeyService: IContextKeyService
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
) {
super();
this._accessiblityHelpIsShown = accessibilityHelpIsShown.bindTo(this._contextKeyService);
Expand All @@ -92,6 +97,16 @@ class AccessibleView extends Disposable {
fontFamily: 'var(--monaco-monospace-font)'
};
this._editorWidget = this._register(this._instantiationService.createInstance(CodeEditorWidget, this._editorContainer, editorOptions, codeEditorWidgetOptions));
this._register(this._accessibilityService.onDidChangeScreenReaderOptimized(() => {
if (this._currentProvider && this._accessiblityHelpIsShown.get()) {
this.show(this._currentProvider);
}
}));
this._register(this._configurationService.onDidChangeConfiguration(e => {
if (this._currentProvider && this._accessiblityHelpIsShown.get() && e.affectsConfiguration(`accessibility.verbosity.${this._currentProvider.id}`)) {
this.show(this._currentProvider);
}
}));
}

show(provider: IAccessibleContentProvider): void {
Expand All @@ -104,6 +119,7 @@ class AccessibleView extends Disposable {
if (provider.options.type === AccessibleViewType.HelpMenu) {
this._accessiblityHelpIsShown.reset();
}
this._currentProvider = undefined;
}
};
this._contextViewService.showContextView(delegate);
Expand All @@ -113,11 +129,29 @@ class AccessibleView extends Disposable {
}

private _render(provider: IAccessibleContentProvider, container: HTMLElement): IDisposable {
this._currentProvider = provider;
const settingKey = `accessibility.verbosity.${provider.id}`;
const value = this._configurationService.getValue(settingKey);
const readMoreLink = provider.options.readMoreUrl ? localize("openDoc", "\nPress H now to open a browser window with more information related to accessibility.\n") : '';
const disableHelpHint = provider.options.type === AccessibleViewType.HelpMenu && !!value ? localize('disable-help-hint', '\nTo disable the `accessibility.verbosity` hint for this feature, press D now.\n') : '\n';
const fragment = provider.provideContent() + readMoreLink + disableHelpHint + localize('exit-tip', 'Exit this menu via the Escape key.');
const accessibilitySupport = this._accessibilityService.isScreenReaderOptimized();
let message = '';
if (provider.options.type === AccessibleViewType.HelpMenu) {
const turnOnMessage = (
isMacintosh
? AccessibilityHelpNLS.changeConfigToOnMac
: AccessibilityHelpNLS.changeConfigToOnWinLinux
);
if (accessibilitySupport && provider.id === 'editor') {
message = AccessibilityHelpNLS.auto_on;
message += '\n';
} else if (!accessibilitySupport) {
message = AccessibilityHelpNLS.auto_off + '\n' + turnOnMessage;
message += '\n';
}
}

const fragment = message + provider.provideContent() + readMoreLink + disableHelpHint + localize('exit-tip', 'Exit this menu via the Escape key.');

this._getTextModel(URI.from({ path: `accessible-view-${provider.id}`, scheme: 'accessible-view', fragment })).then((model) => {
if (!model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { accessibilityHelpIsShown } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { alert } from 'vs/base/browser/ui/aria/aria';
import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings';

class ToggleScreenReaderMode extends Action2 {

constructor() {
Expand All @@ -30,7 +33,9 @@ class ToggleScreenReaderMode extends Action2 {
async run(accessor: ServicesAccessor): Promise<void> {
const accessibiiltyService = accessor.get(IAccessibilityService);
const configurationService = accessor.get(IConfigurationService);
configurationService.updateValue('editor.accessibilitySupport', accessibiiltyService.isScreenReaderOptimized() ? 'off' : 'on', ConfigurationTarget.USER);
const isScreenReaderOptimized = accessibiiltyService.isScreenReaderOptimized();
configurationService.updateValue('editor.accessibilitySupport', isScreenReaderOptimized ? 'off' : 'on', ConfigurationTarget.USER);
alert(isScreenReaderOptimized ? AccessibilityHelpNLS.screenReaderModeDisabled : AccessibilityHelpNLS.screenReaderModeEnabled);
}
}

Expand Down