From 2e12948d07a28ad6a1827c0a9231e3b0cfbf23c9 Mon Sep 17 00:00:00 2001 From: jens1o Date: Tue, 6 Jun 2017 15:12:17 +0200 Subject: [PATCH 1/2] support custom cursor height --- src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts | 5 ++++- src/vs/editor/common/config/commonEditorConfig.ts | 5 +++++ src/vs/editor/common/config/editorOptions.ts | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index babe35b4178ae..969f4396659c0 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -41,6 +41,8 @@ export class ViewCursor { private readonly _domNode: FastDomNode; private _cursorStyle: TextEditorCursorStyle; + + private _cursorHeightMultiplier: number; private _lineHeight: number; private _typicalHalfwidthCharacterWidth: number; @@ -59,6 +61,7 @@ export class ViewCursor { this._cursorStyle = this._context.configuration.editor.viewInfo.cursorStyle; this._lineHeight = this._context.configuration.editor.lineHeight; this._typicalHalfwidthCharacterWidth = this._context.configuration.editor.fontInfo.typicalHalfwidthCharacterWidth; + this._cursorHeightMultiplier = this._context.configuration.editor.cursorHeightMultiplier || 1; this._isVisible = true; @@ -69,7 +72,7 @@ export class ViewCursor { } else { this._domNode.setClassName('cursor'); } - this._domNode.setHeight(this._lineHeight); + this._domNode.setHeight(this._lineHeight * this._cursorHeightMultiplier); this._domNode.setTop(0); this._domNode.setLeft(0); Configuration.applyFontInfo(this._domNode, this._context.configuration.editor.fontInfo); diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 2d54be1a83297..26baaf991d040 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -192,6 +192,11 @@ const editorConfiguration: IConfigurationNode = { 'default': EDITOR_FONT_DEFAULTS.lineHeight, 'description': nls.localize('lineHeight', "Controls the line height. Use 0 to compute the lineHeight from the fontSize.") }, + 'editor.cursorHeightMultiplier': { + 'type': 'number', + 'default': EDITOR_FONT_DEFAULTS.cursorHeightMultiplier, + 'description': nls.localize('cursorHeightMultiplier', "Controls how tall the cursor is. This will be multiplied with editor.lineHeight.") + }, 'editor.letterSpacing': { 'type': 'number', 'default': EDITOR_FONT_DEFAULTS.letterSpacing, diff --git a/src/vs/editor/common/config/editorOptions.ts b/src/vs/editor/common/config/editorOptions.ts index 2daf0ddac8f2e..4d6001a6ab637 100644 --- a/src/vs/editor/common/config/editorOptions.ts +++ b/src/vs/editor/common/config/editorOptions.ts @@ -810,6 +810,7 @@ export class InternalEditorOptions { readonly pixelRatio: number; readonly editorClassName: string; readonly lineHeight: number; + readonly cursorHeightMultiplier: number; readonly readOnly: boolean; /** * @internal @@ -2039,6 +2040,7 @@ export const EDITOR_FONT_DEFAULTS = { ), lineHeight: 0, letterSpacing: 0, + cursorHeightMultiplier: 1 }; /** From fbcb4d0341a457623bc38d79ef977cf5288ac452 Mon Sep 17 00:00:00 2001 From: jens1o Date: Tue, 6 Jun 2017 15:21:04 +0200 Subject: [PATCH 2/2] also set height on render --- src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index 969f4396659c0..182345ecf6b57 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -188,7 +188,7 @@ export class ViewCursor { this._domNode.setLeft(this._renderData.left); this._domNode.setWidth(this._renderData.width); this._domNode.setLineHeight(this._lineHeight); - this._domNode.setHeight(this._lineHeight); + this._domNode.setHeight(this._lineHeight * this._cursorHeightMultiplier); return { domNode: this._domNode.domNode,