mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge branch 'v3' into zmodem
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# [](https://xtermjs.org)
|
||||
|
||||
[](https://travis-ci.org/sourcelair/xterm.js) [](https://coveralls.io/github/sourcelair/xterm.js) [](https://gitter.im/sourcelair/xterm.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
[](https://travis-ci.org/sourcelair/xterm.js) [](https://coveralls.io/github/sourcelair/xterm.js) [](https://gitter.im/sourcelair/xterm.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://www.jsdelivr.com/package/npm/xterm)
|
||||
|
||||
Xterm.js is a terminal front-end component written in JavaScript that works in the browser.
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@ namespace methods_core {
|
||||
const r18: (data: string) => void = t.getOption('handler');
|
||||
const r19: string = t.getOption('bellSound');
|
||||
const r20: string = t.getOption('bellStyle');
|
||||
const r21: boolean = t.getOption('enableBold');
|
||||
const r22: number = t.getOption('letterSpacing');
|
||||
}
|
||||
{
|
||||
@@ -153,6 +154,7 @@ namespace methods_core {
|
||||
t.setOption('cursorBlink', true);
|
||||
t.setOption('debug', true);
|
||||
t.setOption('disableStdin', true);
|
||||
t.setOption('enableBold', true);
|
||||
t.setOption('popOnBell', true);
|
||||
t.setOption('screenKeys', true);
|
||||
t.setOption('useFlowControl', true);
|
||||
|
||||
@@ -135,6 +135,7 @@ export interface ITerminalOptions {
|
||||
cursorStyle?: string;
|
||||
debug?: boolean;
|
||||
disableStdin?: boolean;
|
||||
enableBold?: boolean;
|
||||
fontSize?: number;
|
||||
fontFamily?: string;
|
||||
geometry?: [number, number];
|
||||
|
||||
@@ -77,6 +77,7 @@ const DEFAULT_OPTIONS: ITerminalOptions = {
|
||||
cursorStyle: 'block',
|
||||
bellSound: BellSound,
|
||||
bellStyle: 'none',
|
||||
enableBold: true,
|
||||
fontFamily: 'courier-new, courier, monospace',
|
||||
fontSize: 15,
|
||||
lineHeight: 1.0,
|
||||
@@ -411,6 +412,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
this.renderer.clear();
|
||||
this.charMeasure.measure(this.options);
|
||||
break;
|
||||
case 'enableBold':
|
||||
case 'letterSpacing':
|
||||
case 'lineHeight':
|
||||
// When the font changes the size of the cells may change which requires a renderer clear
|
||||
|
||||
@@ -170,6 +170,9 @@ export class MouseZoneManager implements IMouseZoneManager {
|
||||
|
||||
private _findZoneEventAt(e: MouseEvent): IMouseZone {
|
||||
const coords = this._terminal.mouseHelper.getCoords(e, this._terminal.element, this._terminal.charMeasure, this._terminal.options.lineHeight, this._terminal.cols, this._terminal.rows);
|
||||
if (!coords) {
|
||||
return null;
|
||||
}
|
||||
for (let i = 0; i < this._zones.length; i++) {
|
||||
const zone = this._zones[i];
|
||||
if (zone.y === coords[1] && zone.x1 <= coords[0] && zone.x2 > coords[0]) {
|
||||
|
||||
@@ -230,14 +230,14 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
colorIndex = fg + 2;
|
||||
} else {
|
||||
// If default color and bold
|
||||
if (bold) {
|
||||
if (bold && terminal.options.enableBold) {
|
||||
colorIndex = 1;
|
||||
}
|
||||
}
|
||||
const isAscii = code < 256;
|
||||
// A color is basic if it is one of the standard normal or bold weight
|
||||
// colors of the characters held in the char atlas. Note that this excludes
|
||||
// the normal weight light color characters
|
||||
// the normal weight _light_ color characters.
|
||||
const isBasicColor = (colorIndex > 1 && fg < 16) && (fg < 8 || bold);
|
||||
const isDefaultColor = fg >= 256;
|
||||
const isDefaultBackground = bg >= 256;
|
||||
@@ -245,10 +245,20 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
// ImageBitmap's draw about twice as fast as from a canvas
|
||||
const charAtlasCellWidth = this._scaledCharWidth + CHAR_ATLAS_CELL_SPACING;
|
||||
const charAtlasCellHeight = this._scaledCharHeight + CHAR_ATLAS_CELL_SPACING;
|
||||
|
||||
// Apply alpha to dim the character
|
||||
if (dim) {
|
||||
this._ctx.globalAlpha = DIM_OPACITY;
|
||||
}
|
||||
|
||||
// Draw the non-bold version of the same color if bold is not enabled
|
||||
if (bold && !terminal.options.enableBold) {
|
||||
// Ignore default color as it's not touched above
|
||||
if (colorIndex > 1) {
|
||||
colorIndex -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
this._ctx.drawImage(this._charAtlas,
|
||||
code * charAtlasCellWidth,
|
||||
colorIndex * charAtlasCellHeight,
|
||||
@@ -280,7 +290,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
|
||||
private _drawUncachedChar(terminal: ITerminal, char: string, width: number, fg: number, x: number, y: number, bold: boolean, dim: boolean): void {
|
||||
this._ctx.save();
|
||||
this._ctx.font = `${terminal.options.fontSize * window.devicePixelRatio}px ${terminal.options.fontFamily}`;
|
||||
if (bold) {
|
||||
if (bold && terminal.options.enableBold) {
|
||||
this._ctx.font = `bold ${this._ctx.font}`;
|
||||
}
|
||||
this._ctx.textBaseline = 'top';
|
||||
|
||||
+13
-13
@@ -35,7 +35,7 @@
|
||||
* Default styles for xterm.js
|
||||
*/
|
||||
|
||||
.terminal {
|
||||
.xterm {
|
||||
font-family: courier-new, courier, monospace;
|
||||
font-feature-settings: "liga" 0;
|
||||
position: relative;
|
||||
@@ -44,12 +44,12 @@
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.terminal.focus,
|
||||
.terminal:focus {
|
||||
.xterm.focus,
|
||||
.xterm:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.terminal .xterm-helpers {
|
||||
.xterm .xterm-helpers {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
/**
|
||||
@@ -59,7 +59,7 @@
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.terminal .xterm-helper-textarea {
|
||||
.xterm .xterm-helper-textarea {
|
||||
/*
|
||||
* HACK: to fix IE's blinking cursor
|
||||
* Move textarea out of the screen to the far left, so that the cursor is not visible.
|
||||
@@ -77,7 +77,7 @@
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.terminal .composition-view {
|
||||
.xterm .composition-view {
|
||||
/* TODO: Composition position got messed up somewhere */
|
||||
background: #000;
|
||||
color: #FFF;
|
||||
@@ -87,38 +87,38 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.terminal .composition-view.active {
|
||||
.xterm .composition-view.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.terminal .xterm-viewport {
|
||||
.xterm .xterm-viewport {
|
||||
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||
background-color: #000;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.terminal canvas {
|
||||
.xterm canvas {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.terminal .xterm-scroll-area {
|
||||
.xterm .xterm-scroll-area {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.terminal .xterm-char-measure-element {
|
||||
.xterm .xterm-char-measure-element {
|
||||
display: inline-block;
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
left: -9999em;
|
||||
}
|
||||
|
||||
.terminal.enable-mouse-events {
|
||||
.xterm.enable-mouse-events {
|
||||
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.terminal:not(.enable-mouse-events) {
|
||||
.xterm:not(.enable-mouse-events) {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
Vendored
+166
-161
@@ -7,166 +7,171 @@
|
||||
* to be stable and consumed by external programs.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An object containing start up options for the terminal.
|
||||
*/
|
||||
interface ITerminalOptions {
|
||||
/**
|
||||
* A data uri of the sound to use for the bell (needs bellStyle = 'sound').
|
||||
*/
|
||||
bellSound?: string;
|
||||
|
||||
/**
|
||||
* The type of the bell notification the terminal will use.
|
||||
*/
|
||||
bellStyle?: 'none' | 'visual' | 'sound' | 'both';
|
||||
|
||||
/**
|
||||
* The number of columns in the terminal.
|
||||
*/
|
||||
cols?: number;
|
||||
|
||||
/**
|
||||
* Whether the cursor blinks.
|
||||
*/
|
||||
cursorBlink?: boolean;
|
||||
|
||||
/**
|
||||
* The style of the cursor.
|
||||
*/
|
||||
cursorStyle?: 'block' | 'underline' | 'bar';
|
||||
|
||||
/**
|
||||
* Whether input should be disabled.
|
||||
*/
|
||||
disableStdin?: boolean;
|
||||
|
||||
/**
|
||||
* The font size used to render text.
|
||||
*/
|
||||
fontSize?: number;
|
||||
|
||||
/**
|
||||
* The font family used to render text.
|
||||
*/
|
||||
fontFamily?: string;
|
||||
|
||||
/**
|
||||
* The spacing in whole pixels between characters..
|
||||
*/
|
||||
letterSpacing?: number;
|
||||
|
||||
/**
|
||||
* The line height used to render text.
|
||||
*/
|
||||
lineHeight?: number;
|
||||
|
||||
/**
|
||||
* The number of rows in the terminal.
|
||||
*/
|
||||
rows?: number;
|
||||
|
||||
/**
|
||||
* The amount of scrollback in the terminal. Scrollback is the amount of rows
|
||||
* that are retained when lines are scrolled beyond the initial viewport.
|
||||
*/
|
||||
scrollback?: number;
|
||||
|
||||
/**
|
||||
* The size of tab stops in the terminal.
|
||||
*/
|
||||
tabStopWidth?: number;
|
||||
|
||||
/**
|
||||
* The color theme of the terminal.
|
||||
*/
|
||||
theme?: ITheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains colors to theme the terminal with.
|
||||
*/
|
||||
interface ITheme {
|
||||
/** The default foreground color */
|
||||
foreground?: string,
|
||||
/** The default background color */
|
||||
background?: string,
|
||||
/** The cursor color */
|
||||
cursor?: string,
|
||||
/** The accent color of the cursor (used as the foreground color for a block cursor) */
|
||||
cursorAccent?: string,
|
||||
/** The selection color (can be transparent) */
|
||||
selection?: string,
|
||||
/** ANSI black (eg. `\x1b[30m`) */
|
||||
black?: string,
|
||||
/** ANSI red (eg. `\x1b[31m`) */
|
||||
red?: string,
|
||||
/** ANSI green (eg. `\x1b[32m`) */
|
||||
green?: string,
|
||||
/** ANSI yellow (eg. `\x1b[33m`) */
|
||||
yellow?: string,
|
||||
/** ANSI blue (eg. `\x1b[34m`) */
|
||||
blue?: string,
|
||||
/** ANSI magenta (eg. `\x1b[35m`) */
|
||||
magenta?: string,
|
||||
/** ANSI cyan (eg. `\x1b[36m`) */
|
||||
cyan?: string,
|
||||
/** ANSI white (eg. `\x1b[37m`) */
|
||||
white?: string,
|
||||
/** ANSI bright black (eg. `\x1b[1;30m`) */
|
||||
brightBlack?: string,
|
||||
/** ANSI bright red (eg. `\x1b[1;31m`) */
|
||||
brightRed?: string,
|
||||
/** ANSI bright green (eg. `\x1b[1;32m`) */
|
||||
brightGreen?: string,
|
||||
/** ANSI bright yellow (eg. `\x1b[1;33m`) */
|
||||
brightYellow?: string,
|
||||
/** ANSI bright blue (eg. `\x1b[1;34m`) */
|
||||
brightBlue?: string,
|
||||
/** ANSI bright magenta (eg. `\x1b[1;35m`) */
|
||||
brightMagenta?: string,
|
||||
/** ANSI bright cyan (eg. `\x1b[1;36m`) */
|
||||
brightCyan?: string,
|
||||
/** ANSI bright white (eg. `\x1b[1;37m`) */
|
||||
brightWhite?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* An object containing options for a link matcher.
|
||||
*/
|
||||
interface ILinkMatcherOptions {
|
||||
/**
|
||||
* The index of the link from the regex.match(text) call. This defaults to 0
|
||||
* (for regular expressions without capture groups).
|
||||
*/
|
||||
matchIndex?: number;
|
||||
|
||||
/**
|
||||
* A callback that validates an individual link, returning true if valid and
|
||||
* false if invalid.
|
||||
*/
|
||||
validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void;
|
||||
|
||||
/**
|
||||
* A callback that fires when the mouse hovers over a link for a moment.
|
||||
*/
|
||||
tooltipCallback?: (event: MouseEvent, uri: string) => boolean | void;
|
||||
|
||||
/**
|
||||
* A callback that fires when the mouse leaves a link. Note that this can
|
||||
* happen even when tooltipCallback hasn't fired for the link yet.
|
||||
*/
|
||||
leaveCallback?: (event: MouseEvent, uri: string) => boolean | void;
|
||||
|
||||
/**
|
||||
* The priority of the link matcher, this defines the order in which the link
|
||||
* matcher is evaluated relative to others, from highest to lowest. The
|
||||
* default value is 0.
|
||||
*/
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
declare module 'xterm' {
|
||||
/**
|
||||
* An object containing start up options for the terminal.
|
||||
*/
|
||||
interface ITerminalOptions {
|
||||
/**
|
||||
* A data uri of the sound to use for the bell (needs bellStyle = 'sound').
|
||||
*/
|
||||
bellSound?: string;
|
||||
|
||||
/**
|
||||
* The type of the bell notification the terminal will use.
|
||||
*/
|
||||
bellStyle?: 'none' | 'visual' | 'sound' | 'both';
|
||||
|
||||
/**
|
||||
* The number of columns in the terminal.
|
||||
*/
|
||||
cols?: number;
|
||||
|
||||
/**
|
||||
* Whether the cursor blinks.
|
||||
*/
|
||||
cursorBlink?: boolean;
|
||||
|
||||
/**
|
||||
* The style of the cursor.
|
||||
*/
|
||||
cursorStyle?: 'block' | 'underline' | 'bar';
|
||||
|
||||
/**
|
||||
* Whether input should be disabled.
|
||||
*/
|
||||
disableStdin?: boolean;
|
||||
|
||||
/**
|
||||
* Whether to enable the rendering of bold text.
|
||||
*/
|
||||
enableBold?: boolean;
|
||||
|
||||
/**
|
||||
* The font size used to render text.
|
||||
*/
|
||||
fontSize?: number;
|
||||
|
||||
/**
|
||||
* The font family used to render text.
|
||||
*/
|
||||
fontFamily?: string;
|
||||
|
||||
/**
|
||||
* The spacing in whole pixels between characters..
|
||||
*/
|
||||
letterSpacing?: number;
|
||||
|
||||
/**
|
||||
* The line height used to render text.
|
||||
*/
|
||||
lineHeight?: number;
|
||||
|
||||
/**
|
||||
* The number of rows in the terminal.
|
||||
*/
|
||||
rows?: number;
|
||||
|
||||
/**
|
||||
* The amount of scrollback in the terminal. Scrollback is the amount of rows
|
||||
* that are retained when lines are scrolled beyond the initial viewport.
|
||||
*/
|
||||
scrollback?: number;
|
||||
|
||||
/**
|
||||
* The size of tab stops in the terminal.
|
||||
*/
|
||||
tabStopWidth?: number;
|
||||
|
||||
/**
|
||||
* The color theme of the terminal.
|
||||
*/
|
||||
theme?: ITheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains colors to theme the terminal with.
|
||||
*/
|
||||
interface ITheme {
|
||||
/** The default foreground color */
|
||||
foreground?: string,
|
||||
/** The default background color */
|
||||
background?: string,
|
||||
/** The cursor color */
|
||||
cursor?: string,
|
||||
/** The accent color of the cursor (used as the foreground color for a block cursor) */
|
||||
cursorAccent?: string,
|
||||
/** The selection color (can be transparent) */
|
||||
selection?: string,
|
||||
/** ANSI black (eg. `\x1b[30m`) */
|
||||
black?: string,
|
||||
/** ANSI red (eg. `\x1b[31m`) */
|
||||
red?: string,
|
||||
/** ANSI green (eg. `\x1b[32m`) */
|
||||
green?: string,
|
||||
/** ANSI yellow (eg. `\x1b[33m`) */
|
||||
yellow?: string,
|
||||
/** ANSI blue (eg. `\x1b[34m`) */
|
||||
blue?: string,
|
||||
/** ANSI magenta (eg. `\x1b[35m`) */
|
||||
magenta?: string,
|
||||
/** ANSI cyan (eg. `\x1b[36m`) */
|
||||
cyan?: string,
|
||||
/** ANSI white (eg. `\x1b[37m`) */
|
||||
white?: string,
|
||||
/** ANSI bright black (eg. `\x1b[1;30m`) */
|
||||
brightBlack?: string,
|
||||
/** ANSI bright red (eg. `\x1b[1;31m`) */
|
||||
brightRed?: string,
|
||||
/** ANSI bright green (eg. `\x1b[1;32m`) */
|
||||
brightGreen?: string,
|
||||
/** ANSI bright yellow (eg. `\x1b[1;33m`) */
|
||||
brightYellow?: string,
|
||||
/** ANSI bright blue (eg. `\x1b[1;34m`) */
|
||||
brightBlue?: string,
|
||||
/** ANSI bright magenta (eg. `\x1b[1;35m`) */
|
||||
brightMagenta?: string,
|
||||
/** ANSI bright cyan (eg. `\x1b[1;36m`) */
|
||||
brightCyan?: string,
|
||||
/** ANSI bright white (eg. `\x1b[1;37m`) */
|
||||
brightWhite?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* An object containing options for a link matcher.
|
||||
*/
|
||||
interface ILinkMatcherOptions {
|
||||
/**
|
||||
* The index of the link from the regex.match(text) call. This defaults to 0
|
||||
* (for regular expressions without capture groups).
|
||||
*/
|
||||
matchIndex?: number;
|
||||
|
||||
/**
|
||||
* A callback that validates an individual link, returning true if valid and
|
||||
* false if invalid.
|
||||
*/
|
||||
validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void;
|
||||
|
||||
/**
|
||||
* A callback that fires when the mouse hovers over a link for a moment.
|
||||
*/
|
||||
tooltipCallback?: (event: MouseEvent, uri: string) => boolean | void;
|
||||
|
||||
/**
|
||||
* A callback that fires when the mouse leaves a link. Note that this can
|
||||
* happen even when tooltipCallback hasn't fired for the link yet.
|
||||
*/
|
||||
leaveCallback?: (event: MouseEvent, uri: string) => boolean | void;
|
||||
|
||||
/**
|
||||
* The priority of the link matcher, this defines the order in which the link
|
||||
* matcher is evaluated relative to others, from highest to lowest. The
|
||||
* default value is 0.
|
||||
*/
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that represents an xterm.js terminal.
|
||||
*/
|
||||
@@ -402,7 +407,7 @@ declare module 'xterm' {
|
||||
* Retrieves an option's value from the terminal.
|
||||
* @param key The option key.
|
||||
*/
|
||||
getOption(key: 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;
|
||||
getOption(key: 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean;
|
||||
/**
|
||||
* Retrieves an option's value from the terminal.
|
||||
* @param key The option key.
|
||||
@@ -452,7 +457,7 @@ declare module 'xterm' {
|
||||
* @param key The option key.
|
||||
* @param value The option value.
|
||||
*/
|
||||
setOption(key: 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell', value: boolean): void;
|
||||
setOption(key: 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell', value: boolean): void;
|
||||
/**
|
||||
* Sets an option on the terminal.
|
||||
* @param key The option key.
|
||||
|
||||
Reference in New Issue
Block a user