提交 1be2f051 编写于 作者: A Alex Dima

Show accessibility status in the status bar

上级 300d44c2
......@@ -14,6 +14,7 @@ import paths = require('vs/base/common/paths');
import types = require('vs/base/common/types');
import uri from 'vs/base/common/uri';
import errors = require('vs/base/common/errors');
import * as browser from 'vs/base/browser/browser';
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { Action } from 'vs/base/common/actions';
import { language, LANGUAGE_DEFAULT } from 'vs/base/common/platform';
......@@ -78,6 +79,7 @@ class StateChange {
encoding: boolean;
EOL: boolean;
tabFocusMode: boolean;
screenReaderMode: boolean;
metadata: boolean;
constructor() {
......@@ -87,6 +89,7 @@ class StateChange {
this.encoding = false;
this.EOL = false;
this.tabFocusMode = false;
this.screenReaderMode = false;
this.metadata = false;
}
......@@ -97,6 +100,7 @@ class StateChange {
this.encoding = this.encoding || other.encoding;
this.EOL = this.EOL || other.EOL;
this.tabFocusMode = this.tabFocusMode || other.tabFocusMode;
this.screenReaderMode = this.screenReaderMode || other.screenReaderMode;
this.metadata = this.metadata || other.metadata;
}
}
......@@ -108,6 +112,7 @@ interface StateDelta {
EOL?: string;
indentation?: string;
tabFocusMode?: boolean;
screenReaderMode?: boolean;
metadata?: string;
}
......@@ -130,6 +135,9 @@ class State {
private _tabFocusMode: boolean;
public get tabFocusMode(): boolean { return this._tabFocusMode; }
private _screenReaderMode: boolean;
public get screenReaderMode(): boolean { return this._screenReaderMode; }
private _metadata: string;
public get metadata(): string { return this._metadata; }
......@@ -139,6 +147,7 @@ class State {
this._encoding = null;
this._EOL = null;
this._tabFocusMode = false;
this._screenReaderMode = false;
this._metadata = null;
}
......@@ -188,6 +197,13 @@ class State {
e.tabFocusMode = true;
}
}
if (typeof update.screenReaderMode !== 'undefined') {
if (this._screenReaderMode !== update.screenReaderMode) {
this._screenReaderMode = update.screenReaderMode;
somethingChanged = true;
e.screenReaderMode = true;
}
}
if (typeof update.metadata !== 'undefined') {
if (this._metadata !== update.metadata) {
this._metadata = update.metadata;
......@@ -210,6 +226,7 @@ const nlsMultiSelection = nls.localize('multiSelection', "{0} selections");
const nlsEOLLF = nls.localize('endOfLineLineFeed', "LF");
const nlsEOLCRLF = nls.localize('endOfLineCarriageReturnLineFeed', "CRLF");
const nlsTabFocusMode = nls.localize('tabFocusModeEnabled', "Tab moves focus");
const nlsScreenReaderDetected = nls.localize('screenReaderDetected', "Screen reader detected");
function _setDisplay(el: HTMLElement, desiredValue: string): void {
if (el.style.display !== desiredValue) {
......@@ -228,6 +245,7 @@ export class EditorStatus implements IStatusbarItem {
private state: State;
private element: HTMLElement;
private tabFocusModeElement: HTMLElement;
private screenRedearModeElement: HTMLElement;
private indentationElement: HTMLElement;
private selectionElement: HTMLElement;
private encodingElement: HTMLElement;
......@@ -262,6 +280,10 @@ export class EditorStatus implements IStatusbarItem {
this.tabFocusModeElement.textContent = nlsTabFocusMode;
hide(this.tabFocusModeElement);
this.screenRedearModeElement = append(this.element, $('a.editor-status-screenreadermode.status-bar-info'));
this.screenRedearModeElement.textContent = nlsScreenReaderDetected;
hide(this.screenRedearModeElement);
this.selectionElement = append(this.element, $('a.editor-status-selection'));
this.selectionElement.title = nls.localize('gotoLine', "Go to Line");
this.selectionElement.onclick = () => this.onSelectionClick();
......@@ -306,8 +328,10 @@ export class EditorStatus implements IStatusbarItem {
this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged()),
this.untitledEditorService.onDidChangeEncoding(r => this.onResourceEncodingChange(r)),
this.textFileService.models.onModelEncodingChanged(e => this.onResourceEncodingChange(e.resource)),
TabFocus.onDidChangeTabFocus(e => this.onTabFocusModeChange())
TabFocus.onDidChangeTabFocus(e => this.onTabFocusModeChange()),
browser.onDidChangeAccessibilitySupport(() => this.onScreenReaderModeChange())
);
this.onScreenReaderModeChange();
return combinedDisposable(this.toDispose);
}
......@@ -341,6 +365,14 @@ export class EditorStatus implements IStatusbarItem {
}
}
if (changed.screenReaderMode) {
if (this.state.screenReaderMode && this.state.screenReaderMode === true) {
show(this.screenRedearModeElement);
} else {
hide(this.screenRedearModeElement);
}
}
if (changed.indentation) {
if (this.state.indentation) {
this.indentationElement.textContent = this.state.indentation;
......@@ -653,6 +685,12 @@ export class EditorStatus implements IStatusbarItem {
this.updateState(info);
}
private onScreenReaderModeChange(): void {
const info: StateDelta = { screenReaderMode: browser.getAccessibilitySupport() === browser.AccessibilitySupport.Enabled };
this.updateState(info);
}
private isActiveEditor(e: IBaseEditor): boolean {
const activeEditor = this.editorService.getActiveEditor();
......
......@@ -22,4 +22,7 @@
.monaco-workbench .editor-statusbar-item > .editor-status-tabfocusmode {
padding: 0 5px 0 5px;
}
.monaco-workbench .editor-statusbar-item > .editor-status-screenreadermode {
padding: 0 5px 0 5px;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册