diff --git a/demo/client.ts b/demo/client.ts index 1c38af0f..9dd04a74 100644 --- a/demo/client.ts +++ b/demo/client.ts @@ -173,6 +173,7 @@ function createTerminal(): void { const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].indexOf(navigator.platform) >= 0; term = new Terminal({ + allowTransparency: true, windowsMode: isWindows, fontFamily: 'Fira Code, courier-new, courier, monospace' } as ITerminalOptions); diff --git a/src/common/Types.d.ts b/src/common/Types.d.ts index c48b23ea..94058a58 100644 --- a/src/common/Types.d.ts +++ b/src/common/Types.d.ts @@ -35,6 +35,8 @@ export interface ITerminalOptions extends IPublicTerminalOptions { termName?: string; } +export type CursorStyle = 'block' | 'underline' | 'bar'; + export type XtermListener = (...args: any[]) => void; /** diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 4008a431..4f9600a4 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -6,6 +6,7 @@ import { IOptionsService, ITerminalOptions, FontWeight } from 'common/services/Services'; import { EventEmitter, IEvent } from 'common/EventEmitter'; import { isMac } from 'common/Platform'; +import { CursorStyle } from 'common/Types'; // Source: https://freesound.org/people/altemark/sounds/45759/ // This sound is released under the Creative Commons Attribution 3.0 Unported @@ -123,6 +124,14 @@ export class OptionsService implements IOptionsService { private _sanitizeAndValidateOption(key: string, value: any): any { switch (key) { + case 'cursorStyle': + if (!value) { + value = DEFAULT_OPTIONS[key]; + } + if (!isCursorStyle(value)) { + throw new Error(`"${value}" is not a valid value for ${key}`); + } + break; case 'bellStyle': case 'cursorStyle': case 'rendererType': @@ -176,3 +185,7 @@ export class OptionsService implements IOptionsService { return this.options[key]; } } + +function isCursorStyle(value: unknown): value is CursorStyle { + return value === 'block' || value === 'underline' || value === 'bar'; +} diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 017eb386..b4536eb1 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -5,7 +5,7 @@ import { IEvent, IEventEmitter } from 'common/EventEmitter'; import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColorRGB, IColor } from 'common/Types'; +import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColorRGB, IColor, CursorStyle } from 'common/Types'; import { createDecorator } from 'common/services/ServiceRegistry'; import { IDecorationOptions, IDecoration } from 'xterm'; @@ -217,7 +217,7 @@ export interface ITerminalOptions { cols: number; convertEol: boolean; cursorBlink: boolean; - cursorStyle: 'block' | 'underline' | 'bar'; + cursorStyle: CursorStyle, cursorWidth: number; customGlyphs: boolean; disableStdin: boolean;