@@ -10,6 +10,8 @@ import { CellData } from 'common/buffer/CellData';
1010import { IColorSet , ITerminal } from 'browser/Types' ;
1111import { IRenderDimensions , IRequestRedrawEvent } from 'browser/renderer/Types' ;
1212import { IEventEmitter } from 'common/EventEmitter' ;
13+ import { ICoreBrowserService } from 'browser/services/Services' ;
14+ import { ICoreService } from 'common/services/Services' ;
1315
1416interface ICursorState {
1517x :number ;
@@ -35,8 +37,9 @@ export class CursorRenderLayer extends BaseRenderLayer {
3537container :HTMLElement ,
3638zIndex :number ,
3739colors :IColorSet ,
38- private readonly _terminal :ITerminal ,
39- private _onRequestRefreshRowsEvent :IEventEmitter < IRequestRedrawEvent >
40+ private _onRequestRefreshRowsEvent :IEventEmitter < IRequestRedrawEvent > ,
41+ private readonly _coreBrowserService :ICoreBrowserService ,
42+ private readonly _coreService :ICoreService
4043) {
4144super ( container , 'cursor' , zIndex , true , colors ) ;
4245this . _state = {
@@ -91,9 +94,9 @@ export class CursorRenderLayer extends BaseRenderLayer {
9194public onOptionsChanged ( terminal :Terminal ) :void {
9295if ( terminal . options . cursorBlink ) {
9396if ( ! this . _cursorBlinkStateManager ) {
94- this . _cursorBlinkStateManager = new CursorBlinkStateManager ( terminal , ( ) => {
97+ this . _cursorBlinkStateManager = new CursorBlinkStateManager ( ( ) => {
9598this . _render ( terminal , true ) ;
96- } ) ;
99+ } , this . _coreBrowserService ) ;
97100}
98101} else {
99102this . _cursorBlinkStateManager ?. dispose ( ) ;
@@ -118,8 +121,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
118121
119122private _render ( terminal :Terminal , triggeredByAnimationFrame :boolean ) :void {
120123// Don't draw the cursor if it's hidden
121- // TODO: Need to expose API for this
122- if ( ! this . _terminal . coreService . isCursorInitialized || this . _terminal . coreService . isCursorHidden ) {
124+ if ( ! this . _coreService . isCursorInitialized || this . _coreService . isCursorHidden ) {
123125this . _clearCursor ( ) ;
124126return ;
125127}
@@ -142,7 +144,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
142144return ;
143145}
144146
145- if ( ! isTerminalFocused ( terminal ) ) {
147+ if ( ! this . _coreBrowserService . isFocused ) {
146148this . _clearCursor ( ) ;
147149this . _ctx . save ( ) ;
148150this . _ctx . fillStyle = this . _colors . cursor . css ;
@@ -171,7 +173,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
171173// The cursor is already in the correct spot, don't redraw
172174if ( this . _state . x === cursorX &&
173175this . _state . y === viewportRelativeCursorY &&
174- this . _state . isFocused === isTerminalFocused ( terminal ) &&
176+ this . _state . isFocused === this . _coreBrowserService . isFocused &&
175177this . _state . style === terminal . options . cursorStyle &&
176178this . _state . width === this . _cell . getWidth ( ) ) {
177179return ;
@@ -254,11 +256,11 @@ class CursorBlinkStateManager {
254256private _animationTimeRestarted :number | undefined ;
255257
256258constructor (
257- terminal : Terminal ,
258- private _renderCallback : ( ) => void
259+ private _renderCallback : ( ) => void ,
260+ coreBrowserService : ICoreBrowserService
259261) {
260262this . isCursorVisible = true ;
261- if ( isTerminalFocused ( terminal ) ) {
263+ if ( coreBrowserService . isFocused ) {
262264this . _restartInterval ( ) ;
263265}
264266}
@@ -373,7 +375,3 @@ class CursorBlinkStateManager {
373375this . restartBlinkAnimation ( terminal ) ;
374376}
375377}
376-
377- function isTerminalFocused ( terminal :Terminal ) :boolean {
378- return document . activeElement === terminal . textarea && document . hasFocus ( ) ;
379- }