From d896f7bcd4abc845af75779b2ec48b16fb4b77fa Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Mon, 6 Feb 2023 09:48:29 -0600 Subject: [PATCH] add content editable setting, allow non-screen reader users to use accessible buffer (#173322) --- package.json | 4 ++-- remote/package.json | 4 ++-- remote/web/package.json | 2 +- remote/web/yarn.lock | 8 ++++---- remote/yarn.lock | 16 ++++++++-------- src/vs/platform/terminal/common/terminal.ts | 3 ++- .../terminal/browser/terminalActions.ts | 18 ++++++++++-------- .../terminal/browser/terminalInstance.ts | 8 +++++--- .../contrib/terminal/common/terminal.ts | 3 ++- .../terminal/common/terminalConfiguration.ts | 11 +++++++++++ yarn.lock | 16 ++++++++-------- 11 files changed, 55 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 9c0144be009..56577352660 100644 --- a/package.json +++ b/package.json @@ -87,13 +87,13 @@ "vscode-proxy-agent": "^0.12.0", "vscode-regexpp": "^3.1.0", "vscode-textmate": "8.0.0", - "xterm": "5.2.0-beta.24", + "xterm": "5.2.0-beta.26", "xterm-addon-canvas": "0.4.0-beta.7", "xterm-addon-search": "0.11.0", "xterm-addon-serialize": "0.9.0", "xterm-addon-unicode11": "0.5.0", "xterm-addon-webgl": "0.15.0-beta.6", - "xterm-headless": "5.2.0-beta.24", + "xterm-headless": "5.2.0-beta.26", "yauzl": "^2.9.2", "yazl": "^2.4.3" }, diff --git a/remote/package.json b/remote/package.json index 97a4e8e898d..99ecb595840 100644 --- a/remote/package.json +++ b/remote/package.json @@ -24,13 +24,13 @@ "vscode-proxy-agent": "^0.12.0", "vscode-regexpp": "^3.1.0", "vscode-textmate": "8.0.0", - "xterm": "5.2.0-beta.24", + "xterm": "5.2.0-beta.26", "xterm-addon-canvas": "0.4.0-beta.7", "xterm-addon-search": "0.11.0", "xterm-addon-serialize": "0.9.0", "xterm-addon-unicode11": "0.5.0", "xterm-addon-webgl": "0.15.0-beta.6", - "xterm-headless": "5.2.0-beta.24", + "xterm-headless": "5.2.0-beta.26", "yauzl": "^2.9.2", "yazl": "^2.4.3" }, diff --git a/remote/web/package.json b/remote/web/package.json index c1344bb2a54..4cd100c788e 100644 --- a/remote/web/package.json +++ b/remote/web/package.json @@ -11,7 +11,7 @@ "tas-client-umd": "0.1.6", "vscode-oniguruma": "1.7.0", "vscode-textmate": "8.0.0", - "xterm": "5.2.0-beta.24", + "xterm": "5.2.0-beta.26", "xterm-addon-canvas": "0.4.0-beta.7", "xterm-addon-search": "0.11.0", "xterm-addon-unicode11": "0.5.0", diff --git a/remote/web/yarn.lock b/remote/web/yarn.lock index 5ab302d57e0..caeef05781e 100644 --- a/remote/web/yarn.lock +++ b/remote/web/yarn.lock @@ -88,7 +88,7 @@ xterm-addon-webgl@0.15.0-beta.6: resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.15.0-beta.6.tgz#a99233349b9eaec31df798a312906fe73fb3dc33" integrity sha512-PMEkAT4UFL4Ei222uiHPMdVG3fRQAfS5JuZl9FfRVw0V4qMKHvZxBrZELytVfSgLNGBuPu2z7feeZIFEWQGlhA== -xterm@5.2.0-beta.24: - version "5.2.0-beta.24" - resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.24.tgz#a6191457555bc7f0dc1211d2951025cd6c9002fe" - integrity sha512-N/EzDY5LMwj262mEfJMdu30yuYrbyDN3eqr8f+bA3/VywGqvuQLyH+mUNFSwMWUrAriKNVEZF++B6pqJhthHVg== +xterm@5.2.0-beta.26: + version "5.2.0-beta.26" + resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.26.tgz#9b45e481e10ce6c21b34cb36f7c2b2006ec7a136" + integrity sha512-+jp492Ein/xO+nGjZz0CwAYeyUAK5LoH7N1U5w3HGVjYMLZu/Y/Ql5FO+ax/QrrM3Ob+Rw2JNrTuhMQmIZMIMg== diff --git a/remote/yarn.lock b/remote/yarn.lock index a6e2d08129d..efb8280d7aa 100644 --- a/remote/yarn.lock +++ b/remote/yarn.lock @@ -866,15 +866,15 @@ xterm-addon-webgl@0.15.0-beta.6: resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.15.0-beta.6.tgz#a99233349b9eaec31df798a312906fe73fb3dc33" integrity sha512-PMEkAT4UFL4Ei222uiHPMdVG3fRQAfS5JuZl9FfRVw0V4qMKHvZxBrZELytVfSgLNGBuPu2z7feeZIFEWQGlhA== -xterm-headless@5.2.0-beta.24: - version "5.2.0-beta.24" - resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.24.tgz#645ac47ababe44d12925f7a991f5459aef4e654b" - integrity sha512-Hbzb3V8T/HqeHUHKDk1EOPc7BYEhyhTSPTY0/ORwM3dndfhQBHEIRYTBZAA8+5jY3hPwUvyWmYAYO3vqAv61RQ== +xterm-headless@5.2.0-beta.26: + version "5.2.0-beta.26" + resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.26.tgz#6e852a183d6cfb230a7fe19947ed727769dae0bb" + integrity sha512-v961nK3TVzqrRcaSLJStSwoNfiOXRRwxT0+hBTdWpgHAZAMj93oHBWKuG882kPiyT/kqlxzxdNRvpWKI504eSQ== -xterm@5.2.0-beta.24: - version "5.2.0-beta.24" - resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.24.tgz#a6191457555bc7f0dc1211d2951025cd6c9002fe" - integrity sha512-N/EzDY5LMwj262mEfJMdu30yuYrbyDN3eqr8f+bA3/VywGqvuQLyH+mUNFSwMWUrAriKNVEZF++B6pqJhthHVg== +xterm@5.2.0-beta.26: + version "5.2.0-beta.26" + resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.26.tgz#9b45e481e10ce6c21b34cb36f7c2b2006ec7a136" + integrity sha512-+jp492Ein/xO+nGjZz0CwAYeyUAK5LoH7N1U5w3HGVjYMLZu/Y/Ql5FO+ax/QrrM3Ob+Rw2JNrTuhMQmIZMIMg== yallist@^4.0.0: version "4.0.0" diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index 8d7c1fb9b74..7892cd8f582 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -114,7 +114,8 @@ export const enum TerminalSettingId { ShellIntegrationDecorationsEnabled = 'terminal.integrated.shellIntegration.decorationsEnabled', ShellIntegrationCommandHistory = 'terminal.integrated.shellIntegration.history', ShellIntegrationSuggestEnabled = 'terminal.integrated.shellIntegration.suggestEnabled', - SmoothScrolling = 'terminal.integrated.smoothScrolling' + SmoothScrolling = 'terminal.integrated.smoothScrolling', + AccessibleBufferContentEditable = 'terminal.integrated.accessibleBufferContentEditable' } export const enum TerminalLogConstants { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts index 70525883300..b2d0b5d21b3 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalActions.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalActions.ts @@ -408,16 +408,18 @@ export function registerTerminalActions() { registerAction2(class extends Action2 { constructor() { super({ - id: TerminalCommandId.EnterAccessibilityMode, - title: { value: localize('workbench.action.terminal.enterAccessibilityMode', 'Enter Accessibility Mode'), original: 'Enter Accessibility Mode' }, + id: TerminalCommandId.FocusAccessibleBuffer, + title: { value: localize('workbench.action.terminal.focusAccessibleBuffer', 'Focus Accessible Buffer'), original: 'Focus Accessible Buffer' }, f1: true, category, - precondition: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated)), - keybinding: { - primary: KeyMod.Shift | KeyCode.Tab, - weight: KeybindingWeight.WorkbenchContrib, - when: TerminalContextKeys.focus - } + precondition: ContextKeyExpr.or(TerminalContextKeys.processSupported, TerminalContextKeys.terminalHasBeenCreated), + keybinding: [ + { + primary: KeyMod.Shift | KeyCode.Tab, + weight: KeybindingWeight.WorkbenchContrib, + when: ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, TerminalContextKeys.focus) + } + ], }); } async run(accessor: ServicesAccessor): Promise { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 91e398d2bc5..000bc7764e3 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1108,6 +1108,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { if (!this._accessibilityBuffer) { return; } + const accessibleBufferContentEditable = this._configurationService.getValue(TerminalSettingId.AccessibleBufferContentEditable); + this._accessibilityBuffer.contentEditable = accessibleBufferContentEditable === 'on' || (accessibleBufferContentEditable === 'auto' && !this._accessibilityService.isScreenReaderOptimized()) ? 'true' : 'false'; // The viewport is undefined when this is focused, so we cannot get the cell height from that. Instead, estimate using the font. const font = this.xterm.getFont(); const lineHeight = font?.charHeight ? font.charHeight * font.lineHeight + 'px' : ''; @@ -2675,8 +2677,8 @@ export function parseExitResult( } const introMessage = nls.localize('introMsg', "Welcome to Terminal Accessibility Help"); -const enterAccessibilityModeNls = nls.localize('enterAccessibilityMode', 'The Enter Accessibility Mode ({0}) command enables screen readers to read terminal contents.'); -const enterAccessibilityModeNoKb = nls.localize('enterAccessibilityModeNoKb', 'The Enter Accessibility Mode command enables screen readers to read terminal contents and is currently not triggerable by a keybinding.'); +const focusAccessibleBufferNls = nls.localize('focusAccessibleBuffer', 'The Focus Accessible Buffer ({0}) command enables screen readers to read terminal contents.'); +const focusAccessibleBufferNoKb = nls.localize('focusAccessibleBufferNoKb', 'The Focus Accessible Buffer command enables screen readers to read terminal contents and is currently not triggerable by a keybinding.'); const shellIntegration = nls.localize('shellIntegration', "The terminal has a feature called shell integration that offers an enhanced experience and provides useful commands for screen readers such as:"); const runRecentCommand = nls.localize('runRecentCommand', 'Run Recent Command ({0})'); const runRecentCommandNoKb = nls.localize('runRecentCommandNoKb', 'Run Recent Command is currently not triggerable by a keybinding.'); @@ -2749,7 +2751,7 @@ class AccessibilityHelpWidget extends Widget implements ITerminalWidget { private _buildContent(): void { const content = []; - content.push(this._descriptionForCommand(TerminalCommandId.EnterAccessibilityMode, enterAccessibilityModeNls, enterAccessibilityModeNoKb)); + content.push(this._descriptionForCommand(TerminalCommandId.FocusAccessibleBuffer, focusAccessibleBufferNls, focusAccessibleBufferNoKb)); if (this._hasShellIntegration) { content.push(shellIntegration); content.push('- ' + this._descriptionForCommand(TerminalCommandId.RunRecentCommand, runRecentCommand, runRecentCommandNoKb) + '\n- ' + this._descriptionForCommand(TerminalCommandId.GoToRecentDirectory, goToRecent, goToRecentNoKb)); diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index d4e3dd8c3e7..8fe584d95e9 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -253,6 +253,7 @@ export interface ITerminalConfiguration { }; useWslProfiles: boolean; altClickMovesCursor: boolean; + accessibleBufferContentEditable: 'auto' | 'on' | 'off'; macOptionIsMeta: boolean; macOptionClickForcesSelection: boolean; gpuAcceleration: 'auto' | 'on' | 'canvas' | 'off'; @@ -490,7 +491,7 @@ export const enum TerminalCommandId { OpenFileLink = 'workbench.action.terminal.openFileLink', OpenWebLink = 'workbench.action.terminal.openUrlLink', RunRecentCommand = 'workbench.action.terminal.runRecentCommand', - EnterAccessibilityMode = 'workbench.action.terminal.enterAccessibilityMode', + FocusAccessibleBuffer = 'workbench.action.terminal.focusAccessibleBuffer', CopyLastCommandOutput = 'workbench.action.terminal.copyLastCommandOutput', GoToRecentDirectory = 'workbench.action.terminal.goToRecentDirectory', CopyAndClearSelection = 'workbench.action.terminal.copyAndClearSelection', diff --git a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts index 6702e64fe0c..6dbae03ee82 100644 --- a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts +++ b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts @@ -580,6 +580,17 @@ const terminalConfiguration: IConfigurationNode = { type: 'boolean', default: false }, + [TerminalSettingId.AccessibleBufferContentEditable]: { + description: localize('terminal.integrated.accessibleBufferContentEditable', "Controls whether the accessible buffer is marks as a `contenteditable` element. This adds a text cursor to the buffer, allowing selection with the keyboard without a screen reader. Screen reader will typically want to leave this as `'auto'` or `'off'` which will treat the buffer similar to a document."), + type: 'string', + enum: ['auto', 'on', 'off'], + enumDescriptions: [ + localize('accessibleBufferContentEditable.auto', "Automatically enable when a screen reader is not detected."), + localize('accessibleBufferContentEditable.on', "Always on."), + localize('accessibleBufferContentEditable.off', "Always off.") + ], + default: 'auto' + } } }; diff --git a/yarn.lock b/yarn.lock index 2357f52a9df..bcb9c843abc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11728,15 +11728,15 @@ xterm-addon-webgl@0.15.0-beta.6: resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.15.0-beta.6.tgz#a99233349b9eaec31df798a312906fe73fb3dc33" integrity sha512-PMEkAT4UFL4Ei222uiHPMdVG3fRQAfS5JuZl9FfRVw0V4qMKHvZxBrZELytVfSgLNGBuPu2z7feeZIFEWQGlhA== -xterm-headless@5.2.0-beta.24: - version "5.2.0-beta.24" - resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.24.tgz#645ac47ababe44d12925f7a991f5459aef4e654b" - integrity sha512-Hbzb3V8T/HqeHUHKDk1EOPc7BYEhyhTSPTY0/ORwM3dndfhQBHEIRYTBZAA8+5jY3hPwUvyWmYAYO3vqAv61RQ== +xterm-headless@5.2.0-beta.26: + version "5.2.0-beta.26" + resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-5.2.0-beta.26.tgz#6e852a183d6cfb230a7fe19947ed727769dae0bb" + integrity sha512-v961nK3TVzqrRcaSLJStSwoNfiOXRRwxT0+hBTdWpgHAZAMj93oHBWKuG882kPiyT/kqlxzxdNRvpWKI504eSQ== -xterm@5.2.0-beta.24: - version "5.2.0-beta.24" - resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.24.tgz#a6191457555bc7f0dc1211d2951025cd6c9002fe" - integrity sha512-N/EzDY5LMwj262mEfJMdu30yuYrbyDN3eqr8f+bA3/VywGqvuQLyH+mUNFSwMWUrAriKNVEZF++B6pqJhthHVg== +xterm@5.2.0-beta.26: + version "5.2.0-beta.26" + resolved "https://registry.yarnpkg.com/xterm/-/xterm-5.2.0-beta.26.tgz#9b45e481e10ce6c21b34cb36f7c2b2006ec7a136" + integrity sha512-+jp492Ein/xO+nGjZz0CwAYeyUAK5LoH7N1U5w3HGVjYMLZu/Y/Ql5FO+ax/QrrM3Ob+Rw2JNrTuhMQmIZMIMg== y18n@^3.2.1: version "3.2.2"