Skip to content

Commit 777a464

Browse files
authored
Merge pull request #5609 from xtermjs/merogge/show-cursor
add `showCursorImmediately` option
2 parents d28046e + a20ff56 commit 777a464

6 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/common/services/CoreService.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ describe('CoreService', () => {
1818
new MockOptionsService());
1919
});
2020

21+
describe('isCursorInitialized', () => {
22+
it('should be false by default', () => {
23+
assert.equal(coreService.isCursorInitialized, false);
24+
});
25+
it('should be true when showCursorImmediately is true', () => {
26+
const coreServiceWithOption = new CoreService(
27+
new MockBufferService(80, 30),
28+
new MockLogService(),
29+
new MockOptionsService({ showCursorImmediately: true }));
30+
assert.equal(coreServiceWithOption.isCursorInitialized, true);
31+
});
32+
});
33+
2134
describe('reset', () => {
2235
it('should not affect isCursorInitialized', () => {
2336
coreService.isCursorInitialized = true;

src/common/services/CoreService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const DEFAULT_KITTY_KEYBOARD_STATE = (): IKittyKeyboardState => ({
3838
export class CoreService extends Disposable implements ICoreService {
3939
public serviceBrand: any;
4040

41-
public isCursorInitialized: boolean = false;
41+
public isCursorInitialized: boolean;
4242
public isCursorHidden: boolean = false;
4343
public modes: IModes;
4444
public decPrivateModes: IDecPrivateModes;
@@ -59,6 +59,7 @@ export class CoreService extends Disposable implements ICoreService {
5959
@IOptionsService private readonly _optionsService: IOptionsService
6060
) {
6161
super();
62+
this.isCursorInitialized = _optionsService.rawOptions.showCursorImmediately ?? false;
6263
this.modes = clone(DEFAULT_MODES);
6364
this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES);
6465
this.kittyKeyboard = DEFAULT_KITTY_KEYBOARD_STATE();

src/common/services/OptionsService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Emitter } from 'vs/base/common/event';
1212
export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
1313
cols: 80,
1414
rows: 24,
15+
showCursorImmediately: false,
1516
cursorBlink: false,
1617
cursorStyle: 'block',
1718
cursorWidth: 1,

src/common/services/Services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export interface ITerminalOptions {
253253
rescaleOverlappingGlyphs?: boolean;
254254
rightClickSelectsWord?: boolean;
255255
rows?: number;
256+
showCursorImmediately?: boolean;
256257
screenReaderMode?: boolean;
257258
scrollback?: number;
258259
scrollOnUserInput?: boolean;

typings/xterm-headless.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ declare module '@xterm/headless' {
252252
* The number of rows in the terminal.
253253
*/
254254
rows?: number;
255+
256+
/**
257+
* Whether to show the cursor immediately when the terminal is created.
258+
* When false (default), the cursor will not be visible until the terminal
259+
* is focused for the first time.
260+
*/
261+
showCursorImmediately?: boolean;
255262
}
256263

257264
/**

typings/xterm.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ declare module '@xterm/xterm' {
340340
* The number of rows in the terminal.
341341
*/
342342
rows?: number;
343+
344+
/**
345+
* Whether to show the cursor immediately when the terminal is created.
346+
* When false (default), the cursor will not be visible until the terminal
347+
* is focused for the first time.
348+
*/
349+
showCursorImmediately?: boolean;
343350
}
344351

345352
/**

0 commit comments

Comments
 (0)