提交 f1741033 编写于 作者: A Alex Dima

Add experimental editor option to toggle between text area state strategies

上级 1379c399
......@@ -20,7 +20,7 @@ import {Position} from 'vs/editor/common/core/position';
import {CommonKeybindings} from 'vs/base/common/keyCodes';
import Event, {Emitter} from 'vs/base/common/event';
import {TextAreaHandler} from 'vs/editor/common/controller/textAreaHandler';
import {ITextAreaWrapper, IClipboardEvent, IKeyboardEventWrapper, ISimpleModel} from 'vs/editor/common/controller/textAreaState';
import {ITextAreaWrapper, IClipboardEvent, IKeyboardEventWrapper, ISimpleModel, TextAreaStrategy} from 'vs/editor/common/controller/textAreaState';
class ClipboardEventWrapper implements IClipboardEvent {
......@@ -213,7 +213,7 @@ export class KeyboardHandler extends ViewEventHandler implements Lifecycle.IDisp
this.contentWidth = 0;
this.scrollLeft = 0;
this.textAreaHandler = new TextAreaHandler(Platform, Browser, this.textArea, this.context.model);
this.textAreaHandler = new TextAreaHandler(Platform, Browser, this._getStrategy(), this.textArea, this.context.model);
this._toDispose = [];
this._toDispose.push(this.textAreaHandler.onKeyDown((e) => this.viewController.emitKeyDown(<DomUtils.IKeyboardEvent>e._actual)));
......@@ -273,6 +273,13 @@ export class KeyboardHandler extends ViewEventHandler implements Lifecycle.IDisp
this._toDispose = Lifecycle.disposeAll(this._toDispose);
}
private _getStrategy(): TextAreaStrategy {
if (this.context.configuration.editor._screenReaderNVDA) {
return TextAreaStrategy.NVDA;
}
return TextAreaStrategy.IENarrator;
}
public focusTextArea(): void {
this.textAreaHandler.writePlaceholderAndSelectTextAreaSync();
}
......@@ -281,6 +288,9 @@ export class KeyboardHandler extends ViewEventHandler implements Lifecycle.IDisp
// Give textarea same font size & line height as editor, for the IME case (when the textarea is visible)
DomUtils.StyleMutator.setFontSize(this.textArea.actual, this.context.configuration.editor.fontSize);
DomUtils.StyleMutator.setLineHeight(this.textArea.actual, this.context.configuration.editor.lineHeight);
if (e._screenReaderNVDA) {
this.textAreaHandler.setStrategy(this._getStrategy());
}
return false;
}
......
......@@ -143,6 +143,7 @@ class InternalEditorOptionsHelper {
scrollbar: scrollbar,
overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3),
cursorBlinking: opts.cursorBlinking,
_screenReaderNVDA: toBoolean(opts._screenReaderNVDA),
cursorStyle: opts.cursorStyle,
fontLigatures: toBoolean(opts.fontLigatures),
hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler),
......@@ -220,20 +221,20 @@ class InternalEditorOptionsHelper {
public static createConfigurationChangedEvent(prevOpts:EditorCommon.IInternalEditorOptions, newOpts:EditorCommon.IInternalEditorOptions): EditorCommon.IConfigurationChangedEvent {
return {
layoutInfo: (!EditorLayoutProvider.layoutEqual(prevOpts.layoutInfo, newOpts.layoutInfo)),
layoutInfo: (!EditorLayoutProvider.layoutEqual(prevOpts.layoutInfo, newOpts.layoutInfo)),
stylingInfo: (!this._stylingInfoEqual(prevOpts.stylingInfo, newOpts.stylingInfo)),
wrappingInfo: (!this._wrappingInfoEqual(prevOpts.wrappingInfo, newOpts.wrappingInfo)),
indentInfo: (!this._indentInfoEqual(prevOpts.indentInfo, newOpts.indentInfo)),
observedOuterWidth: (prevOpts.observedOuterWidth !== newOpts.observedOuterWidth),
observedOuterHeight: (prevOpts.observedOuterHeight !== newOpts.observedOuterHeight),
observedOuterHeight: (prevOpts.observedOuterHeight !== newOpts.observedOuterHeight),
lineHeight: (prevOpts.lineHeight !== newOpts.lineHeight),
pageSize: (prevOpts.pageSize !== newOpts.pageSize),
typicalHalfwidthCharacterWidth: (prevOpts.typicalHalfwidthCharacterWidth !== newOpts.typicalHalfwidthCharacterWidth),
typicalFullwidthCharacterWidth: (prevOpts.typicalFullwidthCharacterWidth !== newOpts.typicalFullwidthCharacterWidth),
fontSize: (prevOpts.fontSize !== newOpts.fontSize),
lineNumbers: (prevOpts.lineNumbers !== newOpts.lineNumbers),
selectOnLineNumbers: (prevOpts.selectOnLineNumbers !== newOpts.selectOnLineNumbers),
glyphMargin: (prevOpts.glyphMargin !== newOpts.glyphMargin),
lineNumbers: (prevOpts.lineNumbers !== newOpts.lineNumbers),
selectOnLineNumbers: (prevOpts.selectOnLineNumbers !== newOpts.selectOnLineNumbers),
glyphMargin: (prevOpts.glyphMargin !== newOpts.glyphMargin),
revealHorizontalRightPadding: (prevOpts.revealHorizontalRightPadding !== newOpts.revealHorizontalRightPadding),
roundedSelection: (prevOpts.roundedSelection !== newOpts.roundedSelection),
theme: (prevOpts.theme !== newOpts.theme),
......@@ -241,7 +242,8 @@ class InternalEditorOptionsHelper {
scrollbar: (!this._scrollbarOptsEqual(prevOpts.scrollbar, newOpts.scrollbar)),
overviewRulerLanes: (prevOpts.overviewRulerLanes !== newOpts.overviewRulerLanes),
cursorBlinking: (prevOpts.cursorBlinking !== newOpts.cursorBlinking),
cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle),
_screenReaderNVDA: (prevOpts._screenReaderNVDA !== newOpts._screenReaderNVDA),
cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle),
fontLigatures: (prevOpts.fontLigatures !== newOpts.fontLigatures),
hideCursorInOverviewRuler: (prevOpts.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler),
scrollBeyondLastLine: (prevOpts.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine),
......@@ -255,11 +257,11 @@ class InternalEditorOptionsHelper {
longLineBoundary: (prevOpts.longLineBoundary !== newOpts.longLineBoundary),
forcedTokenizationBoundary: (prevOpts.forcedTokenizationBoundary !== newOpts.forcedTokenizationBoundary),
hover: (prevOpts.hover !== newOpts.hover),
contextmenu: (prevOpts.contextmenu !== newOpts.contextmenu),
contextmenu: (prevOpts.contextmenu !== newOpts.contextmenu),
quickSuggestions: (prevOpts.quickSuggestions !== newOpts.quickSuggestions),
quickSuggestionsDelay: (prevOpts.quickSuggestionsDelay !== newOpts.quickSuggestionsDelay),
iconsInSuggestions: (prevOpts.iconsInSuggestions !== newOpts.iconsInSuggestions),
autoClosingBrackets: (prevOpts.autoClosingBrackets !== newOpts.autoClosingBrackets),
autoClosingBrackets: (prevOpts.autoClosingBrackets !== newOpts.autoClosingBrackets),
formatOnType: (prevOpts.formatOnType !== newOpts.formatOnType),
suggestOnTriggerCharacters: (prevOpts.suggestOnTriggerCharacters !== newOpts.suggestOnTriggerCharacters),
selectionHighlight: (prevOpts.selectionHighlight !== newOpts.selectionHighlight),
......
......@@ -16,6 +16,7 @@ class ConfigClass implements IConfiguration {
constructor() {
this.editor = {
_screenReaderNVDA: false,
lineNumbers: true,
selectOnLineNumbers: true,
lineNumbersMinChars: 5,
......
......@@ -10,7 +10,10 @@ import {Disposable} from 'vs/base/common/lifecycle';
import {Range} from 'vs/editor/common/core/range';
import {Position} from 'vs/editor/common/core/position';
import {CommonKeybindings} from 'vs/base/common/keyCodes';
import {IKeyboardEventWrapper, ITextAreaWrapper, IClipboardEvent, ISimpleModel, TextAreaState, IENarratorTextAreaState, NVDATextAreaState, ITypeData} from 'vs/editor/common/controller/textAreaState';
import {
IKeyboardEventWrapper, ITextAreaWrapper, IClipboardEvent, ISimpleModel,
TextAreaState, createTextAreaState, ITypeData, TextAreaStrategy
} from 'vs/editor/common/controller/textAreaState';
import Event, {Emitter} from 'vs/base/common/event';
enum ReadFromTextArea {
......@@ -86,7 +89,7 @@ export class TextAreaHandler extends Disposable {
private _nextCommand: ReadFromTextArea;
constructor(Platform:IPlatform, Browser:IBrowser, textArea:ITextAreaWrapper, model:ISimpleModel) {
constructor(Platform:IPlatform, Browser:IBrowser, strategy:TextAreaStrategy, textArea:ITextAreaWrapper, model:ISimpleModel) {
super();
this.Platform = Platform;
this.Browser = Browser;
......@@ -101,8 +104,7 @@ export class TextAreaHandler extends Disposable {
this.lastCopiedValue = null;
this.lastCopiedValueIsFromEmptySelection = false;
this.textAreaState = IENarratorTextAreaState.EMPTY;
// this.textAreaState = NVDATextAreaState.EMPTY;
this.textAreaState = createTextAreaState(strategy);
this.hasFocus = false;
......@@ -219,6 +221,10 @@ export class TextAreaHandler extends Disposable {
// --- begin event handlers
public setStrategy(strategy:TextAreaStrategy): void {
this.textAreaState = this.textAreaState.toStrategy(strategy);
}
public setHasFocus(isFocused:boolean): void {
if (this.hasFocus === isFocused) {
// no change
......
......@@ -55,6 +55,18 @@ export interface ITypeData {
replaceCharCnt: number;
}
export enum TextAreaStrategy {
IENarrator,
NVDA
}
export function createTextAreaState(strategy:TextAreaStrategy): TextAreaState {
if (strategy === TextAreaStrategy.IENarrator) {
return IENarratorTextAreaState.EMPTY;
}
return NVDATextAreaState.EMPTY;
}
export abstract class TextAreaState {
protected previousState:TextAreaState;
......@@ -77,6 +89,8 @@ export abstract class TextAreaState {
public abstract toString(): string;
public abstract toStrategy(strategy:TextAreaStrategy): TextAreaState;
public abstract equals(other:TextAreaState): boolean;
public abstract fromTextArea(textArea:ITextAreaWrapper): TextAreaState;
......@@ -196,6 +210,13 @@ export class IENarratorTextAreaState extends TextAreaState {
return '[ <' + this.value + '>, selectionStart: ' + this.selectionStart + ', selectionEnd: ' + this.selectionEnd + ', isInOverwriteMode: ' + this.isInOverwriteMode + ', selectionToken: ' + this.selectionToken + ']';
}
public toStrategy(strategy:TextAreaStrategy): TextAreaState {
if (strategy === TextAreaStrategy.IENarrator) {
return this;
}
return new NVDATextAreaState(this.previousState, this.value, this.selectionStart, this.selectionEnd, this.isInOverwriteMode);
}
public equals(other:TextAreaState): boolean {
if (other instanceof IENarratorTextAreaState) {
return (
......@@ -290,6 +311,13 @@ export class NVDATextAreaState extends TextAreaState {
return '[ <ENTIRE TEXT' + /*this.value +*/ '>, selectionStart: ' + this.selectionStart + ', selectionEnd: ' + this.selectionEnd + ', isInOverwriteMode: ' + this.isInOverwriteMode + ']';
}
public toStrategy(strategy:TextAreaStrategy): TextAreaState {
if (strategy === TextAreaStrategy.NVDA) {
return this;
}
return new IENarratorTextAreaState(this.previousState, this.value, this.selectionStart, this.selectionEnd, this.isInOverwriteMode, 0);
}
public equals(other:TextAreaState): boolean {
if (other instanceof NVDATextAreaState) {
return (
......
......@@ -272,6 +272,7 @@ export function wrappingIndentFromString(wrappingIndent:string): WrappingIndent
* Configuration options for the editor. Common between configuring the editor and the options the editor has computed
*/
export interface ICommonEditorOptions {
_screenReaderNVDA?: boolean;
/**
* Control the rendering of line numbers.
* If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
......@@ -583,6 +584,7 @@ export interface IEditorWrappingInfo {
* Internal configuration options (transformed or computed) for the editor.
*/
export interface IInternalEditorOptions {
_screenReaderNVDA: boolean;
// ---- Options that are transparent - get no massaging
lineNumbers:any;
......@@ -667,6 +669,8 @@ export interface IInternalEditorOptions {
* An event describing that the configuration of the editor has changed.
*/
export interface IConfigurationChangedEvent {
_screenReaderNVDA: boolean;
layoutInfo:boolean;
stylingInfo:boolean;
wrappingInfo:boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册