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

Cache configuration in view parts

上级 07b89fa3
......@@ -90,9 +90,11 @@ class ViewOverlayLine implements IVisibleLineData {
private _dynamicOverlays:editorBrowser.IDynamicViewOverlay[];
private _domNode: HTMLElement;
private _renderPieces: string;
private _lineHeight: number;
constructor(context:editorBrowser.IViewContext, dynamicOverlays:editorBrowser.IDynamicViewOverlay[]) {
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._dynamicOverlays = dynamicOverlays;
this._domNode = null;
......@@ -122,7 +124,9 @@ class ViewOverlayLine implements IVisibleLineData {
// Nothing
}
onConfigurationChanged(e:IConfigurationChangedEvent): void {
// Nothing
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
}
shouldUpdateHTML(startLineNumber:number, lineNumber:number, inlineDecorations:IModelDecoration[]): boolean {
......@@ -146,7 +150,7 @@ class ViewOverlayLine implements IVisibleLineData {
out.push('" style="top:');
out.push(deltaTop.toString());
out.push('px;height:');
out.push(this._context.configuration.editor.lineHeight.toString());
out.push(this._lineHeight.toString());
out.push('px;" class="');
out.push(editorBrowser.ClassNames.VIEW_LINE);
out.push('">');
......@@ -164,7 +168,7 @@ class ViewOverlayLine implements IVisibleLineData {
this._domNode.setAttribute('lineNumber', lineNumber.toString());
}
StyleMutator.setTop(this._domNode, deltaTop);
StyleMutator.setHeight(this._domNode, this._context.configuration.editor.lineHeight);
StyleMutator.setHeight(this._domNode, this._lineHeight);
}
}
......
......@@ -107,8 +107,8 @@ export class LayoutProvider extends ViewEventHandler implements IDisposable, ILa
return {
top: this.scrollable.getScrollTop(),
left: this.scrollable.getScrollLeft(),
width: this.configuration.editor.layoutInfo.contentWidth,
height: this.configuration.editor.layoutInfo.contentHeight
width: this.scrollable.getWidth(),
height: this.scrollable.getHeight()
};
}
......
......@@ -46,6 +46,7 @@ export class ViewContentWidgets extends ViewPart {
private _widgets:IWidgetMap;
private _contentWidth:number;
private _contentLeft: number;
private _lineHeight: number;
public domNode:HTMLElement;
public overflowingContentWidgetsDomNode:HTMLElement;
......@@ -58,6 +59,7 @@ export class ViewContentWidgets extends ViewPart {
this._widgets = {};
this._contentWidth = 0;
this._contentLeft = 0;
this._lineHeight = this._context.configuration.editor.lineHeight;
this.domNode = document.createElement('div');
this.domNode.className = ClassNames.CONTENT_WIDGETS;
......@@ -100,6 +102,9 @@ export class ViewContentWidgets extends ViewPart {
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -200,7 +205,7 @@ export class ViewContentWidgets extends ViewPart {
let heightAboveLine = aboveLineTop;
// b) the box under the line
let underLineTop = visibleRange.top + this._context.configuration.editor.lineHeight;
let underLineTop = visibleRange.top + this._lineHeight;
let heightUnderLine = ctx.viewportHeight - underLineTop;
let aboveTop = aboveLineTop - height;
......@@ -243,7 +248,7 @@ export class ViewContentWidgets extends ViewPart {
}
let aboveTop = visibleRange.top - height,
belowTop = visibleRange.top + this._context.configuration.editor.lineHeight,
belowTop = visibleRange.top + this._lineHeight,
left = left0 + this._contentLeft;
let domNodePosition = dom.getDomNodePosition(this._viewDomNode);
......
......@@ -12,6 +12,8 @@ import {IDynamicViewOverlay, ILayoutProvider, IRenderingContext, IViewContext} f
export class CurrentLineHighlightOverlay extends ViewEventHandler implements IDynamicViewOverlay {
private _context:IViewContext;
private _lineHeight:number;
private _readOnly:boolean;
private _layoutProvider:ILayoutProvider;
private _selectionIsEmpty:boolean;
private _primaryCursorIsInEditableRange:boolean;
......@@ -21,6 +23,9 @@ export class CurrentLineHighlightOverlay extends ViewEventHandler implements IDy
constructor(context:IViewContext, layoutProvider:ILayoutProvider) {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._readOnly = this._context.configuration.editor.readOnly;
this._layoutProvider = layoutProvider;
this._selectionIsEmpty = true;
......@@ -72,6 +77,12 @@ export class CurrentLineHighlightOverlay extends ViewEventHandler implements IDy
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.readOnly) {
this._readOnly = this._context.configuration.editor.readOnly;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -108,7 +119,7 @@ export class CurrentLineHighlightOverlay extends ViewEventHandler implements IDy
'<div class="current-line" style="width:'
+ String(this._scrollWidth)
+ 'px; height:'
+ String(this._context.configuration.editor.lineHeight)
+ String(this._lineHeight)
+ 'px;"></div>'
);
} else {
......@@ -119,6 +130,6 @@ export class CurrentLineHighlightOverlay extends ViewEventHandler implements IDy
}
private _shouldShowCurrentLine(): boolean {
return this._selectionIsEmpty && this._primaryCursorIsInEditableRange && !this._context.configuration.editor.readOnly;
return this._selectionIsEmpty && this._primaryCursorIsInEditableRange && !this._readOnly;
}
}
......@@ -13,11 +13,13 @@ import {IDynamicViewOverlay, IRenderingContext, IViewContext} from 'vs/editor/br
export class DecorationsOverlay extends ViewEventHandler implements IDynamicViewOverlay {
private _context:IViewContext;
private _lineHeight: number;
private _renderResult: string[];
constructor(context:IViewContext) {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._renderResult = null;
this._context.addEventHandler(this);
......@@ -56,6 +58,9 @@ export class DecorationsOverlay extends ViewEventHandler implements IDynamicView
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -125,7 +130,7 @@ export class DecorationsOverlay extends ViewEventHandler implements IDynamicView
}
private _renderWholeLineDecorations(ctx:IRenderingContext, decorations:editorCommon.IModelDecoration[], output: string[]): void {
let lineHeight = String(this._context.configuration.editor.lineHeight);
let lineHeight = String(this._lineHeight);
let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
......@@ -154,7 +159,7 @@ export class DecorationsOverlay extends ViewEventHandler implements IDynamicView
}
private _renderNormalDecorations(ctx:IRenderingContext, decorations:editorCommon.IModelDecoration[], output: string[]): void {
let lineHeight = String(this._context.configuration.editor.lineHeight);
let lineHeight = String(this._lineHeight);
let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
for (let i = 0, lenI = decorations.length; i < lenI; i++) {
......
......@@ -108,6 +108,8 @@ export abstract class DedupOverlay extends ViewEventHandler {
export class GlyphMarginOverlay extends DedupOverlay implements IDynamicViewOverlay {
private _context:IViewContext;
private _lineHeight:number;
private _glyphMargin:boolean;
private _glyphMarginLeft:number;
private _glyphMarginWidth:number;
private _renderResult: string[];
......@@ -115,6 +117,8 @@ export class GlyphMarginOverlay extends DedupOverlay implements IDynamicViewOver
constructor(context:IViewContext) {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._glyphMargin = this._context.configuration.editor.glyphMargin;
this._glyphMarginLeft = 0;
this._glyphMarginWidth = 0;
this._renderResult = null;
......@@ -154,6 +158,12 @@ export class GlyphMarginOverlay extends DedupOverlay implements IDynamicViewOver
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.glyphMargin) {
this._glyphMargin = this._context.configuration.editor.glyphMargin;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -194,7 +204,7 @@ export class GlyphMarginOverlay extends DedupOverlay implements IDynamicViewOver
}
this.shouldRender = false;
if (!this._context.configuration.editor.glyphMargin) {
if (!this._glyphMargin) {
this._renderResult = null;
return false;
}
......@@ -203,7 +213,7 @@ export class GlyphMarginOverlay extends DedupOverlay implements IDynamicViewOver
let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
let toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
let lineHeight = this._context.configuration.editor.lineHeight.toString();
let lineHeight = this._lineHeight.toString();
let left = this._glyphMarginLeft.toString();
let width = this._glyphMarginWidth.toString();
let common = '" style="left:' + left + 'px;width:' + width + 'px' + ';height:' + lineHeight + 'px;"></div>';
......
......@@ -14,6 +14,8 @@ import {ClassNames, IDynamicViewOverlay, IRenderingContext, IViewContext} from '
export class LineNumbersOverlay extends ViewEventHandler implements IDynamicViewOverlay {
private _context:IViewContext;
private _lineHeight:number;
private _lineNumbers:any;
private _lineNumbersLeft:number;
private _lineNumbersWidth:number;
private _renderResult:string[];
......@@ -21,6 +23,8 @@ export class LineNumbersOverlay extends ViewEventHandler implements IDynamicView
constructor(context:IViewContext) {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._lineNumbers = this._context.configuration.editor.lineNumbers;
this._lineNumbersLeft = 0;
this._lineNumbersWidth = 0;
this._renderResult = null;
......@@ -60,6 +64,12 @@ export class LineNumbersOverlay extends ViewEventHandler implements IDynamicView
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.lineNumbers) {
this._lineNumbers = this._context.configuration.editor.lineNumbers;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -88,13 +98,13 @@ export class LineNumbersOverlay extends ViewEventHandler implements IDynamicView
}
this.shouldRender = false;
if (!this._context.configuration.editor.lineNumbers) {
if (!this._lineNumbers) {
this._renderResult = null;
return false;
}
let lineHeightClassName = (platform.isLinux ? (this._context.configuration.editor.lineHeight % 2 === 0 ? ' lh-even': ' lh-odd') : '');
let lineHeight = this._context.configuration.editor.lineHeight.toString();
let lineHeightClassName = (platform.isLinux ? (this._lineHeight % 2 === 0 ? ' lh-even': ' lh-odd') : '');
let lineHeight = this._lineHeight.toString();
let visibleStartLineNumber = ctx.visibleRange.startLineNumber;
let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
let common = '<div class="' + ClassNames.LINE_NUMBERS + lineHeightClassName + '" style="left:' + this._lineNumbersLeft.toString() + 'px;width:' + this._lineNumbersWidth.toString() + 'px;height:' + lineHeight + 'px;">';
......
......@@ -15,6 +15,11 @@ import {IVisibleLineData} from 'vs/editor/browser/view/viewLayer';
export class ViewLine implements IVisibleLineData {
protected _context:IViewContext;
private _renderWhitespace: boolean;
private _lineHeight: number;
private _stopRenderingLineAfter: number;
protected _fontLigatures: boolean;
private _domNode: FastDomNode;
private _lineParts: ILineParts;
......@@ -28,6 +33,11 @@ export class ViewLine implements IVisibleLineData {
constructor(context:IViewContext) {
this._context = context;
this._renderWhitespace = this._context.configuration.editor.renderWhitespace;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._stopRenderingLineAfter = this._context.configuration.editor.stopRenderingLineAfter;
this._fontLigatures = this._context.configuration.editor.fontLigatures;
this._domNode = null;
this._isInvalid = true;
this._isMaybeInvalid = false;
......@@ -67,6 +77,18 @@ 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.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.stopRenderingLineAfter) {
this._stopRenderingLineAfter = this._context.configuration.editor.stopRenderingLineAfter;
}
if (e.fontLigatures) {
this._fontLigatures = this._context.configuration.editor.fontLigatures;
}
this._isInvalid = true;
}
......@@ -81,7 +103,7 @@ export class ViewLine implements IVisibleLineData {
this._context.model.getLineContent(lineNumber),
this._context.model.getLineTokens(lineNumber),
inlineDecorations,
this._context.configuration.editor.renderWhitespace
this._renderWhitespace
);
}
......@@ -108,7 +130,7 @@ export class ViewLine implements IVisibleLineData {
out.push('" style="top:');
out.push(deltaTop.toString());
out.push('px;height:');
out.push(this._context.configuration.editor.lineHeight.toString());
out.push(this._lineHeight.toString());
out.push('px;" class="');
out.push(ClassNames.VIEW_LINE);
out.push('">');
......@@ -124,7 +146,7 @@ export class ViewLine implements IVisibleLineData {
public layoutLine(lineNumber:number, deltaTop:number): void {
this._domNode.setLineNumber(String(lineNumber));
this._domNode.setTop(deltaTop);
this._domNode.setHeight(this._context.configuration.editor.lineHeight);
this._domNode.setHeight(this._lineHeight);
}
// --- end IVisibleLineData
......@@ -136,8 +158,8 @@ export class ViewLine implements IVisibleLineData {
let r = renderLine(new RenderLineInput(
this._context.model.getLineContent(lineNumber),
this._context.model.getTabSize(),
this._context.configuration.editor.stopRenderingLineAfter,
this._context.configuration.editor.renderWhitespace,
this._stopRenderingLineAfter,
this._renderWhitespace,
lineParts.getParts()
));
......@@ -170,7 +192,7 @@ export class ViewLine implements IVisibleLineData {
startColumn = +startColumn; // @perf
endColumn = +endColumn; // @perf
clientRectDeltaLeft = +clientRectDeltaLeft; // @perf
let stopRenderingLineAfter = +this._context.configuration.editor.stopRenderingLineAfter; // @perf
let stopRenderingLineAfter = +this._stopRenderingLineAfter; // @perf
if (stopRenderingLineAfter !== -1 && startColumn > stopRenderingLineAfter && endColumn > stopRenderingLineAfter) {
// This range is obviously not visible
......@@ -325,7 +347,7 @@ export class ViewLine implements IVisibleLineData {
let lineParts = this._lineParts.getParts();
if (spanIndex >= lineParts.length) {
return this._context.configuration.editor.stopRenderingLineAfter;
return this._stopRenderingLineAfter;
}
if (offset === 0) {
......@@ -348,8 +370,8 @@ export class ViewLine implements IVisibleLineData {
let min = originalMin;
let max = originalMax;
if (this._context.configuration.editor.stopRenderingLineAfter !== -1) {
max = Math.min(this._context.configuration.editor.stopRenderingLineAfter - 1, originalMax);
if (this._stopRenderingLineAfter !== -1) {
max = Math.min(this._stopRenderingLineAfter - 1, originalMax);
}
let nextStartOffset:number;
......@@ -429,7 +451,7 @@ class WebKitViewLine extends ViewLine {
protected _readVisibleRangesForRange(startColumn:number, endColumn:number, clientRectDeltaLeft:number, endNode:HTMLElement): HorizontalRange[] {
let output = super._readVisibleRangesForRange(startColumn, endColumn, clientRectDeltaLeft, endNode);
if (this._context.configuration.editor.fontLigatures && output.length === 1 && endColumn > 1 && endColumn === this._charOffsetInPart.length) {
if (this._fontLigatures && output.length === 1 && endColumn > 1 && endColumn === this._charOffsetInPart.length) {
let lastSpanBoundingClientRect = (<HTMLElement>this._getReadingTarget().lastChild).getBoundingClientRect();
let lastSpanBoundingClientRectRight = lastSpanBoundingClientRect.right - clientRectDeltaLeft;
if (startColumn === endColumn) {
......
......@@ -30,6 +30,10 @@ export class ViewLines extends ViewLayer {
public textRangeRestingSpot:HTMLElement;
private _lineHeight: number;
private _isViewportWrapping: boolean;
private _revealHorizontalRightPadding: number;
// --- width
private _maxLineWidth: number;
private _asyncUpdateLineWidths: RunOnceScheduler;
......@@ -41,6 +45,9 @@ export class ViewLines extends ViewLayer {
constructor(context:IViewContext, layoutProvider:ILayoutProvider) {
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._layoutProvider = layoutProvider;
this.domNode.className = ClassNames.VIEW_LINES;
......@@ -74,6 +81,17 @@ export class ViewLines extends ViewLayer {
if (e.wrappingInfo) {
this._maxLineWidth = 0;
}
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.wrappingInfo) {
this._isViewportWrapping = this._context.configuration.editor.wrappingInfo.isViewportWrapping;
}
if (e.revealHorizontalRightPadding) {
this._revealHorizontalRightPadding = this._context.configuration.editor.revealHorizontalRightPadding;
}
return shouldRender;
}
......@@ -116,7 +134,7 @@ export class ViewLines extends ViewLayer {
public onCursorScrollRequest(e:editorCommon.IViewScrollRequestEvent): boolean {
let currentScrollTop = this._layoutProvider.getScrollTop();
let newScrollTop = currentScrollTop + e.deltaLines * this._context.configuration.editor.lineHeight;
let newScrollTop = currentScrollTop + e.deltaLines * this._lineHeight;
this._layoutProvider.setScrollTop(newScrollTop);
return true;
}
......@@ -321,7 +339,7 @@ export class ViewLines extends ViewLayer {
var newScrollLeft = this._computeScrollLeftToRevealRange(this._lastCursorRevealRangeHorizontallyEvent.range);
this._lastCursorRevealRangeHorizontallyEvent = null;
var isViewportWrapping = this._context.configuration.editor.wrappingInfo.isViewportWrapping;
var isViewportWrapping = this._isViewportWrapping;
if (!isViewportWrapping) {
this._ensureMaxLineWidth(newScrollLeft.maxHorizontalOffset);
}
......@@ -403,7 +421,7 @@ export class ViewLines extends ViewLayer {
boxEndY = this._layoutProvider.getVerticalOffsetForLineNumber(range.endLineNumber) + this._layoutProvider.heightInPxForLine(range.endLineNumber);
if (verticalType === editorCommon.VerticalRevealType.Simple) {
// Reveal one line more for the arrow down case, when the last line would be covered by the scrollbar
boxEndY += this._context.configuration.editor.lineHeight;
boxEndY += this._lineHeight;
}
var newScrollTop: number;
......@@ -468,7 +486,7 @@ export class ViewLines extends ViewLayer {
maxHorizontalOffset = boxEndX;
boxStartX = Math.max(0, boxStartX - ViewLines.HORIZONTAL_EXTRA_PX);
boxEndX += this._context.configuration.editor.revealHorizontalRightPadding;
boxEndX += this._revealHorizontalRightPadding;
var newScrollLeft = this._computeMinimumScrolling(viewportStartX, viewportEndX, boxStartX, boxEndX);
return {
......
......@@ -13,6 +13,7 @@ import {DecorationToRender, DedupOverlay} from 'vs/editor/browser/viewParts/glyp
export class LinesDecorationsOverlay extends DedupOverlay implements IDynamicViewOverlay {
private _context:IViewContext;
private _lineHeight: number;
private _decorationsLeft:number;
private _decorationsWidth:number;
......@@ -21,6 +22,7 @@ export class LinesDecorationsOverlay extends DedupOverlay implements IDynamicVie
constructor(context:IViewContext) {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._decorationsLeft = 0;
this._decorationsWidth = 0;
this._renderResult = null;
......@@ -60,6 +62,9 @@ export class LinesDecorationsOverlay extends DedupOverlay implements IDynamicVie
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -104,7 +109,7 @@ export class LinesDecorationsOverlay extends DedupOverlay implements IDynamicVie
let visibleEndLineNumber = ctx.visibleRange.endLineNumber;
let toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
let lineHeight = this._context.configuration.editor.lineHeight.toString();
let lineHeight = this._lineHeight.toString();
let left = this._decorationsLeft.toString();
let width = this._decorationsWidth.toString();
let common = '" style="left:' + left + 'px;width:' + width + 'px' + ';height:' + lineHeight + 'px;"></div>';
......
......@@ -18,6 +18,7 @@ export class ScrollDecorationViewPart extends ViewPart {
private _scrollTop: number;
private _width: number;
private _shouldShow: boolean;
private _useShadows: boolean;
constructor(context: IViewContext) {
super(context);
......@@ -25,11 +26,12 @@ export class ScrollDecorationViewPart extends ViewPart {
this._scrollTop = 0;
this._width = 0;
this._shouldShow = false;
this._useShadows = this._context.configuration.editor.scrollbar.useShadows;
this._domNode = document.createElement('div');
}
private _updateShouldShow(): boolean {
var newShouldShow = (this._context.configuration.editor.scrollbar.useShadows && this._scrollTop > 0);
var newShouldShow = (this._useShadows && this._scrollTop > 0);
if (this._shouldShow !== newShouldShow) {
this._shouldShow = newShouldShow;
return true;
......@@ -44,6 +46,9 @@ export class ScrollDecorationViewPart extends ViewPart {
// --- begin event handlers
public onConfigurationChanged(e: IConfigurationChangedEvent): boolean {
if (e.scrollbar) {
this._useShadows = this._context.configuration.editor.scrollbar.useShadows;
}
return this._updateShouldShow();
}
public onLayoutChanged(layoutInfo: IEditorLayoutInfo): boolean {
......
......@@ -77,12 +77,16 @@ export class SelectionsOverlay extends ViewEventHandler implements IDynamicViewO
private static ROUNDED_PIECE_WIDTH = 10;
private _context:IViewContext;
private _lineHeight:number;
private _roundedSelection:boolean;
private _selections:editorCommon.IEditorRange[];
private _renderResult:string[];
constructor(context:IViewContext) {
super();
this._context = context;
this._lineHeight = this._context.configuration.editor.lineHeight;
this._roundedSelection = this._context.configuration.editor.roundedSelection;
this._selections = [];
this._renderResult = null;
this._context.addEventHandler(this);
......@@ -125,6 +129,12 @@ export class SelectionsOverlay extends ViewEventHandler implements IDynamicViewO
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
}
if (e.roundedSelection) {
this._roundedSelection = this._context.configuration.editor.roundedSelection;
}
return true;
}
public onLayoutChanged(layoutInfo:editorCommon.IEditorLayoutInfo): boolean {
......@@ -273,7 +283,7 @@ export class SelectionsOverlay extends ViewEventHandler implements IDynamicViewO
let linesVisibleRanges = _linesVisibleRanges.map(toStyled);
let visibleRangesHaveGaps = this._visibleRangesHaveGaps(linesVisibleRanges);
if (!isIEWithZoomingIssuesNearRoundedBorders && !visibleRangesHaveGaps && this._context.configuration.editor.roundedSelection) {
if (!isIEWithZoomingIssuesNearRoundedBorders && !visibleRangesHaveGaps && this._roundedSelection) {
this._enrichVisibleRangesWithStyle(linesVisibleRanges, previousFrame);
}
......@@ -299,8 +309,8 @@ export class SelectionsOverlay extends ViewEventHandler implements IDynamicViewO
private _actualRenderOneSelection(output2:string[], visibleStartLineNumber:number, hasMultipleSelections:boolean, visibleRanges:LineVisibleRangesWithStyle[]): void {
let visibleRangesHaveStyle = (visibleRanges.length > 0 && visibleRanges[0].ranges[0].startStyle);
let fullLineHeight = (this._context.configuration.editor.lineHeight).toString();
let reducedLineHeight = (this._context.configuration.editor.lineHeight - 1).toString();
let fullLineHeight = (this._lineHeight).toString();
let reducedLineHeight = (this._lineHeight - 1).toString();
let firstLineNumber = (visibleRanges.length > 0 ? visibleRanges[0].lineNumber : 0);
let lastLineNumber = (visibleRanges.length > 0 ? visibleRanges[visibleRanges.length - 1].lineNumber : 0);
......
......@@ -22,6 +22,10 @@ export class ViewCursors extends ViewPart {
static BLINK_INTERVAL = 500;
private _readOnly:boolean;
private _cursorBlinking:string;
private _cursorStyle:editorCommon.TextEditorCursorStyle;
private _isVisible:boolean;
private _domNode:HTMLElement;
......@@ -36,6 +40,10 @@ export class ViewCursors extends ViewPart {
constructor(context:IViewContext) {
super(context);
this._readOnly = this._context.configuration.editor.readOnly;
this._cursorBlinking = this._context.configuration.editor.cursorBlinking;
this._cursorStyle = this._context.configuration.editor.cursorStyle;
this._primaryCursor = new ViewCursor(this._context, false);
this._secondaryCursors = [];
......@@ -134,6 +142,17 @@ export class ViewCursors extends ViewPart {
return false;
}
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.readOnly) {
this._readOnly = this._context.configuration.editor.readOnly;
}
if (e.cursorBlinking) {
this._cursorBlinking = this._context.configuration.editor.cursorBlinking;
}
if (e.cursorStyle) {
this._cursorStyle = this._context.configuration.editor.cursorStyle;
}
this._primaryCursor.onConfigurationChanged(e);
this._updateBlinking();
if (e.cursorStyle) {
......@@ -174,8 +193,8 @@ export class ViewCursors extends ViewPart {
private _getRenderType(): RenderType {
if (this._editorHasFocus) {
if (this._primaryCursor.getIsInEditableRange() && !this._context.configuration.editor.readOnly) {
switch (this._context.configuration.editor.cursorBlinking) {
if (this._primaryCursor.getIsInEditableRange() && !this._readOnly) {
switch (this._cursorBlinking) {
case 'blink':
return RenderType.Blink;
case 'visible':
......@@ -218,7 +237,7 @@ export class ViewCursors extends ViewPart {
private _getClassName(): string {
let result = ClassNames.VIEW_CURSORS_LAYER;
let extraClassName: string;
switch (this._context.configuration.editor.cursorStyle) {
switch (this._cursorStyle) {
case editorCommon.TextEditorCursorStyle.Line:
extraClassName = 'cursor-line-style';
break;
......
......@@ -29,11 +29,13 @@ export class ViewZones extends ViewPart {
private _whitespaceManager:editorCommon.IWhitespaceManager;
private _zones: { [id:string]:IMyViewZone; };
private _lineHeight:number;
public domNode: HTMLElement;
constructor(context:IViewContext, whitespaceManager:editorCommon.IWhitespaceManager) {
super(context);
this._lineHeight = this._context.configuration.editor.lineHeight;
this._whitespaceManager = whitespaceManager;
this.domNode = document.createElement('div');
this.domNode.className = ClassNames.VIEW_ZONES;
......@@ -87,6 +89,7 @@ export class ViewZones extends ViewPart {
public onConfigurationChanged(e:editorCommon.IConfigurationChangedEvent): boolean {
if (e.lineHeight) {
this._lineHeight = this._context.configuration.editor.lineHeight;
return this._recomputeWhitespacesProps();
}
......@@ -259,9 +262,9 @@ export class ViewZones extends ViewPart {
return zone.heightInPx;
}
if (typeof zone.heightInLines === 'number') {
return this._context.configuration.editor.lineHeight * zone.heightInLines;
return this._lineHeight * zone.heightInLines;
}
return this._context.configuration.editor.lineHeight;
return this._lineHeight;
}
private _safeCallOnComputedHeight(zone: IViewZone, height: number): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册