From 090f172d0ca4088823eea3439eed999cd157fbc6 Mon Sep 17 00:00:00 2001 From: markrendle Date: Tue, 22 Dec 2015 18:50:33 +0000 Subject: [PATCH 1/6] Implement configurable cursor style --- .../viewParts/viewCursors/viewCursor.ts | 42 +++++++++++++++++++ .../viewParts/viewCursors/viewCursors.css | 11 +++++ .../viewParts/viewCursors/viewCursors.ts | 15 ++++++- .../common/config/commonEditorConfig.ts | 8 ++++ src/vs/editor/common/config/defaultConfig.ts | 1 + src/vs/editor/common/editorCommon.ts | 7 ++++ 6 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index 41ee487129609..cf8ab35147e31 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -9,6 +9,25 @@ import DomUtils = require('vs/base/browser/dom'); import EditorBrowser = require('vs/editor/browser/editorBrowser'); import EditorCommon = require('vs/editor/common/editorCommon'); +export enum CursorStyle { + line, + block +} + +const CursorStyleNames = ((e:any) => { + let i = 0, items = []; + while (true) { + if (e[i]) { + items.push(e[i]); + } else { + return items; + } + i++; + } +})(CursorStyle); + +const CursorClassNames = CursorStyleNames.map(n => 'cursor-' + n); + export class ViewCursor { private _context:EditorBrowser.IViewContext; private _position: EditorCommon.IPosition; @@ -18,6 +37,7 @@ export class ViewCursor { private _isInEditableRange:boolean; private _isVisible:boolean; private _isInViewport:boolean; + private _cursorStyle:CursorStyle; constructor(context:EditorBrowser.IViewContext, isSecondary:boolean) { this._context = context; @@ -25,6 +45,7 @@ export class ViewCursor { this._isInEditableRange = true; this._domNode = this._createCursorDomNode(isSecondary); + this.setStyle(CursorStyle[context.configuration.editor.cursorStyle || 'line'] || CursorStyle.line); this._isVisible = true; DomUtils.StyleMutator.setDisplay(this._domNode, 'none'); this.updatePosition({ @@ -120,6 +141,27 @@ export class ViewCursor { } } + public setStyle(style:CursorStyle): void { + if (this._cursorStyle === style) { + return; + } + this._cursorStyle = style; + + let newStyleClass = 'cursor-' + CursorStyle[style]; + if (this._domNode.classList.contains(newStyleClass)) { + return; + } + + this._domNode.classList.remove(...CursorClassNames); + this._domNode.classList.add('cursor-' + CursorStyle[style]); + } + + private removeCursorClass(c:string) { + if (this._domNode.classList.contains(c)) { + this._domNode.classList.remove(c); + } + } + private updatePosition(newPosition:EditorCommon.IPosition): void { this._position = newPosition; this._domNode.setAttribute('lineNumber', this._position.lineNumber.toString()); diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css index 0470064762634..09e5f9e1faf38 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css @@ -8,11 +8,22 @@ } .monaco-editor .cursors-layer > .cursor { + position: absolute; + cursor: text; +} + +.monaco-editor .cursors-layer > .cursor-line { position: absolute; width: 2px; cursor: text; } +.monaco-editor .cursors-layer > .cursor-block { + position: absolute; + width: 1ch; + cursor: text; +} + .monaco-editor .cursors-layer > .cursor.secondary { width: 1px; opacity: 0.6; diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts index 92efce34b39a4..338aa43e2a303 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts @@ -8,7 +8,7 @@ import 'vs/css!./viewCursors'; import Browser = require('vs/base/browser/browser'); -import {ViewCursor} from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; +import {ViewCursor, CursorStyle} from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; import {ViewPart} from 'vs/editor/browser/view/viewPart'; import EditorBrowser = require('vs/editor/browser/editorBrowser'); import EditorCommon = require('vs/editor/common/editorCommon'); @@ -52,6 +52,7 @@ export class ViewCursors extends ViewPart { this._editorHasFocus = false; this._updateBlinking(); + this._updateCursorStyle(); } public dispose(): void { @@ -107,6 +108,7 @@ export class ViewCursors extends ViewPart { public onCursorPositionChanged(e:EditorCommon.IViewCursorPositionChangedEvent): boolean { this._primaryCursor.onCursorPositionChanged(e.position, e.isInEditableRange); this._updateBlinking(); + this._updateCursorStyle(); if (this._secondaryCursors.length < e.secondaryPositions.length) { // Create new cursors @@ -137,6 +139,7 @@ export class ViewCursors extends ViewPart { public onConfigurationChanged(e:EditorCommon.IConfigurationChangedEvent): boolean { this._primaryCursor.onConfigurationChanged(e); this._updateBlinking(); + this._updateCursorStyle(); for (var i = 0, len = this._secondaryCursors.length; i < len; i++) { this._secondaryCursors[i].onConfigurationChanged(e); } @@ -160,6 +163,7 @@ export class ViewCursors extends ViewPart { public onViewFocusChanged(isFocused:boolean): boolean { this._editorHasFocus = isFocused; this._updateBlinking(); + this._updateCursorStyle(); return false; } // --- end event handlers @@ -209,6 +213,15 @@ export class ViewCursors extends ViewPart { } // --- end blinking logic + private _getCursorStyle(): CursorStyle { + return CursorStyle[this._context.configuration.editor.cursorStyle || 'line'] || CursorStyle.line; + } + + private _updateCursorStyle(): void { + this._primaryCursor.setStyle(this._getCursorStyle()); + } + + private _blink(): void { if (this._isVisible) { this._hide(); diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 5d51249b8bc49..8b5b250dfe534 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -142,6 +142,7 @@ class InternalEditorOptionsHelper { scrollbar: scrollbar, overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3), cursorBlinking: opts.cursorBlinking, + cursorStyle: opts.cursorStyle, hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler), scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine), wrappingIndent: opts.wrappingIndent, @@ -238,6 +239,7 @@ class InternalEditorOptionsHelper { scrollbar: (!this._scrollbarOptsEqual(prevOpts.scrollbar, newOpts.scrollbar)), overviewRulerLanes: (prevOpts.overviewRulerLanes !== newOpts.overviewRulerLanes), cursorBlinking: (prevOpts.cursorBlinking !== newOpts.cursorBlinking), + cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle), hideCursorInOverviewRuler: (prevOpts.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler), scrollBeyondLastLine: (prevOpts.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine), wrappingIndent: (prevOpts.wrappingIndent !== newOpts.wrappingIndent), @@ -802,6 +804,12 @@ configurationRegistry.registerConfiguration({ 'default': DefaultConfig.editor.cursorBlinking, 'description': nls.localize('cursorBlinking', "Controls the cursor blinking animation, accepted values are 'blink', 'visible', and 'hidden'") }, + 'editor.cursorStyle' : { + 'type': 'string', + 'enum': ['block', 'line'], + 'default': DefaultConfig.editor.cursorStyle, + 'description': nls.localize('cursorStyle', "Controls the cursor style, accepted values are 'block' and 'line'") + }, 'editor.hideCursorInOverviewRuler' : { 'type': 'boolean', 'default': DefaultConfig.editor.hideCursorInOverviewRuler, diff --git a/src/vs/editor/common/config/defaultConfig.ts b/src/vs/editor/common/config/defaultConfig.ts index 51361684a405a..f0b29ab5a0018 100644 --- a/src/vs/editor/common/config/defaultConfig.ts +++ b/src/vs/editor/common/config/defaultConfig.ts @@ -34,6 +34,7 @@ class ConfigClass implements IConfiguration { }, overviewRulerLanes: 2, cursorBlinking: 'blink', + cursorStyle: 'line', hideCursorInOverviewRuler: false, scrollBeyondLastLine: true, automaticLayout: false, diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index c0301683a919d..c518cde42fd56 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -338,6 +338,11 @@ export interface ICommonEditorOptions { * Defaults to 'blink'. */ cursorBlinking?:string; + /** + * Control the cursor style, either 'block' or 'line'. + * Defaults to 'line'. + */ + cursorStyle?:string; /** * Should the cursor be hidden in the overview ruler. * Defaults to false. @@ -585,6 +590,7 @@ export interface IInternalEditorOptions { scrollbar:IInternalEditorScrollbarOptions; overviewRulerLanes:number; cursorBlinking:string; + cursorStyle:string; hideCursorInOverviewRuler:boolean; scrollBeyondLastLine:boolean; wrappingIndent: string; @@ -676,6 +682,7 @@ export interface IConfigurationChangedEvent { scrollbar:boolean; overviewRulerLanes:boolean; cursorBlinking:boolean; + cursorStyle:boolean; hideCursorInOverviewRuler:boolean; scrollBeyondLastLine:boolean; wrappingIndent:boolean; From 1da94d28ee74302bc30747403a314c49129519be Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 23 Dec 2015 11:03:51 +0100 Subject: [PATCH 2/6] Add preserveFocus flag to showTextDocument and OutputChannel.show, fixes #1045 --- src/vs/vscode.d.ts | 6 ++++-- src/vs/workbench/api/common/extHost.api.impl.ts | 4 ++-- src/vs/workbench/api/common/extHostEditors.ts | 8 ++++---- src/vs/workbench/api/common/extHostOutputService.ts | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index ee6e909751e12..b6d6d242d539f 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -2362,8 +2362,9 @@ declare namespace vscode { * Reveal this channel in the UI. * * @param column The column in which to show the channel, default in [one](#ViewColumn.One). + * @param preserveFocus When `true` the channel will not take focus. */ - show(column?: ViewColumn): void; + show(column?: ViewColumn, preserveFocus?: boolean): void; /** * Hide this channel from the UI. @@ -2708,9 +2709,10 @@ declare namespace vscode { * @param document A text document to be shown. * @param column A view column in which the editor should be shown. The default is the [one](#ViewColumn.One), other values * are adjusted to be __Min(column, columnCount + 1)__. + * @param preserveFocus When `true` the editor will not take focus. * @return A promise that resolves to an [editor](#TextEditor). */ - export function showTextDocument(document: TextDocument, column?: ViewColumn): Thenable; + export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable; /** * Create a TextEditorDecorationType that can be used to add decorations to text editors. diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 2808970b9f6c5..f24d9b2880e2a 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -160,8 +160,8 @@ export class ExtHostAPIImplementation { get visibleTextEditors() { return pluginHostEditors.getVisibleTextEditors(); }, - showTextDocument(document: vscode.TextDocument, column: vscode.ViewColumn): TPromise { - return pluginHostEditors.showTextDocument(document, column); + showTextDocument(document: vscode.TextDocument, column?: vscode.ViewColumn, preserveFocus?: boolean): TPromise { + return pluginHostEditors.showTextDocument(document, column, preserveFocus); }, createTextEditorDecorationType(options:vscode.DecorationRenderOptions): vscode.TextEditorDecorationType { return pluginHostEditors.createTextEditorDecorationType(options); diff --git a/src/vs/workbench/api/common/extHostEditors.ts b/src/vs/workbench/api/common/extHostEditors.ts index 0c68f7b057cff..1e81644b317e0 100644 --- a/src/vs/workbench/api/common/extHostEditors.ts +++ b/src/vs/workbench/api/common/extHostEditors.ts @@ -75,8 +75,8 @@ export class ExtHostEditors { return this._onDidChangeActiveTextEditor && this._onDidChangeActiveTextEditor.event; } - showTextDocument(document: TextDocument, column: ViewColumn): TPromise { - return this._proxy._tryShowTextDocument( document.uri, TypeConverters.fromViewColumn(column)).then(id => { + showTextDocument(document: TextDocument, column: ViewColumn, preserveFocus: boolean): TPromise { + return this._proxy._tryShowTextDocument( document.uri, TypeConverters.fromViewColumn(column), preserveFocus).then(id => { let editor = this._editors[id]; if (editor) { return editor; @@ -525,12 +525,12 @@ export class MainThreadEditors { // --- from plugin host process - _tryShowTextDocument(resource: URI, position: EditorPosition): TPromise { + _tryShowTextDocument(resource: URI, position: EditorPosition, preserveFocus: boolean): TPromise { // the input we want to open let input = { resource, - options: { preserveFocus: false } + options: { preserveFocus } }; return this._workbenchEditorService.openEditor(input, position).then(editor => { diff --git a/src/vs/workbench/api/common/extHostOutputService.ts b/src/vs/workbench/api/common/extHostOutputService.ts index b66ae56f4d1fd..e5276f0f7f270 100644 --- a/src/vs/workbench/api/common/extHostOutputService.ts +++ b/src/vs/workbench/api/common/extHostOutputService.ts @@ -47,8 +47,8 @@ export class ExtHostOutputChannel implements vscode.OutputChannel { this._proxy.clear(this._name); } - show(column?: vscode.ViewColumn): void { - this._proxy.reveal(this._name, TypeConverters.fromViewColumn(column)); + show(column?: vscode.ViewColumn, preserveFocus?: boolean): void { + this._proxy.reveal(this._name, TypeConverters.fromViewColumn(column), preserveFocus); } hide(): void { @@ -95,8 +95,8 @@ export class MainThreadOutputService { return undefined; } - public reveal(channel: string, position: Position): TPromise { - this._outputService.showOutput(channel, position); + public reveal(channel: string, position: Position, preserveFocus: boolean): TPromise { + this._outputService.showOutput(channel, position, preserveFocus); return undefined; } From 469b53c0f6268bd729e6c8b999b376075548bd84 Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Wed, 23 Dec 2015 22:46:12 +0100 Subject: [PATCH 3/6] debugProtocol: add attribute "origin" to Source (fix Microsoft/vscode-debugadapter-node#5) --- src/vs/workbench/parts/debug/common/debugProtocol.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vs/workbench/parts/debug/common/debugProtocol.d.ts b/src/vs/workbench/parts/debug/common/debugProtocol.d.ts index 9ae5973e25b07..cd41e755655b6 100644 --- a/src/vs/workbench/parts/debug/common/debugProtocol.d.ts +++ b/src/vs/workbench/parts/debug/common/debugProtocol.d.ts @@ -450,6 +450,8 @@ declare module DebugProtocol { path?: string; /** If sourceReference > 0 the contents of the source can be retrieved through the SourceRequest. A sourceReference is only valid for a session, so it must not be used to persist a source. */ sourceReference?: number; + /** The (optional) origin of this source: possible values "internal module", "inlined content from source map" */ + origin?: string; } /** A Stackframe contains the source location. */ From a26f9d765854b1c9f29536fcd62f777aab3ce6ac Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Wed, 23 Dec 2015 22:48:18 +0100 Subject: [PATCH 4/6] update node-debug (inlined source) --- extensions/node-debug/node-debug.azure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/node-debug/node-debug.azure.json b/extensions/node-debug/node-debug.azure.json index 8e3074d8bb197..1bb6d5c946767 100644 --- a/extensions/node-debug/node-debug.azure.json +++ b/extensions/node-debug/node-debug.azure.json @@ -1,6 +1,6 @@ { "account": "monacobuild", "container": "debuggers", - "zip": "5c4669d/node-debug.zip", + "zip": "bfa6851/node-debug.zip", "output": "" } From 11eb2c583bbaa16ddb063ec09f8fb72f41ad30f1 Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Thu, 24 Dec 2015 01:11:08 +0100 Subject: [PATCH 5/6] update node-debug (windows offline debugging) --- extensions/node-debug/node-debug.azure.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/node-debug/node-debug.azure.json b/extensions/node-debug/node-debug.azure.json index 1bb6d5c946767..7fde9f609f7ee 100644 --- a/extensions/node-debug/node-debug.azure.json +++ b/extensions/node-debug/node-debug.azure.json @@ -1,6 +1,6 @@ { "account": "monacobuild", "container": "debuggers", - "zip": "bfa6851/node-debug.zip", + "zip": "69132db/node-debug.zip", "output": "" } From 4a0e3199409a7fc8de1cd872ea9bb4dbe21daede Mon Sep 17 00:00:00 2001 From: markrendle Date: Tue, 22 Dec 2015 18:50:33 +0000 Subject: [PATCH 6/6] Implement configurable cursor style --- .../viewParts/viewCursors/viewCursor.ts | 42 +++++++++++++++++++ .../viewParts/viewCursors/viewCursors.css | 11 +++++ .../viewParts/viewCursors/viewCursors.ts | 15 ++++++- .../common/config/commonEditorConfig.ts | 8 ++++ src/vs/editor/common/config/defaultConfig.ts | 1 + src/vs/editor/common/editorCommon.ts | 7 ++++ 6 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts index 41ee487129609..cf8ab35147e31 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts @@ -9,6 +9,25 @@ import DomUtils = require('vs/base/browser/dom'); import EditorBrowser = require('vs/editor/browser/editorBrowser'); import EditorCommon = require('vs/editor/common/editorCommon'); +export enum CursorStyle { + line, + block +} + +const CursorStyleNames = ((e:any) => { + let i = 0, items = []; + while (true) { + if (e[i]) { + items.push(e[i]); + } else { + return items; + } + i++; + } +})(CursorStyle); + +const CursorClassNames = CursorStyleNames.map(n => 'cursor-' + n); + export class ViewCursor { private _context:EditorBrowser.IViewContext; private _position: EditorCommon.IPosition; @@ -18,6 +37,7 @@ export class ViewCursor { private _isInEditableRange:boolean; private _isVisible:boolean; private _isInViewport:boolean; + private _cursorStyle:CursorStyle; constructor(context:EditorBrowser.IViewContext, isSecondary:boolean) { this._context = context; @@ -25,6 +45,7 @@ export class ViewCursor { this._isInEditableRange = true; this._domNode = this._createCursorDomNode(isSecondary); + this.setStyle(CursorStyle[context.configuration.editor.cursorStyle || 'line'] || CursorStyle.line); this._isVisible = true; DomUtils.StyleMutator.setDisplay(this._domNode, 'none'); this.updatePosition({ @@ -120,6 +141,27 @@ export class ViewCursor { } } + public setStyle(style:CursorStyle): void { + if (this._cursorStyle === style) { + return; + } + this._cursorStyle = style; + + let newStyleClass = 'cursor-' + CursorStyle[style]; + if (this._domNode.classList.contains(newStyleClass)) { + return; + } + + this._domNode.classList.remove(...CursorClassNames); + this._domNode.classList.add('cursor-' + CursorStyle[style]); + } + + private removeCursorClass(c:string) { + if (this._domNode.classList.contains(c)) { + this._domNode.classList.remove(c); + } + } + private updatePosition(newPosition:EditorCommon.IPosition): void { this._position = newPosition; this._domNode.setAttribute('lineNumber', this._position.lineNumber.toString()); diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css index 0470064762634..09e5f9e1faf38 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.css @@ -8,11 +8,22 @@ } .monaco-editor .cursors-layer > .cursor { + position: absolute; + cursor: text; +} + +.monaco-editor .cursors-layer > .cursor-line { position: absolute; width: 2px; cursor: text; } +.monaco-editor .cursors-layer > .cursor-block { + position: absolute; + width: 1ch; + cursor: text; +} + .monaco-editor .cursors-layer > .cursor.secondary { width: 1px; opacity: 0.6; diff --git a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts index 92efce34b39a4..338aa43e2a303 100644 --- a/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts +++ b/src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts @@ -8,7 +8,7 @@ import 'vs/css!./viewCursors'; import Browser = require('vs/base/browser/browser'); -import {ViewCursor} from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; +import {ViewCursor, CursorStyle} from 'vs/editor/browser/viewParts/viewCursors/viewCursor'; import {ViewPart} from 'vs/editor/browser/view/viewPart'; import EditorBrowser = require('vs/editor/browser/editorBrowser'); import EditorCommon = require('vs/editor/common/editorCommon'); @@ -52,6 +52,7 @@ export class ViewCursors extends ViewPart { this._editorHasFocus = false; this._updateBlinking(); + this._updateCursorStyle(); } public dispose(): void { @@ -107,6 +108,7 @@ export class ViewCursors extends ViewPart { public onCursorPositionChanged(e:EditorCommon.IViewCursorPositionChangedEvent): boolean { this._primaryCursor.onCursorPositionChanged(e.position, e.isInEditableRange); this._updateBlinking(); + this._updateCursorStyle(); if (this._secondaryCursors.length < e.secondaryPositions.length) { // Create new cursors @@ -137,6 +139,7 @@ export class ViewCursors extends ViewPart { public onConfigurationChanged(e:EditorCommon.IConfigurationChangedEvent): boolean { this._primaryCursor.onConfigurationChanged(e); this._updateBlinking(); + this._updateCursorStyle(); for (var i = 0, len = this._secondaryCursors.length; i < len; i++) { this._secondaryCursors[i].onConfigurationChanged(e); } @@ -160,6 +163,7 @@ export class ViewCursors extends ViewPart { public onViewFocusChanged(isFocused:boolean): boolean { this._editorHasFocus = isFocused; this._updateBlinking(); + this._updateCursorStyle(); return false; } // --- end event handlers @@ -209,6 +213,15 @@ export class ViewCursors extends ViewPart { } // --- end blinking logic + private _getCursorStyle(): CursorStyle { + return CursorStyle[this._context.configuration.editor.cursorStyle || 'line'] || CursorStyle.line; + } + + private _updateCursorStyle(): void { + this._primaryCursor.setStyle(this._getCursorStyle()); + } + + private _blink(): void { if (this._isVisible) { this._hide(); diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 5d51249b8bc49..8b5b250dfe534 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -142,6 +142,7 @@ class InternalEditorOptionsHelper { scrollbar: scrollbar, overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3), cursorBlinking: opts.cursorBlinking, + cursorStyle: opts.cursorStyle, hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler), scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine), wrappingIndent: opts.wrappingIndent, @@ -238,6 +239,7 @@ class InternalEditorOptionsHelper { scrollbar: (!this._scrollbarOptsEqual(prevOpts.scrollbar, newOpts.scrollbar)), overviewRulerLanes: (prevOpts.overviewRulerLanes !== newOpts.overviewRulerLanes), cursorBlinking: (prevOpts.cursorBlinking !== newOpts.cursorBlinking), + cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle), hideCursorInOverviewRuler: (prevOpts.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler), scrollBeyondLastLine: (prevOpts.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine), wrappingIndent: (prevOpts.wrappingIndent !== newOpts.wrappingIndent), @@ -802,6 +804,12 @@ configurationRegistry.registerConfiguration({ 'default': DefaultConfig.editor.cursorBlinking, 'description': nls.localize('cursorBlinking', "Controls the cursor blinking animation, accepted values are 'blink', 'visible', and 'hidden'") }, + 'editor.cursorStyle' : { + 'type': 'string', + 'enum': ['block', 'line'], + 'default': DefaultConfig.editor.cursorStyle, + 'description': nls.localize('cursorStyle', "Controls the cursor style, accepted values are 'block' and 'line'") + }, 'editor.hideCursorInOverviewRuler' : { 'type': 'boolean', 'default': DefaultConfig.editor.hideCursorInOverviewRuler, diff --git a/src/vs/editor/common/config/defaultConfig.ts b/src/vs/editor/common/config/defaultConfig.ts index 51361684a405a..f0b29ab5a0018 100644 --- a/src/vs/editor/common/config/defaultConfig.ts +++ b/src/vs/editor/common/config/defaultConfig.ts @@ -34,6 +34,7 @@ class ConfigClass implements IConfiguration { }, overviewRulerLanes: 2, cursorBlinking: 'blink', + cursorStyle: 'line', hideCursorInOverviewRuler: false, scrollBeyondLastLine: true, automaticLayout: false, diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index c0301683a919d..c518cde42fd56 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -338,6 +338,11 @@ export interface ICommonEditorOptions { * Defaults to 'blink'. */ cursorBlinking?:string; + /** + * Control the cursor style, either 'block' or 'line'. + * Defaults to 'line'. + */ + cursorStyle?:string; /** * Should the cursor be hidden in the overview ruler. * Defaults to false. @@ -585,6 +590,7 @@ export interface IInternalEditorOptions { scrollbar:IInternalEditorScrollbarOptions; overviewRulerLanes:number; cursorBlinking:string; + cursorStyle:string; hideCursorInOverviewRuler:boolean; scrollBeyondLastLine:boolean; wrappingIndent: string; @@ -676,6 +682,7 @@ export interface IConfigurationChangedEvent { scrollbar:boolean; overviewRulerLanes:boolean; cursorBlinking:boolean; + cursorStyle:boolean; hideCursorInOverviewRuler:boolean; scrollBeyondLastLine:boolean; wrappingIndent:boolean;