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

Further grouping of resolved editor options

上级 e9bc6350
......@@ -311,7 +311,7 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
if (GlobalScreenReaderNVDA.getValue()) {
return TextAreaStrategy.NVDA;
}
if (this._context.configuration.editor.experimentalScreenReader) {
if (this._context.configuration.editor.viewInfo.experimentalScreenReader) {
return TextAreaStrategy.NVDA;
}
return TextAreaStrategy.IENarrator;
......@@ -326,7 +326,7 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
if (e.fontInfo) {
Configuration.applyFontInfoSlow(this.textArea.actual, this._context.configuration.editor.fontInfo);
}
if (e.experimentalScreenReader) {
if (e.viewInfo.experimentalScreenReader) {
this.textAreaHandler.setStrategy(this._getStrategy());
}
return false;
......
......@@ -260,7 +260,7 @@ export class MouseHandler extends ViewEventHandler implements IDisposable {
let targetIsContent = (t.type === editorCommon.MouseTargetType.CONTENT_TEXT || t.type === editorCommon.MouseTargetType.CONTENT_EMPTY);
let targetIsGutter = (t.type === editorCommon.MouseTargetType.GUTTER_GLYPH_MARGIN || t.type === editorCommon.MouseTargetType.GUTTER_LINE_NUMBERS || t.type === editorCommon.MouseTargetType.GUTTER_LINE_DECORATIONS);
let targetIsLineNumbers = (t.type === editorCommon.MouseTargetType.GUTTER_LINE_NUMBERS);
let selectOnLineNumbers = this._context.configuration.editor.selectOnLineNumbers;
let selectOnLineNumbers = this._context.configuration.editor.viewInfo.selectOnLineNumbers;
let targetIsViewZone = (t.type === editorCommon.MouseTargetType.CONTENT_VIEW_ZONE || t.type === editorCommon.MouseTargetType.GUTTER_VIEW_ZONE);
let shouldHandle = e.leftButton;
......
......@@ -213,9 +213,9 @@ export class MouseTargetFactory {
// Is it the textarea cover?
if (REGEX.IS_TEXTAREA_COVER.test(path)) {
if (this._context.configuration.editor.glyphMargin) {
if (this._context.configuration.editor.viewInfo.glyphMargin) {
return this.createMouseTargetFromGlyphMargin(t, mouseVerticalOffset, mouseColumn);
} else if (this._context.configuration.editor.lineNumbers) {
} else if (this._context.configuration.editor.viewInfo.lineNumbers) {
return this.createMouseTargetFromLineNumbers(t, mouseVerticalOffset, mouseColumn);
} else {
return this.createMouseTargetFromLinesDecorationsChild(t, mouseVerticalOffset, mouseColumn);
......@@ -359,8 +359,8 @@ export class MouseTargetFactory {
if (adjustedPosy <= editorContent.top) {
adjustedPosy = editorContent.top + 1;
}
if (adjustedPosy >= editorContent.top + this._context.configuration.editor.observedOuterHeight) {
adjustedPosy = editorContent.top + this._context.configuration.editor.observedOuterHeight - 1;
if (adjustedPosy >= editorContent.top + this._context.configuration.editor.layoutInfo.height) {
adjustedPosy = editorContent.top + this._context.configuration.editor.layoutInfo.height - 1;
}
var hitx = e.posx - document.body.scrollLeft;
......
......@@ -111,7 +111,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this.linesContent = document.createElement('div');
this.linesContent.className = editorBrowser.ClassNames.LINES_CONTENT + ' monaco-editor-background';
this.domNode = document.createElement('div');
this.domNode.className = configuration.editor.editorClassName;
this.domNode.className = configuration.editor.viewInfo.editorClassName;
this.overflowGuardContainer = document.createElement('div');
this.overflowGuardContainer.className = editorBrowser.ClassNames.OVERFLOW_GUARD;
......@@ -177,7 +177,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this.textArea.setAttribute('autocorrect', 'off');
this.textArea.setAttribute('autocapitalize', 'off');
this.textArea.setAttribute('spellcheck', 'false');
this.textArea.setAttribute('aria-label', this._context.configuration.editor.ariaLabel);
this.textArea.setAttribute('aria-label', this._context.configuration.editor.viewInfo.ariaLabel);
this.textArea.setAttribute('role', 'textbox');
this.textArea.setAttribute('aria-multiline', 'true');
this.textArea.setAttribute('aria-haspopup', 'false');
......@@ -193,10 +193,10 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
// (there have been reports of tiny blinking cursors)
// (in WebKit the textarea is 1px by 1px because it cannot handle input to a 0x0 textarea)
this.textAreaCover = document.createElement('div');
if (this._context.configuration.editor.glyphMargin) {
if (this._context.configuration.editor.viewInfo.glyphMargin) {
this.textAreaCover.className = 'monaco-editor-background ' + editorBrowser.ClassNames.GLYPH_MARGIN + ' ' + editorBrowser.ClassNames.TEXTAREA_COVER;
} else {
if (this._context.configuration.editor.lineNumbers) {
if (this._context.configuration.editor.viewInfo.lineNumbers) {
this.textAreaCover.className = 'monaco-editor-background ' + editorBrowser.ClassNames.LINE_NUMBERS + ' ' + editorBrowser.ClassNames.TEXTAREA_COVER;
} else {
this.textAreaCover.className = 'monaco-editor-background ' + editorBrowser.ClassNames.TEXTAREA_COVER;
......@@ -448,11 +448,11 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
return false;
}
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
if (e.editorClassName) {
this.domNode.className = this._context.configuration.editor.editorClassName;
if (e.viewInfo.editorClassName) {
this.domNode.className = this._context.configuration.editor.viewInfo.editorClassName;
}
if (e.ariaLabel) {
this.textArea.setAttribute('aria-label', this._context.configuration.editor.ariaLabel);
if (e.viewInfo.ariaLabel) {
this.textArea.setAttribute('aria-label', this._context.configuration.editor.viewInfo.ariaLabel);
}
return false;
}
......
......@@ -267,7 +267,7 @@ export class LayoutProvider extends ViewEventHandler implements IDisposable, ILa
public getTotalHeight(): number {
var reserveHorizontalScrollbarHeight = 0;
if (this.scrollManager.getScrollWidth() > this.scrollManager.getWidth()) {
reserveHorizontalScrollbarHeight = this.configuration.editor.scrollbar.horizontalScrollbarSize;
reserveHorizontalScrollbarHeight = this.configuration.editor.viewInfo.scrollbar.horizontalScrollbarSize;
}
return this.linesLayout.getTotalHeight(this.getCurrentViewport(), reserveHorizontalScrollbarHeight);
}
......
......@@ -33,7 +33,7 @@ export class ScrollManager implements IDisposable {
this.privateViewEventBus = privateViewEventBus;
this.linesContent = linesContent;
var configScrollbarOpts = this.configuration.editor.scrollbar;
var configScrollbarOpts = this.configuration.editor.viewInfo.scrollbar;
var scrollbarOptions:ScrollableElementCreationOptions = {
canUseTranslate3d: true,
......@@ -64,11 +64,11 @@ export class ScrollManager implements IDisposable {
this.toDispose.push(this.configuration.onDidChange((e:IConfigurationChangedEvent) => {
this.scrollbar.updateClassName(this.configuration.editor.theme);
if (e.scrollbar) {
if (e.viewInfo.scrollbar) {
let newOpts:ScrollableElementChangeOptions = {
canUseTranslate3d: true,
handleMouseWheel: this.configuration.editor.scrollbar.handleMouseWheel,
mouseWheelScrollSensitivity: this.configuration.editor.scrollbar.mouseWheelScrollSensitivity
handleMouseWheel: this.configuration.editor.viewInfo.scrollbar.handleMouseWheel,
mouseWheelScrollSensitivity: this.configuration.editor.viewInfo.scrollbar.mouseWheelScrollSensitivity
};
this.scrollbar.updateOptions(newOpts);
}
......
......@@ -87,7 +87,7 @@ export class GlyphMarginOverlay extends DedupOverlay {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._glyphMargin = this._context.configuration.editor.glyphMargin;
this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin;
this._glyphMarginLeft = 0;
this._glyphMarginWidth = 0;
this._renderResult = null;
......@@ -130,8 +130,8 @@ export class GlyphMarginOverlay extends DedupOverlay {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.glyphMargin) {
this._glyphMargin = this._context.configuration.editor.glyphMargin;
if (e.viewInfo.glyphMargin) {
this._glyphMargin = this._context.configuration.editor.viewInfo.glyphMargin;
}
return true;
}
......
......@@ -26,7 +26,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._lineNumbers = this._context.configuration.editor.lineNumbers;
this._lineNumbers = this._context.configuration.editor.viewInfo.lineNumbers;
this._lineNumbersLeft = 0;
this._lineNumbersWidth = 0;
this._renderResult = null;
......@@ -69,8 +69,8 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.lineNumbers) {
this._lineNumbers = this._context.configuration.editor.lineNumbers;
if (e.viewInfo.lineNumbers) {
this._lineNumbers = this._context.configuration.editor.viewInfo.lineNumbers;
}
return true;
}
......
......@@ -38,11 +38,11 @@ export class ViewLine implements IVisibleLineData {
constructor(context:ViewContext) {
this._context = context;
this._renderWhitespace = this._context.configuration.editor.renderWhitespace;
this._indentGuides = this._context.configuration.editor.indentGuides;
this._renderWhitespace = this._context.configuration.editor.viewInfo.renderWhitespace;
this._indentGuides = this._context.configuration.editor.viewInfo.indentGuides;
this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._stopRenderingLineAfter = this._context.configuration.editor.stopRenderingLineAfter;
this._stopRenderingLineAfter = this._context.configuration.editor.viewInfo.stopRenderingLineAfter;
this._fontLigatures = this._context.configuration.editor.fontLigatures;
this._domNode = null;
......@@ -84,11 +84,11 @@ export class ViewLine implements IVisibleLineData {
this._isMaybeInvalid = true;
}
public onConfigurationChanged(e:IConfigurationChangedEvent): void {
if (e.renderWhitespace) {
this._renderWhitespace = this._context.configuration.editor.renderWhitespace;
if (e.viewInfo.renderWhitespace) {
this._renderWhitespace = this._context.configuration.editor.viewInfo.renderWhitespace;
}
if (e.indentGuides) {
this._indentGuides = this._context.configuration.editor.indentGuides;
if (e.viewInfo.indentGuides) {
this._indentGuides = this._context.configuration.editor.viewInfo.indentGuides;
}
if (e.fontInfo) {
this._spaceWidth = this._context.configuration.editor.fontInfo.spaceWidth;
......@@ -96,8 +96,8 @@ export class ViewLine implements IVisibleLineData {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.stopRenderingLineAfter) {
this._stopRenderingLineAfter = this._context.configuration.editor.stopRenderingLineAfter;
if (e.viewInfo.stopRenderingLineAfter) {
this._stopRenderingLineAfter = this._context.configuration.editor.viewInfo.stopRenderingLineAfter;
}
if (e.fontLigatures) {
this._fontLigatures = this._context.configuration.editor.fontLigatures;
......
......@@ -77,7 +77,7 @@ export class ViewLines extends ViewLayer {
super(context);
this._lineHeight = this._context.configuration.editor.lineHeight;
this._isViewportWrapping = this._context.configuration.editor.wrappingInfo.isViewportWrapping;
this._revealHorizontalRightPadding = this._context.configuration.editor.revealHorizontalRightPadding;
this._revealHorizontalRightPadding = this._context.configuration.editor.viewInfo.revealHorizontalRightPadding;
this._layoutProvider = layoutProvider;
this.domNode.setClassName(ClassNames.VIEW_LINES);
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
......@@ -119,8 +119,8 @@ export class ViewLines extends ViewLayer {
if (e.wrappingInfo) {
this._isViewportWrapping = this._context.configuration.editor.wrappingInfo.isViewportWrapping;
}
if (e.revealHorizontalRightPadding) {
this._revealHorizontalRightPadding = this._context.configuration.editor.revealHorizontalRightPadding;
if (e.viewInfo.revealHorizontalRightPadding) {
this._revealHorizontalRightPadding = this._context.configuration.editor.viewInfo.revealHorizontalRightPadding;
}
if (e.fontInfo) {
Configuration.applyFontInfo(this.domNode, this._context.configuration.editor.fontInfo);
......
......@@ -41,7 +41,7 @@ export class DecorationsOverviewRuler extends ViewPart {
DecorationsOverviewRuler.DECORATION_HEIGHT,
getVerticalOffsetForLine
);
this._overviewRuler.setLanesCount(this._context.configuration.editor.overviewRulerLanes, false);
this._overviewRuler.setLanesCount(this._context.configuration.editor.viewInfo.overviewRulerLanes, false);
let theme = this._context.configuration.editor.theme;
this._overviewRuler.setUseDarkColor(!themes.isLightTheme(theme), false);
......@@ -49,7 +49,7 @@ export class DecorationsOverviewRuler extends ViewPart {
this._zonesFromDecorations = [];
this._shouldUpdateCursorPosition = true;
this._hideCursor = this._context.configuration.editor.hideCursorInOverviewRuler;
this._hideCursor = this._context.configuration.editor.viewInfo.hideCursorInOverviewRuler;
this._zonesFromCursors = [];
this._cursorPositions = [];
......@@ -71,7 +71,7 @@ export class DecorationsOverviewRuler extends ViewPart {
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
var prevLanesCount = this._overviewRuler.getLanesCount();
var newLanesCount = this._context.configuration.editor.overviewRulerLanes;
var newLanesCount = this._context.configuration.editor.viewInfo.overviewRulerLanes;
var shouldRender = false;
......@@ -85,8 +85,8 @@ export class DecorationsOverviewRuler extends ViewPart {
shouldRender = true;
}
if (e.hideCursorInOverviewRuler) {
this._hideCursor = this._context.configuration.editor.hideCursorInOverviewRuler;
if (e.viewInfo.hideCursorInOverviewRuler) {
this._hideCursor = this._context.configuration.editor.viewInfo.hideCursorInOverviewRuler;
this._shouldUpdateCursorPosition = true;
shouldRender = true;
}
......
......@@ -26,7 +26,7 @@ export class Rulers extends ViewPart {
this._layoutProvider = layoutProvider;
this.domNode = document.createElement('div');
this.domNode.className = 'view-rulers';
this._rulers = this._context.configuration.editor.rulers;
this._rulers = this._context.configuration.editor.viewInfo.rulers;
this._height = this._context.configuration.editor.layoutInfo.contentHeight;
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
}
......@@ -38,8 +38,8 @@ export class Rulers extends ViewPart {
// --- begin event handlers
public onConfigurationChanged(e: editorCommon.IConfigurationChangedEvent): boolean {
if (e.rulers || e.layoutInfo || e.fontInfo) {
this._rulers = this._context.configuration.editor.rulers;
if (e.viewInfo.rulers || e.layoutInfo || e.fontInfo) {
this._rulers = this._context.configuration.editor.viewInfo.rulers;
this._height = this._context.configuration.editor.layoutInfo.contentHeight;
this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth;
return true;
......
......@@ -28,7 +28,7 @@ export class ScrollDecorationViewPart extends ViewPart {
this._scrollTop = 0;
this._width = 0;
this._shouldShow = false;
this._useShadows = this._context.configuration.editor.scrollbar.useShadows;
this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows;
this._domNode = document.createElement('div');
}
......@@ -48,8 +48,8 @@ export class ScrollDecorationViewPart extends ViewPart {
// --- begin event handlers
public onConfigurationChanged(e: IConfigurationChangedEvent): boolean {
if (e.scrollbar) {
this._useShadows = this._context.configuration.editor.scrollbar.useShadows;
if (e.viewInfo.scrollbar) {
this._useShadows = this._context.configuration.editor.viewInfo.scrollbar.useShadows;
}
return this._updateShouldShow();
}
......
......@@ -85,7 +85,7 @@ export class SelectionsOverlay extends DynamicViewOverlay {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._roundedSelection = this._context.configuration.editor.roundedSelection;
this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection;
this._selections = [];
this._renderResult = null;
this._context.addEventHandler(this);
......@@ -131,8 +131,8 @@ export class SelectionsOverlay extends DynamicViewOverlay {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.roundedSelection) {
this._roundedSelection = this._context.configuration.editor.roundedSelection;
if (e.viewInfo.roundedSelection) {
this._roundedSelection = this._context.configuration.editor.viewInfo.roundedSelection;
}
return true;
}
......
......@@ -25,7 +25,7 @@ export class ViewCursor {
constructor(context:ViewContext, isSecondary:boolean) {
this._context = context;
this._cursorStyle = this._context.configuration.editor.cursorStyle;
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._lastRenderedContent = '';
......@@ -105,8 +105,8 @@ export class ViewCursor {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.cursorStyle) {
this._cursorStyle = this._context.configuration.editor.cursorStyle;
if (e.viewInfo.cursorStyle) {
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
}
if (e.fontInfo) {
Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo);
......
......@@ -44,8 +44,8 @@ export class ViewCursors extends ViewPart {
super(context);
this._readOnly = this._context.configuration.editor.readOnly;
this._cursorBlinking = this._context.configuration.editor.cursorBlinking;
this._cursorStyle = this._context.configuration.editor.cursorStyle;
this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking;
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
this._primaryCursor = new ViewCursor(this._context, false);
this._secondaryCursors = [];
......@@ -146,16 +146,16 @@ export class ViewCursors extends ViewPart {
if (e.readOnly) {
this._readOnly = this._context.configuration.editor.readOnly;
}
if (e.cursorBlinking) {
this._cursorBlinking = this._context.configuration.editor.cursorBlinking;
if (e.viewInfo.cursorBlinking) {
this._cursorBlinking = this._context.configuration.editor.viewInfo.cursorBlinking;
}
if (e.cursorStyle) {
this._cursorStyle = this._context.configuration.editor.cursorStyle;
if (e.viewInfo.cursorStyle) {
this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle;
}
this._primaryCursor.onConfigurationChanged(e);
this._updateBlinking();
if (e.cursorStyle) {
if (e.viewInfo.cursorStyle) {
this._updateDomClassName();
}
for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
......
......@@ -1778,14 +1778,14 @@ class InlineViewZonesComputer extends ViewZonesComputer {
let lineTokens = new ViewLineTokens([new ViewLineToken(0, '')], 0, lineContent.length);
let parts = createLineParts(lineNumber, 1, lineContent, tabSize, lineTokens, decorations, config.renderWhitespace, config.indentGuides);
let parts = createLineParts(lineNumber, 1, lineContent, tabSize, lineTokens, decorations, config.viewInfo.renderWhitespace, config.viewInfo.indentGuides);
let r = renderLine(new RenderLineInput(
lineContent,
tabSize,
config.fontInfo.spaceWidth,
config.stopRenderingLineAfter,
config.renderWhitespace,
config.viewInfo.stopRenderingLineAfter,
config.viewInfo.renderWhitespace,
parts.getParts()
));
......
......@@ -65,32 +65,17 @@ export class ConfigurationWithDefaults {
export class InternalEditorOptions implements editorCommon.IInternalEditorOptions {
_internalEditorOptionsBrand: void;
experimentalScreenReader: boolean;
rulers: number[];
wordSeparators: string;
selectionClipboard: boolean;
ariaLabel: string;
lineNumbers:any;
selectOnLineNumbers:boolean;
glyphMargin:boolean;
revealHorizontalRightPadding:number;
roundedSelection:boolean;
theme:string;
readOnly:boolean;
scrollbar:editorCommon.InternalEditorScrollbarOptions;
overviewRulerLanes:number;
cursorBlinking:string;
cursorStyle:editorCommon.TextEditorCursorStyle;
fontLigatures:boolean;
hideCursorInOverviewRuler:boolean;
scrollBeyondLastLine:boolean;
wrappingIndent: editorCommon.WrappingIndent;
wordWrapBreakBeforeCharacters: string;
wordWrapBreakAfterCharacters: string;
wordWrapBreakObtrusiveCharacters: string;
tabFocusMode:boolean;
stopLineTokenizationAfter:number;
stopRenderingLineAfter: number;
longLineBoundary:number;
forcedTokenizationBoundary:number;
hover:boolean;
......@@ -106,46 +91,27 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
outlineMarkers: boolean;
referenceInfos: boolean;
folding: boolean;
renderWhitespace: boolean;
indentGuides: boolean;
useTabStops: boolean;
trimAutoWhitespace: boolean;
layoutInfo: editorCommon.EditorLayoutInfo;
fontInfo: editorCommon.FontInfo;
editorClassName: string;
viewInfo: editorCommon.InternalEditorViewOptions;
wrappingInfo: editorCommon.IEditorWrappingInfo;
observedOuterWidth:number;
observedOuterHeight:number;
lineHeight:number;
pageSize:number;
constructor(input:editorCommon.IInternalEditorOptions) {
this.experimentalScreenReader = Boolean(input.experimentalScreenReader);
this.rulers = Array.prototype.slice.call(input.rulers, 0);
this.wordSeparators = String(input.wordSeparators);
this.selectionClipboard = Boolean(input.selectionClipboard);
this.ariaLabel = String(input.ariaLabel);
this.lineNumbers = input.lineNumbers || false;
this.selectOnLineNumbers = Boolean(input.selectOnLineNumbers);
this.glyphMargin = Boolean(input.glyphMargin);
this.revealHorizontalRightPadding = Number(input.revealHorizontalRightPadding)|0;
this.roundedSelection = Boolean(input.roundedSelection);
this.theme = String(input.theme);
this.readOnly = Boolean(input.readOnly);
this.scrollbar = input.scrollbar.clone();
this.overviewRulerLanes = Number(input.overviewRulerLanes)|0;
this.cursorBlinking = String(input.cursorBlinking);
this.cursorStyle = Number(input.cursorStyle)|0;
this.fontLigatures = Boolean(input.fontLigatures);
this.hideCursorInOverviewRuler = Boolean(input.hideCursorInOverviewRuler);
this.scrollBeyondLastLine = Boolean(input.scrollBeyondLastLine);
this.wrappingIndent = input.wrappingIndent;
this.wordWrapBreakBeforeCharacters = String(input.wordWrapBreakBeforeCharacters);
this.wordWrapBreakAfterCharacters = String(input.wordWrapBreakAfterCharacters);
this.wordWrapBreakObtrusiveCharacters = String(input.wordWrapBreakObtrusiveCharacters);
this.tabFocusMode = Boolean(input.tabFocusMode);
this.stopLineTokenizationAfter = Number(input.stopLineTokenizationAfter)|0;
this.stopRenderingLineAfter = Number(input.stopRenderingLineAfter)|0;
this.longLineBoundary = Number(input.longLineBoundary)|0;
this.forcedTokenizationBoundary = Number(input.forcedTokenizationBoundary)|0;
this.hover = Boolean(input.hover);
......@@ -161,19 +127,15 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
this.outlineMarkers = Boolean(input.outlineMarkers);
this.referenceInfos = Boolean(input.referenceInfos);
this.folding = Boolean(input.folding);
this.renderWhitespace = Boolean(input.renderWhitespace);
this.indentGuides = Boolean(input.indentGuides);
this.useTabStops = Boolean(input.useTabStops);
this.trimAutoWhitespace = Boolean(input.trimAutoWhitespace);
this.layoutInfo = input.layoutInfo.clone();
this.fontInfo = input.fontInfo.clone();
this.editorClassName = input.editorClassName;
this.viewInfo = input.viewInfo.clone();
this.wrappingInfo = {
isViewportWrapping: Boolean(input.wrappingInfo.isViewportWrapping),
wrappingColumn: Number(input.wrappingInfo.wrappingColumn)|0,
};
this.observedOuterWidth = Number(input.observedOuterWidth)|0;
this.observedOuterHeight = Number(input.observedOuterHeight)|0;
this.lineHeight = Number(input.lineHeight)|0;
this.pageSize = Number(input.pageSize)|0;
}
......@@ -274,34 +236,40 @@ class InternalEditorOptionsHelper {
tabFocusMode = true;
}
return {
// ---- Options that are transparent - get no massaging
let viewInfo = new editorCommon.InternalEditorViewOptions({
experimentalScreenReader: toBoolean(opts.experimentalScreenReader),
rulers: toSortedIntegerArray(opts.rulers),
ariaLabel: String(opts.ariaLabel),
lineNumbers: lineNumbers,
selectOnLineNumbers: toBoolean(opts.selectOnLineNumbers),
glyphMargin: glyphMargin,
revealHorizontalRightPadding: toInteger(opts.revealHorizontalRightPadding, 0),
roundedSelection: toBoolean(opts.roundedSelection),
theme: opts.theme,
readOnly: readOnly,
scrollbar: scrollbar,
overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3),
cursorBlinking: opts.cursorBlinking,
experimentalScreenReader: toBoolean(opts.experimentalScreenReader),
rulers: toSortedIntegerArray(opts.rulers),
wordSeparators: String(opts.wordSeparators),
selectionClipboard: toBoolean(opts.selectionClipboard),
ariaLabel: String(opts.ariaLabel),
cursorStyle: cursorStyleFromString(opts.cursorStyle),
fontLigatures: toBoolean(opts.fontLigatures),
hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler),
scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine),
editorClassName: editorClassName,
stopRenderingLineAfter: stopRenderingLineAfter,
renderWhitespace: toBoolean(opts.renderWhitespace),
indentGuides: toBoolean(opts.indentGuides),
scrollbar: scrollbar,
});
return {
// ---- Options that are transparent - get no massaging
theme: opts.theme,
readOnly: readOnly,
wordSeparators: String(opts.wordSeparators),
selectionClipboard: toBoolean(opts.selectionClipboard),
fontLigatures: toBoolean(opts.fontLigatures),
wrappingIndent: wrappingIndentFromString(opts.wrappingIndent),
wordWrapBreakBeforeCharacters: opts.wordWrapBreakBeforeCharacters,
wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
tabFocusMode: tabFocusMode,
stopLineTokenizationAfter: stopLineTokenizationAfter,
stopRenderingLineAfter: stopRenderingLineAfter,
longLineBoundary: toInteger(opts.longLineBoundary),
forcedTokenizationBoundary: toInteger(opts.forcedTokenizationBoundary),
......@@ -318,19 +286,14 @@ class InternalEditorOptionsHelper {
outlineMarkers: toBoolean(opts.outlineMarkers),
referenceInfos: toBoolean(opts.referenceInfos),
folding: toBoolean(opts.folding),
renderWhitespace: toBoolean(opts.renderWhitespace),
indentGuides: toBoolean(opts.indentGuides),
useTabStops: toBoolean(opts.useTabStops),
trimAutoWhitespace: toBoolean(opts.trimAutoWhitespace),
layoutInfo: layoutInfo,
fontInfo: fontInfo,
editorClassName: editorClassName,
viewInfo: viewInfo,
wrappingInfo: wrappingInfo,
observedOuterWidth: outerWidth,
observedOuterHeight: outerHeight,
lineHeight: fontInfo.lineHeight, // todo -> duplicated in styling
pageSize: pageSize,
};
......@@ -374,33 +337,18 @@ class InternalEditorOptionsHelper {
public static createConfigurationChangedEvent(prevOpts:InternalEditorOptions, newOpts:InternalEditorOptions): editorCommon.IConfigurationChangedEvent {
return {
experimentalScreenReader: (prevOpts.experimentalScreenReader !== newOpts.experimentalScreenReader),
rulers: (!this._numberArraysEqual(prevOpts.rulers, newOpts.rulers)),
wordSeparators: (prevOpts.wordSeparators !== newOpts.wordSeparators),
selectionClipboard: (prevOpts.selectionClipboard !== newOpts.selectionClipboard),
ariaLabel: (prevOpts.ariaLabel !== newOpts.ariaLabel),
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),
readOnly: (prevOpts.readOnly !== newOpts.readOnly),
scrollbar: (!prevOpts.scrollbar.equals(newOpts.scrollbar)),
overviewRulerLanes: (prevOpts.overviewRulerLanes !== newOpts.overviewRulerLanes),
cursorBlinking: (prevOpts.cursorBlinking !== newOpts.cursorBlinking),
cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle),
fontLigatures: (prevOpts.fontLigatures !== newOpts.fontLigatures),
hideCursorInOverviewRuler: (prevOpts.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler),
scrollBeyondLastLine: (prevOpts.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine),
wrappingIndent: (prevOpts.wrappingIndent !== newOpts.wrappingIndent),
wordWrapBreakBeforeCharacters: (prevOpts.wordWrapBreakBeforeCharacters !== newOpts.wordWrapBreakBeforeCharacters),
wordWrapBreakAfterCharacters: (prevOpts.wordWrapBreakAfterCharacters !== newOpts.wordWrapBreakAfterCharacters),
wordWrapBreakObtrusiveCharacters:(prevOpts.wordWrapBreakObtrusiveCharacters !== newOpts.wordWrapBreakObtrusiveCharacters),
tabFocusMode: (prevOpts.tabFocusMode !== newOpts.tabFocusMode),
stopLineTokenizationAfter: (prevOpts.stopLineTokenizationAfter !== newOpts.stopLineTokenizationAfter),
stopRenderingLineAfter: (prevOpts.stopRenderingLineAfter !== newOpts.stopRenderingLineAfter),
longLineBoundary: (prevOpts.longLineBoundary !== newOpts.longLineBoundary),
forcedTokenizationBoundary: (prevOpts.forcedTokenizationBoundary !== newOpts.forcedTokenizationBoundary),
......@@ -416,17 +364,13 @@ class InternalEditorOptionsHelper {
outlineMarkers: (prevOpts.outlineMarkers !== newOpts.outlineMarkers),
referenceInfos: (prevOpts.referenceInfos !== newOpts.referenceInfos),
folding: (prevOpts.folding !== newOpts.folding),
renderWhitespace: (prevOpts.renderWhitespace !== newOpts.renderWhitespace),
indentGuides: (prevOpts.indentGuides !== newOpts.indentGuides),
useTabStops: (prevOpts.useTabStops !== newOpts.useTabStops),
trimAutoWhitespace: (prevOpts.trimAutoWhitespace !== newOpts.trimAutoWhitespace),
layoutInfo: (!prevOpts.layoutInfo.equals(newOpts.layoutInfo)),
fontInfo: (!prevOpts.fontInfo.equals(newOpts.fontInfo)),
editorClassName: (prevOpts.editorClassName !== newOpts.editorClassName),
viewInfo: prevOpts.viewInfo.createChangeEvent(newOpts.viewInfo),
wrappingInfo: (!this._wrappingInfoEqual(prevOpts.wrappingInfo, newOpts.wrappingInfo)),
observedOuterWidth: (prevOpts.observedOuterWidth !== newOpts.observedOuterWidth),
observedOuterHeight: (prevOpts.observedOuterHeight !== newOpts.observedOuterHeight),
lineHeight: (prevOpts.lineHeight !== newOpts.lineHeight),
pageSize: (prevOpts.pageSize !== newOpts.pageSize),
};
......@@ -439,17 +383,6 @@ class InternalEditorOptionsHelper {
);
}
private static _numberArraysEqual(a:number[], b:number[]): boolean {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
}
function toBoolean(value:any): boolean {
......@@ -577,7 +510,16 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
let keys = Object.keys(changeEvent);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i];
if (changeEvent[key]) {
if (changeEvent[key] === true) {
hasChanged = true;
break;
}
}
keys = Object.keys(changeEvent.viewInfo);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i];
if (changeEvent[key] === true) {
hasChanged = true;
break;
}
......
......@@ -633,38 +633,183 @@ export interface IEditorWrappingInfo {
wrappingColumn: number;
}
/**
* Internal configuration options (transformed or computed) for the editor.
*/
export interface IInternalEditorOptions {
export class InternalEditorViewOptions {
experimentalScreenReader: boolean;
rulers: number[];
wordSeparators: string;
selectionClipboard: boolean;
ariaLabel: string;
// ---- Options that are transparent - get no massaging
lineNumbers:any;
selectOnLineNumbers:boolean;
glyphMargin:boolean;
revealHorizontalRightPadding:number;
roundedSelection:boolean;
theme:string;
readOnly:boolean;
scrollbar:InternalEditorScrollbarOptions;
overviewRulerLanes:number;
cursorBlinking:string;
cursorStyle:TextEditorCursorStyle;
fontLigatures:boolean;
hideCursorInOverviewRuler:boolean;
scrollBeyondLastLine:boolean;
editorClassName: string;
stopRenderingLineAfter: number;
renderWhitespace: boolean;
indentGuides: boolean;
scrollbar:InternalEditorScrollbarOptions;
constructor(source:{
experimentalScreenReader: boolean;
rulers: number[];
ariaLabel: string;
lineNumbers:any;
selectOnLineNumbers:boolean;
glyphMargin:boolean;
revealHorizontalRightPadding:number;
roundedSelection:boolean;
overviewRulerLanes:number;
cursorBlinking:string;
cursorStyle:TextEditorCursorStyle;
hideCursorInOverviewRuler:boolean;
scrollBeyondLastLine:boolean;
editorClassName: string;
stopRenderingLineAfter: number;
renderWhitespace: boolean;
indentGuides: boolean;
scrollbar:InternalEditorScrollbarOptions;
}) {
this.experimentalScreenReader = Boolean(source.experimentalScreenReader);
this.rulers = InternalEditorViewOptions._toSortedIntegerArray(source.rulers);
this.ariaLabel = String(source.ariaLabel);
this.lineNumbers = source.lineNumbers;
this.selectOnLineNumbers = Boolean(source.selectOnLineNumbers);
this.glyphMargin = Boolean(source.glyphMargin);
this.revealHorizontalRightPadding = source.revealHorizontalRightPadding|0;
this.roundedSelection = Boolean(source.roundedSelection);
this.overviewRulerLanes = source.overviewRulerLanes|0;
this.cursorBlinking = String(source.cursorBlinking);
this.cursorStyle = source.cursorStyle|0;
this.hideCursorInOverviewRuler = Boolean(source.hideCursorInOverviewRuler);
this.scrollBeyondLastLine = Boolean(source.scrollBeyondLastLine);
this.editorClassName = String(source.editorClassName);
this.stopRenderingLineAfter = source.stopRenderingLineAfter|0;
this.renderWhitespace = Boolean(source.renderWhitespace);
this.indentGuides = Boolean(source.indentGuides);
this.scrollbar = source.scrollbar.clone();
}
private static _toSortedIntegerArray(source:any): number[] {
if (!Array.isArray(source)) {
return [];
}
let arrSource = <any[]>source;
let result = arrSource.map(el => {
let r = parseInt(el, 10);
if (isNaN(r)) {
return 0;
}
return r;
});
result.sort();
return result;
}
private static _numberArraysEqual(a:number[], b:number[]): boolean {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
public equals(other:InternalEditorViewOptions): boolean {
return (
this.experimentalScreenReader === other.experimentalScreenReader
&& InternalEditorViewOptions._numberArraysEqual(this.rulers, other.rulers)
&& this.ariaLabel === other.ariaLabel
&& this.lineNumbers === other.lineNumbers
&& this.selectOnLineNumbers === other.selectOnLineNumbers
&& this.glyphMargin === other.glyphMargin
&& this.revealHorizontalRightPadding === other.revealHorizontalRightPadding
&& this.roundedSelection === other.roundedSelection
&& this.overviewRulerLanes === other.overviewRulerLanes
&& this.cursorBlinking === other.cursorBlinking
&& this.cursorStyle === other.cursorStyle
&& this.hideCursorInOverviewRuler === other.hideCursorInOverviewRuler
&& this.scrollBeyondLastLine === other.scrollBeyondLastLine
&& this.editorClassName === other.editorClassName
&& this.stopRenderingLineAfter === other.stopRenderingLineAfter
&& this.renderWhitespace === other.renderWhitespace
&& this.indentGuides === other.indentGuides
&& this.scrollbar.equals(other.scrollbar)
);
}
public createChangeEvent(newOpts:InternalEditorViewOptions): IViewConfigurationChangedEvent {
return {
experimentalScreenReader: this.experimentalScreenReader !== newOpts.experimentalScreenReader,
rulers: (!InternalEditorViewOptions._numberArraysEqual(this.rulers, newOpts.rulers)),
ariaLabel: this.ariaLabel !== newOpts.ariaLabel,
lineNumbers: this.lineNumbers !== newOpts.lineNumbers,
selectOnLineNumbers: this.selectOnLineNumbers !== newOpts.selectOnLineNumbers,
glyphMargin: this.glyphMargin !== newOpts.glyphMargin,
revealHorizontalRightPadding: this.revealHorizontalRightPadding !== newOpts.revealHorizontalRightPadding,
roundedSelection: this.roundedSelection !== newOpts.roundedSelection,
overviewRulerLanes: this.overviewRulerLanes !== newOpts.overviewRulerLanes,
cursorBlinking: this.cursorBlinking !== newOpts.cursorBlinking,
cursorStyle: this.cursorStyle !== newOpts.cursorStyle,
hideCursorInOverviewRuler: this.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler,
scrollBeyondLastLine: this.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine,
editorClassName: this.editorClassName !== newOpts.editorClassName,
stopRenderingLineAfter: this.stopRenderingLineAfter !== newOpts.stopRenderingLineAfter,
renderWhitespace: this.renderWhitespace !== newOpts.renderWhitespace,
indentGuides: this.indentGuides !== newOpts.indentGuides,
scrollbar: (!this.scrollbar.equals(newOpts.scrollbar)),
};
}
public clone(): InternalEditorViewOptions {
return new InternalEditorViewOptions(this);
}
}
export interface IViewConfigurationChangedEvent {
experimentalScreenReader: boolean;
rulers: boolean;
ariaLabel: boolean;
lineNumbers: boolean;
selectOnLineNumbers: boolean;
glyphMargin: boolean;
revealHorizontalRightPadding: boolean;
roundedSelection: boolean;
overviewRulerLanes: boolean;
cursorBlinking: boolean;
cursorStyle: boolean;
hideCursorInOverviewRuler: boolean;
scrollBeyondLastLine: boolean;
editorClassName: boolean;
stopRenderingLineAfter: boolean;
renderWhitespace: boolean;
indentGuides: boolean;
scrollbar: boolean;
}
/**
* Internal configuration options (transformed or computed) for the editor.
*/
export interface IInternalEditorOptions {
wordSeparators: string;
selectionClipboard: boolean;
// ---- Options that are transparent - get no massaging
theme:string;
readOnly:boolean;
fontLigatures:boolean;
wrappingIndent: WrappingIndent;
wordWrapBreakBeforeCharacters: string;
wordWrapBreakAfterCharacters: string;
wordWrapBreakObtrusiveCharacters: string;
tabFocusMode:boolean;
stopLineTokenizationAfter:number;
stopRenderingLineAfter: number;
longLineBoundary:number;
forcedTokenizationBoundary:number;
......@@ -682,8 +827,6 @@ export interface IInternalEditorOptions {
outlineMarkers: boolean;
referenceInfos: boolean;
folding: boolean;
renderWhitespace: boolean;
indentGuides: boolean;
useTabStops: boolean;
trimAutoWhitespace: boolean;
......@@ -692,18 +835,11 @@ export interface IInternalEditorOptions {
layoutInfo: EditorLayoutInfo;
fontInfo: FontInfo;
editorClassName: string;
viewInfo: InternalEditorViewOptions;
wrappingInfo: IEditorWrappingInfo;
/**
* Computed width of the container of the editor in px.
*/
observedOuterWidth:number;
/**
* Computed height of the container of the editor in px.
*/
observedOuterHeight:number;
/**
* Computed line height (deduced from theme and CSS) in px.
*/
......@@ -718,34 +854,19 @@ export interface IInternalEditorOptions {
* An event describing that the configuration of the editor has changed.
*/
export interface IConfigurationChangedEvent {
experimentalScreenReader: boolean;
rulers: boolean;
wordSeparators: boolean;
selectionClipboard: boolean;
ariaLabel: boolean;
// ---- Options that are transparent - get no massaging
lineNumbers: boolean;
selectOnLineNumbers: boolean;
glyphMargin: boolean;
revealHorizontalRightPadding: boolean;
roundedSelection: boolean;
theme: boolean;
readOnly: boolean;
scrollbar: boolean;
overviewRulerLanes: boolean;
cursorBlinking: boolean;
cursorStyle: boolean;
fontLigatures: boolean;
hideCursorInOverviewRuler: boolean;
scrollBeyondLastLine: boolean;
wrappingIndent: boolean;
wordWrapBreakBeforeCharacters: boolean;
wordWrapBreakAfterCharacters: boolean;
wordWrapBreakObtrusiveCharacters: boolean;
tabFocusMode: boolean;
stopLineTokenizationAfter: boolean;
stopRenderingLineAfter: boolean;
longLineBoundary: boolean;
forcedTokenizationBoundary: boolean;
......@@ -762,18 +883,14 @@ export interface IConfigurationChangedEvent {
outlineMarkers: boolean;
referenceInfos: boolean;
folding: boolean;
renderWhitespace: boolean;
indentGuides: boolean;
useTabStops: boolean;
trimAutoWhitespace: boolean;
// ---- Options that are computed
layoutInfo: boolean;
fontInfo: boolean;
editorClassName: boolean;
viewInfo: IViewConfigurationChangedEvent;
wrappingInfo: boolean;
observedOuterWidth: boolean;
observedOuterHeight: boolean;
lineHeight: boolean;
pageSize: boolean;
}
......
......@@ -29,7 +29,7 @@ export class LinesLayout {
constructor(configuration: editorCommon.IConfiguration, model:IViewModel) {
this.configuration = configuration;
this._lineHeight = this.configuration.editor.lineHeight;
this._scrollBeyondLastLine = this.configuration.editor.scrollBeyondLastLine;
this._scrollBeyondLastLine = this.configuration.editor.viewInfo.scrollBeyondLastLine;
this.model = model;
this.verticalObjects = new VerticalObjects();
......@@ -40,8 +40,8 @@ export class LinesLayout {
if (e.lineHeight) {
this._lineHeight = this.configuration.editor.lineHeight;
}
if (e.scrollBeyondLastLine) {
this._scrollBeyondLastLine = this.configuration.editor.scrollBeyondLastLine;
if (e.viewInfo.scrollBeyondLastLine) {
this._scrollBeyondLastLine = this.configuration.editor.viewInfo.scrollBeyondLastLine;
}
}
......
......@@ -47,7 +47,7 @@ export class ViewModelCursors {
this.lastCursorPositionChangedEvent = e;
var position = this.converter.validateViewPosition(e.viewPosition.lineNumber, e.viewPosition.column, e.position),
stopRenderingLineAfter = this.configuration.editor.stopRenderingLineAfter;
stopRenderingLineAfter = this.configuration.editor.viewInfo.stopRenderingLineAfter;
// Limit position to be somewhere where it can actually be rendered
if (stopRenderingLineAfter !== -1 && position.column > stopRenderingLineAfter) {
......
......@@ -419,8 +419,8 @@ export class ViewModel extends EventEmitter implements IViewModel {
}
var modelLineNumber = modelPosition.lineNumber;
if (typeof this.configuration.editor.lineNumbers === 'function') {
return this.configuration.editor.lineNumbers(modelLineNumber);
if (typeof this.configuration.editor.viewInfo.lineNumbers === 'function') {
return this.configuration.editor.viewInfo.lineNumbers(modelLineNumber);
}
return modelLineNumber.toString();
......
......@@ -161,7 +161,7 @@ export class ToggleRenderWhitespaceAction extends EditorAction {
public run(): TPromise<boolean> {
this.editor.updateOptions({
renderWhitespace: !this.editor.getConfiguration().renderWhitespace
renderWhitespace: !this.editor.getConfiguration().viewInfo.renderWhitespace
});
return TPromise.as(true);
......
......@@ -272,7 +272,7 @@ export class MainThreadTextEditor {
let cursorStyle = this._configuration ? this._configuration.cursorStyle : EditorCommon.TextEditorCursorStyle.Line;
if (codeEditor) {
let codeEditorOpts = codeEditor.getConfiguration();
cursorStyle = codeEditorOpts.cursorStyle;
cursorStyle = codeEditorOpts.viewInfo.cursorStyle;
}
let indent = model.getOptions();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册