mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Give terminal options a proper interface
This commit is contained in:
@@ -50,6 +50,27 @@ export interface ITerminal {
|
||||
showCursor(): void;
|
||||
}
|
||||
|
||||
export interface ITerminalOptions {
|
||||
cancelEvents?: boolean;
|
||||
colors?: string[];
|
||||
cols?: number;
|
||||
convertEol?: boolean;
|
||||
cursorBlink?: boolean;
|
||||
cursorStyle?: string;
|
||||
debug?: boolean;
|
||||
disableStdin?: boolean;
|
||||
geometry?: [number, number];
|
||||
handler?: (data: string) => void;
|
||||
popOnBell?: boolean;
|
||||
rows?: number;
|
||||
screenKeys?: boolean;
|
||||
scrollback?: number;
|
||||
tabStopWidth?: number;
|
||||
termName?: string;
|
||||
useFlowControl?: boolean;
|
||||
visualBell?: boolean;
|
||||
}
|
||||
|
||||
export interface IBuffer {
|
||||
lines: ICircularList<[number, string, number][]>;
|
||||
ydisp: number;
|
||||
|
||||
+10
-9
@@ -29,8 +29,8 @@ import * as Mouse from './utils/Mouse';
|
||||
import { CHARSETS } from './Charsets';
|
||||
import { getRawByteCoords } from './utils/Mouse';
|
||||
import { translateBufferLineToString } from './utils/BufferLine';
|
||||
import { TerminalOptions, CustomKeyEventHandler, Charset } from './Types';
|
||||
import { ITerminal, IBrowser } from './Interfaces';
|
||||
import { CustomKeyEventHandler, Charset } from './Types';
|
||||
import { ITerminal, IBrowser, ITerminalOptions } from './Interfaces';
|
||||
|
||||
// Declare for RequireJS in loadAddon
|
||||
declare var define: any;
|
||||
@@ -71,7 +71,7 @@ const CURSOR_BLINK_INTERVAL = 600;
|
||||
|
||||
// TODO: Most of the color code should be removed after truecolor is implemented
|
||||
// Colors 0-15
|
||||
const tangoColors = [
|
||||
const tangoColors: string[] = [
|
||||
// dark:
|
||||
'#2e3436',
|
||||
'#cc0000',
|
||||
@@ -94,7 +94,7 @@ const tangoColors = [
|
||||
|
||||
// Colors 0-15 + 16-255
|
||||
// Much thanks to TooTallNate for writing this.
|
||||
const defaultColors = (function() {
|
||||
const defaultColors: string[] = (function() {
|
||||
let colors = tangoColors.slice();
|
||||
let r = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
|
||||
let i;
|
||||
@@ -125,9 +125,9 @@ const defaultColors = (function() {
|
||||
return colors;
|
||||
})();
|
||||
|
||||
const _colors = defaultColors.slice();
|
||||
const _colors: string[] = defaultColors.slice();
|
||||
|
||||
const vcolors = (function() {
|
||||
const vcolors: number[][] = (function() {
|
||||
const out = [];
|
||||
let color;
|
||||
|
||||
@@ -143,7 +143,7 @@ const vcolors = (function() {
|
||||
return out;
|
||||
})();
|
||||
|
||||
const DEFAULT_OPTIONS: TerminalOptions = {
|
||||
const DEFAULT_OPTIONS: ITerminalOptions = {
|
||||
colors: defaultColors,
|
||||
convertEol: false,
|
||||
termName: 'xterm',
|
||||
@@ -186,7 +186,7 @@ export class Terminal extends EventEmitter implements ITerminal {
|
||||
public browser: IBrowser = <any>Browser;
|
||||
|
||||
// TODO: Options should be private, remove from interface in favor of getOption
|
||||
public options: TerminalOptions;
|
||||
public options: ITerminalOptions;
|
||||
private colors: any;
|
||||
|
||||
// TODO: This can be changed to an enum or boolean, 0 and 1 seem to be the only options
|
||||
@@ -294,7 +294,7 @@ export class Terminal extends EventEmitter implements ITerminal {
|
||||
* @alias module:xterm/src/xterm
|
||||
*/
|
||||
constructor(
|
||||
options: any = {}
|
||||
options: ITerminalOptions = {}
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -2269,6 +2269,7 @@ export class Terminal extends EventEmitter implements ITerminal {
|
||||
const cursorBlinkInterval = this.cursorBlinkInterval;
|
||||
const inputHandler = this.inputHandler;
|
||||
const buffers = this.buffers;
|
||||
// TODO: Need to make sure this still works
|
||||
Terminal.call(this, this.options);
|
||||
this.customKeyEventHandler = customKeyEventHandler;
|
||||
this.cursorBlinkInterval = cursorBlinkInterval;
|
||||
|
||||
@@ -13,7 +13,5 @@ export type LinkMatcher = {
|
||||
export type LinkMatcherHandler = (event: MouseEvent, uri: string) => boolean | void;
|
||||
export type LinkMatcherValidationCallback = (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => void;
|
||||
|
||||
// TODO: Make this type more specific
|
||||
export type TerminalOptions = {[key: string]: any};
|
||||
export type CustomKeyEventHandler = (event: KeyboardEvent) => boolean;
|
||||
export type Charset = {[key: string]: string};
|
||||
|
||||
Reference in New Issue
Block a user