Use const enums for constants
This commit is contained in:
@@ -5,15 +5,17 @@
|
|||||||
|
|
||||||
import { ICoreBrowserService } from 'browser/services/Services';
|
import { ICoreBrowserService } from 'browser/services/Services';
|
||||||
|
|
||||||
/**
|
const enum Constants {
|
||||||
* The time between cursor blinks.
|
/**
|
||||||
*/
|
* The time between cursor blinks.
|
||||||
const BLINK_INTERVAL = 600;
|
*/
|
||||||
|
BLINK_INTERVAL = 600,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The idle time after which cursor blinking stops (2 minutes).
|
* The idle time after which cursor blinking stops.
|
||||||
*/
|
*/
|
||||||
const IDLE_TIMEOUT = 5000; //2 * 60 * 1000;
|
IDLE_TIMEOUT = 5 * 60 * 1000
|
||||||
|
}
|
||||||
|
|
||||||
export class CursorBlinkStateManager {
|
export class CursorBlinkStateManager {
|
||||||
public isCursorVisible: boolean;
|
public isCursorVisible: boolean;
|
||||||
@@ -82,7 +84,7 @@ export class CursorBlinkStateManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _restartInterval(timeToStart: number = BLINK_INTERVAL): void {
|
private _restartInterval(timeToStart: number = Constants.BLINK_INTERVAL): void {
|
||||||
// Clear any existing interval
|
// Clear any existing interval
|
||||||
if (this._blinkInterval) {
|
if (this._blinkInterval) {
|
||||||
this._coreBrowserService.window.clearInterval(this._blinkInterval);
|
this._coreBrowserService.window.clearInterval(this._blinkInterval);
|
||||||
@@ -97,7 +99,7 @@ export class CursorBlinkStateManager {
|
|||||||
// Check if another animation restart was requested while this was being
|
// Check if another animation restart was requested while this was being
|
||||||
// started
|
// started
|
||||||
if (this._animationTimeRestarted) {
|
if (this._animationTimeRestarted) {
|
||||||
const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);
|
const time = Constants.BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);
|
||||||
this._animationTimeRestarted = undefined;
|
this._animationTimeRestarted = undefined;
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
this._restartInterval(time);
|
this._restartInterval(time);
|
||||||
@@ -118,7 +120,7 @@ export class CursorBlinkStateManager {
|
|||||||
if (this._animationTimeRestarted) {
|
if (this._animationTimeRestarted) {
|
||||||
// calc time diff
|
// calc time diff
|
||||||
// Make restart interval do a setTimeout initially?
|
// Make restart interval do a setTimeout initially?
|
||||||
const time = BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);
|
const time = Constants.BLINK_INTERVAL - (Date.now() - this._animationTimeRestarted);
|
||||||
this._animationTimeRestarted = undefined;
|
this._animationTimeRestarted = undefined;
|
||||||
this._restartInterval(time);
|
this._restartInterval(time);
|
||||||
return;
|
return;
|
||||||
@@ -130,7 +132,7 @@ export class CursorBlinkStateManager {
|
|||||||
this._renderCallback();
|
this._renderCallback();
|
||||||
this._animationFrame = undefined;
|
this._animationFrame = undefined;
|
||||||
});
|
});
|
||||||
}, BLINK_INTERVAL);
|
}, Constants.BLINK_INTERVAL);
|
||||||
}, timeToStart);
|
}, timeToStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +178,7 @@ export class CursorBlinkStateManager {
|
|||||||
}
|
}
|
||||||
this._idleTimeout = this._coreBrowserService.window.setTimeout(() => {
|
this._idleTimeout = this._coreBrowserService.window.setTimeout(() => {
|
||||||
this._stopBlinkingDueToIdle();
|
this._stopBlinkingDueToIdle();
|
||||||
}, IDLE_TIMEOUT);
|
}, Constants.IDLE_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,10 +26,12 @@ const FOCUS_CLASS = 'xterm-focus';
|
|||||||
const SELECTION_CLASS = 'xterm-selection';
|
const SELECTION_CLASS = 'xterm-selection';
|
||||||
const CURSOR_BLINK_IDLE_CLASS = 'xterm-cursor-blink-idle';
|
const CURSOR_BLINK_IDLE_CLASS = 'xterm-cursor-blink-idle';
|
||||||
|
|
||||||
/**
|
const enum Constants {
|
||||||
* The idle time after which cursor blinking stops (2 minutes).
|
/**
|
||||||
*/
|
* The idle time after which cursor blinking stops.
|
||||||
const IDLE_TIMEOUT = 5000; // 2 * 60 * 1000;
|
*/
|
||||||
|
IDLE_TIMEOUT = 5 * 60 * 1000
|
||||||
|
}
|
||||||
|
|
||||||
let nextTerminalId = 1;
|
let nextTerminalId = 1;
|
||||||
|
|
||||||
@@ -571,7 +573,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
this._rowContainer.classList.remove(CURSOR_BLINK_IDLE_CLASS);
|
this._rowContainer.classList.remove(CURSOR_BLINK_IDLE_CLASS);
|
||||||
this._idleTimeout = this._coreBrowserService.window.setTimeout(() => {
|
this._idleTimeout = this._coreBrowserService.window.setTimeout(() => {
|
||||||
this._stopBlinkingDueToIdle();
|
this._stopBlinkingDueToIdle();
|
||||||
}, IDLE_TIMEOUT);
|
}, Constants.IDLE_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user