提交 00a2a235 编写于 作者: D Daniel Imms

Initial terminal screen reader support

Part of 8339
上级 dee4d63d
......@@ -72,6 +72,13 @@ declare module 'vscode-xterm' {
*/
rows?: number;
/**
* Whether screen reader support is enabled. When on this will expose
* supporting elements in the DOM to support NVDA on Windows and VoiceOver
* on macOS.
*/
screenReaderMode?: boolean;
/**
* The amount of scrollback in the terminal. Scrollback is the amount of rows
* that are retained when lines are scrolled beyond the initial viewport.
......
......@@ -337,6 +337,12 @@ export interface ITerminalInstance {
*/
updateConfig(): void;
/**
* Updates the accessibility support state of the terminal instance.
* @param isEnabled Whether it's enabled.
*/
updateAccessibilitySupport(isEnabled: boolean): void;
/**
* Configure the dimensions of the terminal instance.
*
......
......@@ -12,6 +12,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITerminalService, ITerminalInstance, IShellLaunchConfig, ITerminalConfigHelper, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, TERMINAL_PANEL_ID } from 'vs/workbench/parts/terminal/common/terminal';
import { TPromise } from 'vs/base/common/winjs.base';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
export abstract class TerminalService implements ITerminalService {
public _serviceBrand: any;
......@@ -63,6 +64,9 @@ export abstract class TerminalService implements ITerminalService {
if (e.affectsConfiguration('terminal.integrated')) {
this.updateConfig();
}
if (e.affectsConfiguration('editor.accessibilitySupport')) {
this.updateAccessibilitySupport();
}
});
lifecycleService.onWillShutdown(event => event.veto(this._onWillShutdown()));
lifecycleService.onShutdown(() => this._onShutdown());
......@@ -240,6 +244,11 @@ export abstract class TerminalService implements ITerminalService {
this.terminalInstances.forEach(instance => instance.updateConfig());
}
public updateAccessibilitySupport(): void {
const isEnabled = this._configurationService.getValue<IEditorOptions>('editor').accessibilitySupport === 'on';
this.terminalInstances.forEach(instance => instance.updateAccessibilitySupport(isEnabled));
}
public setWorkspaceShellAllowed(isAllowed: boolean): void {
this.configHelper.setWorkspaceShellAllowed(isAllowed);
}
......
......@@ -126,3 +126,24 @@
.xterm:not(.enable-mouse-events) {
cursor: text;
}
.xterm .accessibility {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 100;
}
.xterm .accessibility-tree {
color: transparent;
}
.xterm .live-region {
position: absolute;
left: -9999px;
width: 1px;
height: 1px;
overflow: hidden;
}
......@@ -37,6 +37,8 @@ import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_FOREGROUND_CO
import { PANEL_BACKGROUND } from 'vs/workbench/common/theme';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
/** The amount of time to consider terminal errors to be related to the launch */
const LAUNCHING_DURATION = 500;
......@@ -125,7 +127,8 @@ export class TerminalInstance implements ITerminalInstance {
@IHistoryService private _historyService: IHistoryService,
@IThemeService private _themeService: IThemeService,
@IConfigurationResolverService private _configurationResolverService: IConfigurationResolverService,
@IWorkspaceContextService private _workspaceContextService: IWorkspaceContextService
@IWorkspaceContextService private _workspaceContextService: IWorkspaceContextService,
@IConfigurationService private _configurationService: IConfigurationService
) {
this._instanceDisposables = [];
this._processDisposables = [];
......@@ -260,6 +263,7 @@ export class TerminalInstance implements ITerminalInstance {
// Enable the winpty compatibility addon which will simulate wraparound mode
Terminal.applyAddon(require.__$__nodeRequire('vscode-xterm/lib/addons/winptyCompat/winptyCompat'));
}
const accessibilitySupport = this._configurationService.getValue<IEditorOptions>('editor').accessibilitySupport;
const font = this._configHelper.getFont(true);
this._xterm = new Terminal({
scrollback: this._configHelper.config.scrollback,
......@@ -268,7 +272,8 @@ export class TerminalInstance implements ITerminalInstance {
fontSize: font.fontSize,
lineHeight: font.lineHeight,
enableBold: this._configHelper.config.enableBold,
bellStyle: this._configHelper.config.enableBell ? 'sound' : 'none'
bellStyle: this._configHelper.config.enableBell ? 'sound' : 'none',
screenReaderMode: accessibilitySupport === 'on'
});
if (this._shellLaunchConfig.initialText) {
this._xterm.writeln(this._shellLaunchConfig.initialText);
......@@ -963,6 +968,10 @@ export class TerminalInstance implements ITerminalInstance {
this._setEnableBell(this._configHelper.config.enableBell);
}
public updateAccessibilitySupport(isEnabled: boolean): void {
this._xterm.setOption('screenReaderMode', isEnabled);
}
private _setCursorBlink(blink: boolean): void {
if (this._xterm && this._xterm.getOption('cursorBlink') !== blink) {
this._xterm.setOption('cursorBlink', blink);
......
......@@ -5808,9 +5808,9 @@ vscode-textmate@^3.2.0:
fast-plist "^0.1.2"
oniguruma "^6.0.1"
vscode-xterm@3.0.0-beta4:
version "3.0.0-beta4"
resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.0.0-beta4.tgz#011b580c3ac91181ed70d46a8a33a63a84a17938"
vscode-xterm@3.0.0-beta8:
version "3.0.0-beta8"
resolved "https://registry.yarnpkg.com/vscode-xterm/-/vscode-xterm-3.0.0-beta8.tgz#7e7d5f399d76992e07e5099aea9a1732ad40f7c1"
vso-node-api@^6.1.2-preview:
version "6.1.2-preview"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册