Skip to content

Commit

Permalink
Merge branch 'master' into selection_manager_browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Jun 29, 2019
2 parents 88308f0 + 73be720 commit a706dd9
Show file tree
Hide file tree
Showing 29 changed files with 971 additions and 94 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules/
.lock-wscript
lib/
out/
out-test/
Makefile.gyp
*.Makefile
*.target.gyp.mk
Expand All @@ -19,3 +20,7 @@ package-lock.json
# Keep bundled code out of Git
dist/
demo/dist/

# dont commit benchmark folders
.benchmark/
timeline/
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
!*.js
!*.json

# Whitelist - css/
!css/**/*.css

# Whitelist - dist/
!dist/**/*.js
!dist/**/*.js.map
Expand Down Expand Up @@ -33,6 +36,7 @@
!typings/*.d.ts

# Blacklist - (normal behavior) these will override any whitelist
*.d.ts.map
*.test.ts
*.test.d.ts
*.test.js
Expand Down
22 changes: 11 additions & 11 deletions addons/xterm-addon-webgl/src/renderLayer/BaseRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx = this._canvas.getContext('2d', {alpha: this._alpha});
// Draw the background if this is an opaque layer
if (!this._alpha) {
this.clearAll();
this._clearAll();
}
}

Expand All @@ -81,7 +81,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._refreshCharAtlas(terminal, colorSet);
}

protected setTransparency(terminal: Terminal, alpha: boolean): void {
protected _setTransparency(terminal: Terminal, alpha: boolean): void {
// Do nothing when alpha doesn't change
if (alpha === this._alpha) {
return;
Expand Down Expand Up @@ -127,7 +127,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {

// Draw the background if this is an opaque layer
if (!this._alpha) {
this.clearAll();
this._clearAll();
}

this._refreshCharAtlas(terminal, this._colors);
Expand All @@ -142,7 +142,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to fill.
* @param height The number of rows to fill.
*/
protected fillCells(x: number, y: number, width: number, height: number): void {
protected _fillCells(x: number, y: number, width: number, height: number): void {
this._ctx.fillRect(
x * this._scaledCellWidth,
y * this._scaledCellHeight,
Expand All @@ -156,7 +156,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill.
* @param y The row to fill.
*/
protected fillBottomLineAtCells(x: number, y: number, width: number = 1): void {
protected _fillBottomLineAtCells(x: number, y: number, width: number = 1): void {
this._ctx.fillRect(
x * this._scaledCellWidth,
(y + 1) * this._scaledCellHeight - window.devicePixelRatio - 1 /* Ensure it's drawn within the cell */,
Expand All @@ -170,7 +170,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill.
* @param y The row to fill.
*/
protected fillLeftLineAtCell(x: number, y: number): void {
protected _fillLeftLineAtCell(x: number, y: number): void {
this._ctx.fillRect(
x * this._scaledCellWidth,
y * this._scaledCellHeight,
Expand All @@ -184,7 +184,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param x The column to fill.
* @param y The row to fill.
*/
protected strokeRectAtCell(x: number, y: number, width: number, height: number): void {
protected _strokeRectAtCell(x: number, y: number, width: number, height: number): void {
this._ctx.lineWidth = window.devicePixelRatio;
this._ctx.strokeRect(
x * this._scaledCellWidth + window.devicePixelRatio / 2,
Expand All @@ -196,7 +196,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
/**
* Clears the entire canvas.
*/
protected clearAll(): void {
protected _clearAll(): void {
if (this._alpha) {
this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
} else {
Expand All @@ -212,7 +212,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param width The number of columns to clear.
* @param height The number of rows to clear.
*/
protected clearCells(x: number, y: number, width: number, height: number): void {
protected _clearCells(x: number, y: number, width: number, height: number): void {
if (this._alpha) {
this._ctx.clearRect(
x * this._scaledCellWidth,
Expand All @@ -239,7 +239,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param y The row to draw at.
* @param color The color of the character.
*/
protected fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void {
protected _fillCharTrueColor(terminal: Terminal, cell: CellData, x: number, y: number): void {
this._ctx.font = this._getFont(terminal, false, false);
this._ctx.textBaseline = 'middle';
this._clipRow(terminal, y);
Expand All @@ -263,7 +263,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* This is used to validate whether a cached image can be used.
* @param bold Whether the text is bold.
*/
protected drawChars(terminal: Terminal, cell: ICellData, x: number, y: number): void {
protected _drawChars(terminal: Terminal, cell: ICellData, x: number, y: number): void {

// skip cache right away if we draw in RGB
// Note: to avoid bad runtime JoinedCellData will be skipped
Expand Down
12 changes: 6 additions & 6 deletions addons/xterm-addon-webgl/src/renderLayer/CursorRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class CursorRenderLayer extends BaseRenderLayer {

private _clearCursor(): void {
if (this._state) {
this.clearCells(this._state.x, this._state.y, this._state.width, 1);
this._clearCells(this._state.x, this._state.y, this._state.width, 1);
this._state = {
x: null,
y: null,
Expand All @@ -196,30 +196,30 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _renderBarCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css;
this.fillLeftLineAtCell(x, y);
this._fillLeftLineAtCell(x, y);
this._ctx.restore();
}

private _renderBlockCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css;
this.fillCells(x, y, cell.getWidth(), 1);
this._fillCells(x, y, cell.getWidth(), 1);
this._ctx.fillStyle = this._colors.cursorAccent.css;
this.fillCharTrueColor(terminal, cell, x, y);
this._fillCharTrueColor(terminal, cell, x, y);
this._ctx.restore();
}

private _renderUnderlineCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css;
this.fillBottomLineAtCells(x, y);
this._fillBottomLineAtCells(x, y);
this._ctx.restore();
}

private _renderBlurCursor(terminal: Terminal, x: number, y: number, cell: ICellData): void {
this._ctx.save();
this._ctx.strokeStyle = this._colors.cursor.css;
this.strokeRectAtCell(x, y, cell.getWidth(), 1);
this._strokeRectAtCell(x, y, cell.getWidth(), 1);
this._ctx.restore();
}
}
Expand Down
14 changes: 7 additions & 7 deletions addons/xterm-addon-webgl/src/renderLayer/LinkRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export class LinkRenderLayer extends BaseRenderLayer {

private _clearCurrentLink(): void {
if (this._state) {
this.clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
this._clearCells(this._state.x1, this._state.y1, this._state.cols - this._state.x1, 1);
const middleRowCount = this._state.y2 - this._state.y1 - 1;
if (middleRowCount > 0) {
this.clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
this._clearCells(0, this._state.y1 + 1, this._state.cols, middleRowCount);
}
this.clearCells(0, this._state.y2, this._state.x2, 1);
this._clearCells(0, this._state.y2, this._state.x2, 1);
this._state = null;
}
}
Expand All @@ -54,14 +54,14 @@ export class LinkRenderLayer extends BaseRenderLayer {

if (e.y1 === e.y2) {
// Single line link
this.fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
this._fillBottomLineAtCells(e.x1, e.y1, e.x2 - e.x1);
} else {
// Multi-line link
this.fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
this._fillBottomLineAtCells(e.x1, e.y1, e.cols - e.x1);
for (let y = e.y1 + 1; y < e.y2; y++) {
this.fillBottomLineAtCells(0, y, e.cols);
this._fillBottomLineAtCells(0, y, e.cols);
}
this.fillBottomLineAtCells(0, e.y2, e.x2);
this._fillBottomLineAtCells(0, e.y2, e.x2);
}
this._state = e;
}
Expand Down
6 changes: 3 additions & 3 deletions css/xterm.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* The z-index of the helpers must be higher than the canvases in order for
* IMEs to appear on top.
*/
z-index: 10;
z-index: 5;
}

.xterm .xterm-helper-textarea {
Expand All @@ -69,7 +69,7 @@
top: 0;
width: 0;
height: 0;
z-index: -10;
z-index: -5;
/** Prevent wrapping so the IME appears against the textarea at the correct position */
white-space: nowrap;
overflow: hidden;
Expand Down Expand Up @@ -150,7 +150,7 @@
top: 0;
bottom: 0;
right: 0;
z-index: 100;
z-index: 10;
color: transparent;
}

Expand Down
3 changes: 2 additions & 1 deletion demo/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ function initOptions(term: TerminalType): void {
fontFamily: null,
fontWeight: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
fontWeightBold: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
rendererType: ['dom', 'canvas']
rendererType: ['dom', 'canvas'],
wordSeparator: null
};
const options = Object.keys((<any>term)._core.options);
const booleanOptions = [];
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"prepare": "npm run build",
"prepublishOnly": "npm run package",
"watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput",
"benchmark": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json",
"benchmark-baseline": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --baseline out-test/benchmark/test/benchmark/*benchmark.js",
"benchmark-eval": "NODE_PATH=./out xterm-benchmark -r 5 -c test/benchmark/benchmark.json --eval out-test/benchmark/test/benchmark/*benchmark.js",
"clean": "rm -rf lib out addons/*/lib addons/*/out"
},
"devDependencies": {
Expand Down Expand Up @@ -48,6 +51,7 @@
"utf8": "^3.0.0",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0",
"ws": "^7.0.0"
"ws": "^7.0.0",
"xterm-benchmark": "^0.1.3"
}
}
2 changes: 1 addition & 1 deletion src/Linkifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { CellData } from 'common/buffer/CellData';
class TestLinkifier extends Linkifier {
constructor(terminal: ITerminal) {
super(terminal);
(<any>Linkifier).TIME_BEFORE_LINKIFY = 0;
Linkifier._timeBeforeLatency = 0;
}

public get linkMatchers(): ILinkMatcher[] { return this._linkMatchers; }
Expand Down
20 changes: 10 additions & 10 deletions src/Linkifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import { MouseZone } from './MouseZoneManager';
import { getStringCellWidth } from 'common/CharWidth';
import { EventEmitter, IEvent } from 'common/EventEmitter';

/**
* Limit of the unwrapping line expansion (overscan) at the top and bottom
* of the actual viewport in ASCII characters.
* A limit of 2000 should match most sane urls.
*/
const OVERSCAN_CHAR_LIMIT = 2000;

/**
* The Linkifier applies links to rows shortly after they have been refreshed.
*/
Expand All @@ -18,14 +25,7 @@ export class Linkifier implements ILinkifier {
* the costly operation of searching every row multiple times, potentially a
* huge amount of times.
*/
protected static readonly TIME_BEFORE_LINKIFY = 200;

/**
* Limit of the unwrapping line expansion (overscan) at the top and bottom
* of the actual viewport in ASCII characters.
* A limit of 2000 should match most sane urls.
*/
protected static readonly OVERSCAN_CHAR_LIMIT = 2000;
protected static _timeBeforeLatency = 200;

protected _linkMatchers: ILinkMatcher[] = [];

Expand Down Expand Up @@ -85,7 +85,7 @@ export class Linkifier implements ILinkifier {
if (this._rowsTimeoutId) {
clearTimeout(this._rowsTimeoutId);
}
this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier.TIME_BEFORE_LINKIFY);
this._rowsTimeoutId = <number><any>setTimeout(() => this._linkifyRows(), Linkifier._timeBeforeLatency);
}

/**
Expand Down Expand Up @@ -114,7 +114,7 @@ export class Linkifier implements ILinkifier {
// the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom.
// This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT
// chars will not match anymore at the viewport borders.
const overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols);
const overscanLineLimit = Math.ceil(OVERSCAN_CHAR_LIMIT / this._terminal.cols);
const iterator = this._terminal.buffer.iterator(
false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
while (iterator.hasNext()) {
Expand Down
6 changes: 2 additions & 4 deletions src/WindowsMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ export function applyWindowsMode(terminal: ITerminal): IDisposable {
const line = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y - 1);
const lastChar = line.get(terminal.cols - 1);

if (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE) {
const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
nextLine.isWrapped = true;
}
const nextLine = terminal.buffer.lines.get(terminal.buffer.ybase + terminal.buffer.y);
nextLine.isWrapped = (lastChar[CHAR_DATA_CODE_INDEX] !== NULL_CELL_CODE && lastChar[CHAR_DATA_CODE_INDEX] !== WHITESPACE_CELL_CODE);
});
}
Loading

0 comments on commit a706dd9

Please sign in to comment.