Add ability to have a visual bell
This commit is contained in:
+2
-1
@@ -70,7 +70,8 @@ function createTerminal() {
|
|||||||
term = new Terminal({
|
term = new Terminal({
|
||||||
cursorBlink: optionElements.cursorBlink.checked,
|
cursorBlink: optionElements.cursorBlink.checked,
|
||||||
scrollback: parseInt(optionElements.scrollback.value, 10),
|
scrollback: parseInt(optionElements.scrollback.value, 10),
|
||||||
tabStopWidth: parseInt(optionElements.tabstopwidth.value, 10)
|
tabStopWidth: parseInt(optionElements.tabstopwidth.value, 10),
|
||||||
|
bellStyles: [1, 2]
|
||||||
});
|
});
|
||||||
term.on('resize', function (size) {
|
term.on('resize', function (size) {
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
|
|||||||
+3
-3
@@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ILinkMatcherOptions } from './Interfaces';
|
import { ILinkMatcherOptions } from './Interfaces';
|
||||||
import { LinkMatcherHandler, LinkMatcherValidationCallback, Charset, LineData } from './Types';
|
import { LinkMatcherHandler, LinkMatcherValidationCallback, Charset, LineData, BellStylesEnum } from './Types';
|
||||||
|
|
||||||
export interface IBrowser {
|
export interface IBrowser {
|
||||||
isNode: boolean;
|
isNode: boolean;
|
||||||
@@ -113,6 +113,8 @@ export interface IInputHandlingTerminal extends IEventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ITerminalOptions {
|
export interface ITerminalOptions {
|
||||||
|
bellSound?: string;
|
||||||
|
bellStyles?: BellStylesEnum[];
|
||||||
cancelEvents?: boolean;
|
cancelEvents?: boolean;
|
||||||
colors?: string[];
|
colors?: string[];
|
||||||
cols?: number;
|
cols?: number;
|
||||||
@@ -123,14 +125,12 @@ export interface ITerminalOptions {
|
|||||||
disableStdin?: boolean;
|
disableStdin?: boolean;
|
||||||
geometry?: [number, number];
|
geometry?: [number, number];
|
||||||
handler?: (data: string) => void;
|
handler?: (data: string) => void;
|
||||||
popOnBell?: boolean;
|
|
||||||
rows?: number;
|
rows?: number;
|
||||||
screenKeys?: boolean;
|
screenKeys?: boolean;
|
||||||
scrollback?: number;
|
scrollback?: number;
|
||||||
tabStopWidth?: number;
|
tabStopWidth?: number;
|
||||||
termName?: string;
|
termName?: string;
|
||||||
useFlowControl?: boolean;
|
useFlowControl?: boolean;
|
||||||
visualBell?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IBuffer {
|
export interface IBuffer {
|
||||||
|
|||||||
+15
-8
@@ -39,6 +39,8 @@ import { CHARSETS } from './Charsets';
|
|||||||
import { getRawByteCoords } from './utils/Mouse';
|
import { getRawByteCoords } from './utils/Mouse';
|
||||||
import { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData, Option, StringOption, BooleanOption, StringArrayOption, NumberOption, GeometryOption, HandlerOption } from './Types';
|
import { CustomKeyEventHandler, Charset, LinkMatcherHandler, LinkMatcherValidationCallback, CharData, LineData, Option, StringOption, BooleanOption, StringArrayOption, NumberOption, GeometryOption, HandlerOption } from './Types';
|
||||||
import { ITerminal, IBrowser, ITerminalOptions, IInputHandlingTerminal, ILinkMatcherOptions, IViewport, ICompositionHelper } from './Interfaces';
|
import { ITerminal, IBrowser, ITerminalOptions, IInputHandlingTerminal, ILinkMatcherOptions, IViewport, ICompositionHelper } from './Interfaces';
|
||||||
|
import { BellSound } from './utils/Sounds';
|
||||||
|
import { BellStyles } from './utils/BellStyles';
|
||||||
|
|
||||||
// Declare for RequireJS in loadAddon
|
// Declare for RequireJS in loadAddon
|
||||||
declare var define: any;
|
declare var define: any;
|
||||||
@@ -147,8 +149,8 @@ const DEFAULT_OPTIONS: ITerminalOptions = {
|
|||||||
geometry: [80, 24],
|
geometry: [80, 24],
|
||||||
cursorBlink: false,
|
cursorBlink: false,
|
||||||
cursorStyle: 'block',
|
cursorStyle: 'block',
|
||||||
visualBell: false,
|
bellSound: BellSound,
|
||||||
popOnBell: false,
|
bellStyles: [BellStyles.Sound],
|
||||||
scrollback: 1000,
|
scrollback: 1000,
|
||||||
screenKeys: false,
|
screenKeys: false,
|
||||||
debug: false,
|
debug: false,
|
||||||
@@ -1882,12 +1884,17 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
* Note: We could do sweet things with webaudio here
|
* Note: We could do sweet things with webaudio here
|
||||||
*/
|
*/
|
||||||
public bell(): void {
|
public bell(): void {
|
||||||
if (!this.options.visualBell) return;
|
this.emit('bell');
|
||||||
this.element.style.borderColor = 'white';
|
if (this.options.bellStyles.indexOf(BellStyles.Sound) > -1) {
|
||||||
setTimeout(() => {
|
this.bellAudioElement.play();
|
||||||
this.element.style.borderColor = '';
|
}
|
||||||
}, 10);
|
if (this.options.bellStyles.indexOf(BellStyles.Visual) > -1) {
|
||||||
if (this.options.popOnBell) this.focus();
|
var cursor = this.element.querySelector('.terminal-cursor') as HTMLElement;
|
||||||
|
cursor.style.backgroundColor = "#fff";
|
||||||
|
setTimeout(function() {
|
||||||
|
cursor.style.backgroundColor = "#e6e6e6";
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+5
-3
@@ -2,6 +2,8 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { BellStyles } from './utils/BellStyles';
|
||||||
|
|
||||||
export type LinkMatcher = {
|
export type LinkMatcher = {
|
||||||
id: number,
|
id: number,
|
||||||
regex: RegExp,
|
regex: RegExp,
|
||||||
@@ -26,10 +28,8 @@ export type BooleanOption =
|
|||||||
'cursorBlink' |
|
'cursorBlink' |
|
||||||
'debug' |
|
'debug' |
|
||||||
'disableStdin' |
|
'disableStdin' |
|
||||||
'popOnBell' |
|
|
||||||
'screenKeys' |
|
'screenKeys' |
|
||||||
'useFlowControl' |
|
'useFlowControl';
|
||||||
'visualBell';
|
|
||||||
export type StringOption =
|
export type StringOption =
|
||||||
'cursorStyle' |
|
'cursorStyle' |
|
||||||
'termName';
|
'termName';
|
||||||
@@ -41,3 +41,5 @@ export type NumberOption =
|
|||||||
'scrollback';
|
'scrollback';
|
||||||
export type GeometryOption = 'geometry';
|
export type GeometryOption = 'geometry';
|
||||||
export type HandlerOption = 'handler';
|
export type HandlerOption = 'handler';
|
||||||
|
|
||||||
|
export type BellStylesEnum = BellStyles;
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export enum BellStyles {
|
||||||
|
None,
|
||||||
|
Sound,
|
||||||
|
Visual
|
||||||
|
}
|
||||||
+3
-3
@@ -94,12 +94,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.terminal:not(.focus) .terminal-cursor {
|
.terminal:not(.focus) .terminal-cursor {
|
||||||
outline: 1px solid #fff;
|
outline: 1px solid #e6e6e6;
|
||||||
outline-offset: -1px;
|
outline-offset: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal.xterm-cursor-style-block.focus:not(.xterm-cursor-blink-on) .terminal-cursor {
|
.terminal.xterm-cursor-style-block.focus:not(.xterm-cursor-blink-on) .terminal-cursor {
|
||||||
background-color: #fff;
|
background-color: #e6e6e6;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
.terminal.focus.xterm-cursor-style-underline:not(.xterm-cursor-blink-on) .terminal-cursor::before {
|
.terminal.focus.xterm-cursor-style-underline:not(.xterm-cursor-blink-on) .terminal-cursor::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: #fff;
|
background-color: ##e6e6e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.terminal.focus.xterm-cursor-style-bar:not(.xterm-cursor-blink-on) .terminal-cursor::before {
|
.terminal.focus.xterm-cursor-style-bar:not(.xterm-cursor-blink-on) .terminal-cursor::before {
|
||||||
|
|||||||
Reference in New Issue
Block a user