Skip to content

Commit

Permalink
Merge pull request microsoft#188294 from microsoft/merogge/screen-rea…
Browse files Browse the repository at this point in the history
…der-message

inform screen reader user how to enter optimized mode in editor
  • Loading branch information
meganrogge authored Jul 19, 2023
2 parents 210f6d5 + 9a29bef commit d1177d5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
24 changes: 22 additions & 2 deletions src/vs/editor/browser/controller/textAreaHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { TokenizationRegistry } from 'vs/editor/common/languages';
import { ColorId, ITokenPresentation } from 'vs/editor/common/encodedTokenAttributes';
import { Color } from 'vs/base/common/color';
import { IME } from 'vs/base/common/ime';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';

export interface IVisibleRangeProvider {
visibleRangeForPosition(position: Position): HorizontalPosition | null;
Expand Down Expand Up @@ -140,7 +141,12 @@ export class TextAreaHandler extends ViewPart {
public readonly textAreaCover: FastDomNode<HTMLElement>;
private readonly _textAreaInput: TextAreaInput;

constructor(context: ViewContext, viewController: ViewController, visibleRangeProvider: IVisibleRangeProvider) {
constructor(
context: ViewContext,
viewController: ViewController,
visibleRangeProvider: IVisibleRangeProvider,
@IKeybindingService private readonly _keybindingService: IKeybindingService
) {
super(context);

this._viewController = viewController;
Expand Down Expand Up @@ -553,7 +559,21 @@ export class TextAreaHandler extends ViewPart {
private _getAriaLabel(options: IComputedEditorOptions): string {
const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
if (accessibilitySupport === AccessibilitySupport.Disabled) {
return nls.localize('accessibilityOffAriaLabel', "The editor is not accessible at this time. Press {0} for options.", platform.isLinux ? 'Shift+Alt+F1' : 'Alt+F1');

const toggleKeybindingLabel = this._keybindingService.lookupKeybinding('editor.action.toggleScreenReaderAccessibilityMode')?.getAriaLabel();
const runCommandKeybindingLabel = this._keybindingService.lookupKeybinding('workbench.action.showCommands')?.getAriaLabel();
const keybindingEditorKeybindingLabel = this._keybindingService.lookupKeybinding('workbench.action.openGlobalKeybindings')?.getAriaLabel();
const editorNotAccessibleMessage = nls.localize('accessibilityModeOff', "The editor is not accessible at this time.");
if (toggleKeybindingLabel) {
return nls.localize('accessibilityOffAriaLabel', "{0} To enable screen reader optimized mode, use {1}", editorNotAccessibleMessage, toggleKeybindingLabel);
} else if (runCommandKeybindingLabel) {
return nls.localize('accessibilityOffAriaLabelNoKb', "{0} To enable screen reader optimized mode, open the quick pick with {1} and run the command Toggle Screen Reader Accessibility Mode, which is currently not triggerable via keyboard.", editorNotAccessibleMessage, runCommandKeybindingLabel);
} else if (keybindingEditorKeybindingLabel) {
return nls.localize('accessibilityOffAriaLabelNoKbs', "{0} Please assign a keybinding for the command Toggle Screen Reader Accessibility Mode by accessing the keybindings editor with {1} and run it.", editorNotAccessibleMessage, keybindingEditorKeybindingLabel);
} else {
// SOS
return editorNotAccessibleMessage;
}
}
return options.get(EditorOption.ariaLabel);
}
Expand Down
6 changes: 4 additions & 2 deletions src/vs/editor/browser/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { WhitespaceOverlay } from 'vs/editor/browser/viewParts/whitespace/whitespace';
import { GlyphMarginWidgets } from 'vs/editor/browser/viewParts/glyphMargin/glyphMargin';
import { GlyphMarginLane } from 'vs/editor/common/model';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';


export interface IContentWidgetData {
Expand Down Expand Up @@ -106,7 +107,8 @@ export class View extends ViewEventHandler {
colorTheme: IColorTheme,
model: IViewModel,
userInputEvents: ViewUserInputEvents,
overflowWidgetsDomNode: HTMLElement | undefined
overflowWidgetsDomNode: HTMLElement | undefined,
@IInstantiationService private readonly _instantiationService: IInstantiationService
) {
super();
this._selections = [new Selection(1, 1, 1, 1)];
Expand All @@ -123,7 +125,7 @@ export class View extends ViewEventHandler {
this._viewParts = [];

// Keyboard handler
this._textAreaHandler = new TextAreaHandler(this._context, viewController, this._createTextAreaHandlerHelper());
this._textAreaHandler = this._instantiationService.createInstance(TextAreaHandler, this._context, viewController, this._createTextAreaHandlerHelper());
this._viewParts.push(this._textAreaHandler);

// These two dom nodes must be constructed up front, since references are needed in the layout provider (scrolling & co.)
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/browser/widget/codeEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
this._themeService.getColorTheme(),
viewModel,
viewUserInputEvents,
this._overflowWidgetsDomNode
this._overflowWidgetsDomNode,
this._instantiationService
);

return [view, true];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ class ToggleScreenReaderMode extends Action2 {
id: 'editor.action.toggleScreenReaderAccessibilityMode',
title: { value: nls.localize('toggleScreenReaderMode', "Toggle Screen Reader Accessibility Mode"), original: 'Toggle Screen Reader Accessibility Mode' },
f1: true,
keybinding: {
keybinding: [{
primary: KeyMod.CtrlCmd | KeyCode.KeyE,
weight: KeybindingWeight.WorkbenchContrib + 10,
when: accessibilityHelpIsShown
}
},
{
primary: KeyMod.Alt | KeyCode.F3,
weight: KeybindingWeight.WorkbenchContrib + 10,
}]
});
}

Expand Down

0 comments on commit d1177d5

Please sign in to comment.