提交 09582828 编写于 作者: B Benjamin Pasero

Editors: announce currently edited document to screen readers (fixes #2526)

上级 bf60fdf0
......@@ -137,12 +137,16 @@ export class StringEditor extends BaseTextEditor {
options.readOnly = isReadonly;
let ariaLabel: string;
let inputName = input && input.getName();
if (isReadonly) {
options.ariaLabel = nls.localize('readonlyEditorAriaLabel', "Readonly text editor");
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text editor.");
} else {
options.ariaLabel = nls.localize('untitledFileEditorAriaLabel', "Untitled file text editor");
ariaLabel = inputName ? nls.localize('untitledFileEditorWithInputAriaLabel', "{0}. Untitled file text editor.", inputName) : nls.localize('untitledFileEditorAriaLabel', "Untitled file text editor.");
}
options.ariaLabel = ariaLabel;
return options;
}
......
......@@ -210,11 +210,15 @@ export class TextDiffEditor extends BaseTextEditor {
options.readOnly = readOnly;
let ariaLabel: string;
let inputName = input && input.getName();
if (readOnly) {
options.ariaLabel = nls.localize('readonlyEditorAriaLabel', "Readonly text diff editor");
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text compare editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text compare editor.");
} else {
options.ariaLabel = nls.localize('editableEditorAriaLabel', "Text diff editor");
ariaLabel = inputName ? nls.localize('editableEditorWithInputAriaLabel', "{0}. Text file compare editor.", inputName) : nls.localize('editableEditorAriaLabel', "Text file compare editor.");
}
options.ariaLabel = ariaLabel;
}
return options;
......
......@@ -15,6 +15,7 @@ import {Preferences} from 'vs/workbench/common/constants';
import {IEditorViewState} from 'vs/editor/common/editorCommon';
import {OptionsChangeEvent, EventType as WorkbenchEventType, EditorEvent, TextEditorSelectionEvent} from 'vs/workbench/common/events';
import {Scope} from 'vs/workbench/common/memento';
import {EditorInput, IFileEditorInput, EditorOptions} from 'vs/workbench/common/editor';
import {BaseEditor} from 'vs/workbench/browser/parts/editor/baseEditor';
import {EditorConfiguration} from 'vs/editor/common/config/commonEditorConfig';
import {IEditorSelection, IEditor, EventType, IConfigurationChangedEvent, IModelContentChangedEvent, IModelModeChangedEvent, ICursorPositionChangedEvent, IEditorOptions} from 'vs/editor/common/editorCommon';
......@@ -171,6 +172,12 @@ export abstract class BaseTextEditor extends BaseEditor {
return this._instantiationService.createInstance(CodeEditorWidget, parent.getHTMLElement(), this.getCodeEditorOptions());
}
public setInput(input: EditorInput, options: EditorOptions): TPromise<void> {
return super.setInput(input, options).then(() => {
this.editorControl.updateOptions(this.getCodeEditorOptions()); // support input specific editor options
});
}
public setVisible(visible: boolean, position: Position = null): TPromise<void> {
let promise = super.setVisible(visible, position);
......
......@@ -256,7 +256,10 @@ export class TextFileEditor extends BaseTextEditor {
protected getCodeEditorOptions(): IEditorOptions {
let options = super.getCodeEditorOptions();
options.ariaLabel = nls.localize('fileEditorAriaLabel', "Text file editor");
let input = this.getInput();
let inputName = input && input.getName();
options.ariaLabel = inputName ? nls.localize('fileEditorWithInputAriaLabel', "{0}. Text file editor.", inputName) : nls.localize('fileEditorAriaLabel', "Text file editor.");
return options;
}
......
......@@ -77,10 +77,15 @@ export class OutputPanel extends StringEditor {
protected getCodeEditorOptions(): IEditorOptions {
const options = super.getCodeEditorOptions();
options.wrappingColumn = 0; // all output editors wrap
options.lineNumbers = false; // all output editors hide line numbers
options.lineNumbers = false; // all output editors hide line numbers
options.glyphMargin = false;
options.lineDecorationsWidth = 20;
options.ariaLabel = nls.localize('outputEditorAriaLabel', "Output panel");
let input = this.getInput();
let ariaLabel: string;
let channel = this.outputService.getActiveChannel();
options.ariaLabel = channel ? nls.localize('outputPanelWithInputAriaLabel', "{0}. Output panel.", channel) : nls.localize('outputPanelAriaLabel', "Output panel.");
return options;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册