Skip to content

Commit

Permalink
Merge pull request #500 from Protectator/master
Browse files Browse the repository at this point in the history
Adding option to configure cursor blinking
  • Loading branch information
alexdima committed Dec 4, 2015
2 parents 483ffb3 + 5568b56 commit 4383c34
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/vs/editor/browser/viewParts/viewCursors/viewCursors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class ViewCursors extends ViewPart {
}
public onConfigurationChanged(e:EditorCommon.IConfigurationChangedEvent): boolean {
this._primaryCursor.onConfigurationChanged(e);
this._updateBlinking();
for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
this._secondaryCursors[i].onConfigurationChanged(e);
}
Expand Down Expand Up @@ -172,7 +173,16 @@ export class ViewCursors extends ViewPart {
private _getRenderType(): RenderType {
if (this._editorHasFocus) {
if (this._primaryCursor.getIsInEditableRange() && !this._context.configuration.editor.readOnly) {
return RenderType.Blink;
switch (this._context.configuration.editor.cursorBlinking) {
case ("blink"):
return RenderType.Blink;
case ("visible"):
return RenderType.Visible;
case ("hidden"):
return RenderType.Hidden;
default:
return RenderType.Blink;
}
}
return RenderType.Visible;
}
Expand Down
8 changes: 8 additions & 0 deletions src/vs/editor/common/config/commonEditorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class InternalEditorOptionsHelper {
readOnly: toBoolean(opts.readOnly),
scrollbar: scrollbar,
overviewRulerLanes: toInteger(opts.overviewRulerLanes, 0, 3),
cursorBlinking: opts.cursorBlinking,
hideCursorInOverviewRuler: toBoolean(opts.hideCursorInOverviewRuler),
scrollBeyondLastLine: toBoolean(opts.scrollBeyondLastLine),
wrappingIndent: opts.wrappingIndent,
Expand Down Expand Up @@ -236,6 +237,7 @@ class InternalEditorOptionsHelper {
readOnly: (prevOpts.readOnly !== newOpts.readOnly),
scrollbar: (!this._scrollbarOptsEqual(prevOpts.scrollbar, newOpts.scrollbar)),
overviewRulerLanes: (prevOpts.overviewRulerLanes !== newOpts.overviewRulerLanes),
cursorBlinking: (prevOpts.cursorBlinking !== newOpts.cursorBlinking),
hideCursorInOverviewRuler: (prevOpts.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler),
scrollBeyondLastLine: (prevOpts.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine),
wrappingIndent: (prevOpts.wrappingIndent !== newOpts.wrappingIndent),
Expand Down Expand Up @@ -794,6 +796,12 @@ configurationRegistry.registerConfiguration({
'default': 3,
'description': nls.localize('overviewRulerLanes', "Controls the number of decorations that can show up at the same position in the overview ruler")
},
'editor.cursorBlinking' : {
'type': 'string',
'enum': ['blink', 'visible', 'hidden'],
'default': DefaultConfig.editor.cursorBlinking,
'description': nls.localize('cursorBlinking', "Controls the cursor blinking animation.")
},
'editor.hideCursorInOverviewRuler' : {
'type': 'boolean',
'default': DefaultConfig.editor.hideCursorInOverviewRuler,
Expand Down
1 change: 1 addition & 0 deletions src/vs/editor/common/config/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ConfigClass implements IConfiguration {
horizontalHasArrows: false
},
overviewRulerLanes: 2,
cursorBlinking: 'blink',
hideCursorInOverviewRuler: false,
scrollBeyondLastLine: true,
automaticLayout: false,
Expand Down
7 changes: 7 additions & 0 deletions src/vs/editor/common/editorCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ export interface ICommonEditorOptions {
* Defaults to 2.
*/
overviewRulerLanes?:number;
/**
* Control the cursor blinking animation.
* Defaults to 'blink'.
*/
cursorBlinking?:string;
/**
* Should the cursor be hidden in the overview ruler.
* Defaults to false.
Expand Down Expand Up @@ -577,6 +582,7 @@ export interface IInternalEditorOptions {
readOnly:boolean;
scrollbar:IInternalEditorScrollbarOptions;
overviewRulerLanes:number;
cursorBlinking:string;
hideCursorInOverviewRuler:boolean;
scrollBeyondLastLine:boolean;
wrappingIndent: string;
Expand Down Expand Up @@ -667,6 +673,7 @@ export interface IConfigurationChangedEvent {
readOnly:boolean;
scrollbar:boolean;
overviewRulerLanes:boolean;
cursorBlinking:boolean;
hideCursorInOverviewRuler:boolean;
scrollBeyondLastLine:boolean;
wrappingIndent:boolean;
Expand Down

0 comments on commit 4383c34

Please sign in to comment.