Merge branch 'master' into options3

This commit is contained in:
Daniel Imms
2021-12-17 11:13:23 -08:00
committed by GitHub
19 changed files with 59 additions and 45 deletions
@@ -14,7 +14,7 @@
"SerializeAddon": ["../src/SerializeAddon"] "SerializeAddon": ["../src/SerializeAddon"]
} }
}, },
"include": ["../**/*", "../../../typings/xterm.d.ts", "../../../out/**/*"], "include": ["../**/*", "../../../typings/xterm.d.ts"],
"exclude": ["../../../**/*test.ts", "../../**/*api.ts"], "exclude": ["../../../**/*test.ts", "../../**/*api.ts"],
"references": [ "references": [
{ "path": "../../../src/common" }, { "path": "../../../src/common" },
@@ -43,6 +43,7 @@ function handleLink(event: MouseEvent, uri: string): void {
interface ILinkProviderOptions { interface ILinkProviderOptions {
hover?(event: MouseEvent, text: string, location: IViewportRange): void; hover?(event: MouseEvent, text: string, location: IViewportRange): void;
leave?(event: MouseEvent, text: string): void; leave?(event: MouseEvent, text: string): void;
urlRegex?: RegExp;
} }
export class WebLinksAddon implements ITerminalAddon { export class WebLinksAddon implements ITerminalAddon {
@@ -62,7 +63,8 @@ export class WebLinksAddon implements ITerminalAddon {
if (this._useLinkProvider && 'registerLinkProvider' in this._terminal) { if (this._useLinkProvider && 'registerLinkProvider' in this._terminal) {
const options = this._options as ILinkProviderOptions; const options = this._options as ILinkProviderOptions;
this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, strictUrlRegex, this._handler, options)); const regex = options.urlRegex || strictUrlRegex;
this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, regex, this._handler, options));
} else { } else {
// TODO: This should be removed eventually // TODO: This should be removed eventually
const options = this._options as ILinkMatcherOptions; const options = this._options as ILinkMatcherOptions;
@@ -14,8 +14,8 @@ import { AttributeData } from 'common/buffer/AttributeData';
import { channels, rgba } from 'browser/Color'; import { channels, rgba } from 'browser/Color';
import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs'; import { tryDrawCustomChar } from 'browser/renderer/CustomGlyphs';
// In practice we're probably never going to exhaust a texture this large. For debugging purposes, // For debugging purposes, it can be useful to set this to a really tiny value,
// however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. // to verify that LRU eviction works.
const TEXTURE_WIDTH = 1024; const TEXTURE_WIDTH = 1024;
const TEXTURE_HEIGHT = 1024; const TEXTURE_HEIGHT = 1024;
@@ -463,7 +463,7 @@ export class WebglCharAtlas implements IDisposable {
const clippedImageData = this._clipImageData(imageData, this._workBoundingBox); const clippedImageData = this._clipImageData(imageData, this._workBoundingBox);
// Check if there is enough room in the current row and go to next if needed // Check if there is enough room in the current row and go to next if needed
if (this._currentRowX + this._config.scaledCharWidth > TEXTURE_WIDTH) { if (this._currentRowX + rasterizedGlyph.size.x > TEXTURE_WIDTH) {
this._currentRowX = 0; this._currentRowX = 0;
this._currentRowY += this._currentRowHeight; this._currentRowY += this._currentRowHeight;
this._currentRowHeight = 0; this._currentRowHeight = 0;
+3 -3
View File
@@ -11,13 +11,13 @@ const Mustache = require('mustache');
* regexp to fetch all comments * regexp to fetch all comments
* Fetches all multiline comments and single lines containing '// @vt:'. * Fetches all multiline comments and single lines containing '// @vt:'.
*/ */
const REX_COMMENTS = /^\s*?[/][*][*]([\s\S]*?)[*][/]|^\s*?\/\/ ([@]vt[:].*?)$/mug; const REX_COMMENTS = /^\s*?\/\*\*([\S\s]*?)\*\/|^\s*?\/\/ (@vt:.*?)$/mug;
/** /**
* regexp to parse the @vt line * regexp to parse the @vt line
* expected data - "@vt: <status> <kind> <mnemonic> "<name>" "<sequence>" "<short description>" * expected data - "@vt: <status> <kind> <mnemonic> "<name>" "<sequence>" "<short description>"
*/ */
const REX_VT_LINE = /^[@]vt\:\s*(\w+|#\w+|#\w+\[.*?\])\s*(\w+)\s*(\w+)\s*"(.*?)"\s*"(.*?)"\s*"(.*?)".*$/; const REX_VT_LINE = /^@vt:\s*(\w+|#\w+|#\w+\[.*?\])\s*(\w+)\s*(\w+)\s*"(.*?)"\s*"(.*?)"\s*"(.*?)".*$/;
// known vt command types // known vt command types
const TYPES = [ const TYPES = [
@@ -362,7 +362,7 @@ function* parseMultiLineGen(filename, s) {
if (!s.includes('@vt:')) { if (!s.includes('@vt:')) {
return; return;
} }
const lines = s.split('\n').map(el => el.trim().replace(/[*]/, '').replace(/\s/, '')); const lines = s.split('\n').map(el => el.trim().replace(/\*/, '').replace(/\s/, ''));
let grabLine = false; let grabLine = false;
let longDescription = []; let longDescription = [];
let feature = undefined; let feature = undefined;
+4 -4
View File
@@ -92,7 +92,7 @@ function checkAndPublishPackage(packageDir) {
} }
function getNextBetaVersion(packageJson) { function getNextBetaVersion(packageJson) {
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) { if (!/^\d+\.\d+\.\d+$/.exec(packageJson.version)) {
console.error('The package.json version must be of the form x.y.z'); console.error('The package.json version must be of the form x.y.z');
process.exit(1); process.exit(1);
} }
@@ -104,11 +104,11 @@ function getNextBetaVersion(packageJson) {
return `${nextStableVersion}-${tag}.1`; return `${nextStableVersion}-${tag}.1`;
} }
const latestPublishedVersion = publishedVersions.sort((a, b) => { const latestPublishedVersion = publishedVersions.sort((a, b) => {
const aVersion = parseInt(a.substr(a.search(/[0-9]+$/))); const aVersion = parseInt(a.substr(a.search(/\d+$/)));
const bVersion = parseInt(b.substr(b.search(/[0-9]+$/))); const bVersion = parseInt(b.substr(b.search(/\d+$/)));
return aVersion > bVersion ? -1 : 1; return aVersion > bVersion ? -1 : 1;
})[0]; })[0];
const latestTagVersion = parseInt(latestPublishedVersion.substr(latestPublishedVersion.search(/[0-9]+$/)), 10); const latestTagVersion = parseInt(latestPublishedVersion.substr(latestPublishedVersion.search(/\d+$/)), 10);
return `${nextStableVersion}-${tag}.${latestTagVersion + 1}`; return `${nextStableVersion}-${tag}.${latestTagVersion + 1}`;
} }
+2 -2
View File
@@ -21,7 +21,7 @@ let flagArgs = [];
if (process.argv.length > 2) { if (process.argv.length > 2) {
const args = process.argv.slice(2); const args = process.argv.slice(2);
flagArgs = args.filter(e => e.startsWith('--')).map(arg => arg.split('=')).reduce((arr, val) => arr.concat([...val], [])); flagArgs = args.filter(e => e.startsWith('--')).map(arg => arg.split('=')).reduce((arr, val) => arr.concat(val.slice(), []));
console.info(flagArgs); console.info(flagArgs);
// ability to inject particular test files via // ability to inject particular test files via
// yarn test [testFileA testFileB ...] // yarn test [testFileA testFileB ...]
@@ -44,7 +44,7 @@ const server = cp.spawn('node', ['demo/start'], {
server.stdout.on('data', (data) => { server.stdout.on('data', (data) => {
// await for the server to fully start // await for the server to fully start
if (data.indexOf("successfully") !== -1) { if (data.includes("successfully")) {
const run = cp.spawnSync( const run = cp.spawnSync(
npmBinScript('mocha'), npmBinScript('mocha'),
[...testFiles, ...flagArgs], { [...testFiles, ...flagArgs], {
+1
View File
@@ -55,6 +55,7 @@ export class AccessibilityManager extends Disposable {
this._accessibilityTreeRoot = document.createElement('div'); this._accessibilityTreeRoot = document.createElement('div');
this._accessibilityTreeRoot.setAttribute('role', 'document'); this._accessibilityTreeRoot.setAttribute('role', 'document');
this._accessibilityTreeRoot.classList.add('xterm-accessibility'); this._accessibilityTreeRoot.classList.add('xterm-accessibility');
this._accessibilityTreeRoot.tabIndex = 0;
this._rowContainer = document.createElement('div'); this._rowContainer = document.createElement('div');
this._rowContainer.setAttribute('role', 'list'); this._rowContainer.setAttribute('role', 'list');
+10 -2
View File
@@ -820,7 +820,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
// normal viewport scrolling // normal viewport scrolling
// conditionally stop event, if the viewport still had rows to scroll within // conditionally stop event, if the viewport still had rows to scroll within
if (!this.viewport!.onWheel(ev)) { if (this.viewport!.onWheel(ev)) {
return this.cancel(ev); return this.cancel(ev);
} }
}, { passive: false })); }, { passive: false }));
@@ -1169,6 +1169,10 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._keyPressHandled = true; this._keyPressHandled = true;
// The key was handled so clear the dead key state, otherwise certain keystrokes like arrow
// keys could be ignored
this._unprocessedDeadKey = false;
return true; return true;
} }
@@ -1181,11 +1185,15 @@ export class Terminal extends CoreTerminal implements ITerminal {
protected _inputEvent(ev: InputEvent): boolean { protected _inputEvent(ev: InputEvent): boolean {
// Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to // Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to
// support reading out character input which can doubling up input characters // support reading out character input which can doubling up input characters
if (ev.data && ev.inputType === 'insertText' && !this.optionsService.options.screenReaderMode) { if (ev.data && ev.inputType === 'insertText' && !ev.composed && !this.optionsService.options.screenReaderMode) {
if (this._keyPressHandled) { if (this._keyPressHandled) {
return false; return false;
} }
// The key was handled so clear the dead key state, otherwise certain keystrokes like arrow
// keys could be ignored
this._unprocessedDeadKey = false;
const text = ev.data; const text = ev.data;
this.coreService.triggerDataEvent(text, true); this.coreService.triggerDataEvent(text, true);
+2 -2
View File
@@ -220,7 +220,7 @@ export class Viewport extends Disposable implements IViewport {
private _getPixelsScrolled(ev: WheelEvent): number { private _getPixelsScrolled(ev: WheelEvent): number {
// Do nothing if it's not a vertical scroll event // Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0) { if (ev.deltaY === 0 || ev.shiftKey) {
return 0; return 0;
} }
@@ -241,7 +241,7 @@ export class Viewport extends Disposable implements IViewport {
*/ */
public getLinesScrolled(ev: WheelEvent): number { public getLinesScrolled(ev: WheelEvent): number {
// Do nothing if it's not a vertical scroll event // Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0) { if (ev.deltaY === 0 || ev.shiftKey) {
return 0; return 0;
} }
+3 -3
View File
@@ -121,7 +121,7 @@ function wrappedRowsCount(startY: number, targetY: number, bufferService: IBuffe
for (let i = 0; i < Math.abs(startRow - endRow); i++) { for (let i = 0; i < Math.abs(startRow - endRow); i++) {
const direction = verticalDirection(startY, targetY) === Direction.UP ? -1 : 1; const direction = verticalDirection(startY, targetY) === Direction.UP ? -1 : 1;
const line = bufferService.buffer.lines.get(startRow + (direction * i)); const line = bufferService.buffer.lines.get(startRow + (direction * i));
if (line && line.isWrapped) { if (line?.isWrapped) {
wrappedRows++; wrappedRows++;
} }
} }
@@ -136,12 +136,12 @@ function wrappedRowsCount(startY: number, targetY: number, bufferService: IBuffe
function wrappedRowsForRow(bufferService: IBufferService, currentRow: number): number { function wrappedRowsForRow(bufferService: IBufferService, currentRow: number): number {
let rowCount = 0; let rowCount = 0;
let line = bufferService.buffer.lines.get(currentRow); let line = bufferService.buffer.lines.get(currentRow);
let lineWraps = line && line.isWrapped; let lineWraps = line?.isWrapped;
while (lineWraps && currentRow >= 0 && currentRow < bufferService.rows) { while (lineWraps && currentRow >= 0 && currentRow < bufferService.rows) {
rowCount++; rowCount++;
line = bufferService.buffer.lines.get(--currentRow); line = bufferService.buffer.lines.get(--currentRow);
lineWraps = line && line.isWrapped; lineWraps = line?.isWrapped;
} }
return rowCount; return rowCount;
+1 -6
View File
@@ -325,12 +325,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._currentGlyphIdentifier.bold = !!cell.isBold(); this._currentGlyphIdentifier.bold = !!cell.isBold();
this._currentGlyphIdentifier.dim = !!cell.isDim(); this._currentGlyphIdentifier.dim = !!cell.isDim();
this._currentGlyphIdentifier.italic = !!cell.isItalic(); this._currentGlyphIdentifier.italic = !!cell.isItalic();
const atlasDidDraw = this._charAtlas && this._charAtlas.draw( const atlasDidDraw = this._charAtlas?.draw(this._ctx, this._currentGlyphIdentifier, x * this._scaledCellWidth + this._scaledCharLeft, y * this._scaledCellHeight + this._scaledCharTop);
this._ctx,
this._currentGlyphIdentifier,
x * this._scaledCellWidth + this._scaledCharLeft,
y * this._scaledCellHeight + this._scaledCharTop
);
if (!atlasDidDraw) { if (!atlasDidDraw) {
this._drawUncachedChars(cell, x, y); this._drawUncachedChars(cell, x, y);
+1 -1
View File
@@ -16,7 +16,7 @@ export function generateConfig(scaledCharWidth: number, scaledCharHeight: number
cursor: undefined, cursor: undefined,
cursorAccent: undefined, cursorAccent: undefined,
selection: undefined, selection: undefined,
ansi: colors.ansi ansi: [...colors.ansi]
}; };
return { return {
devicePixelRatio: window.devicePixelRatio, devicePixelRatio: window.devicePixelRatio,
+15 -6
View File
@@ -176,16 +176,25 @@ export class CharacterJoinerService implements ICharacterJoinerService {
// At this point we already know that there is at least one joiner so // At this point we already know that there is at least one joiner so
// we can just pull its value and assign it directly rather than // we can just pull its value and assign it directly rather than
// merging it into an empty array, which incurs unnecessary writes. // merging it into an empty array, which incurs unnecessary writes.
const joinedRanges: [number, number][] = this._characterJoiners[0].handler(text); let allJoinedRanges: [number, number][] = [];
try {
allJoinedRanges = this._characterJoiners[0].handler(text);
} catch (error) {
console.error(error);
}
for (let i = 1; i < this._characterJoiners.length; i++) { for (let i = 1; i < this._characterJoiners.length; i++) {
// We merge any overlapping ranges across the different joiners // We merge any overlapping ranges across the different joiners
const joinerRanges = this._characterJoiners[i].handler(text); try {
for (let j = 0; j < joinerRanges.length; j++) { const joinerRanges = this._characterJoiners[i].handler(text);
CharacterJoinerService._mergeRanges(joinedRanges, joinerRanges[j]); for (let j = 0; j < joinerRanges.length; j++) {
CharacterJoinerService._mergeRanges(allJoinedRanges, joinerRanges[j]);
}
} catch (error) {
console.error(error);
} }
} }
this._stringRangesToCellRanges(joinedRanges, lineData, startCol); this._stringRangesToCellRanges(allJoinedRanges, lineData, startCol);
return joinedRanges; return allJoinedRanges;
} }
/** /**
+2 -2
View File
@@ -220,7 +220,7 @@ export class SelectionService extends Disposable implements ISelectionService {
for (let i = start[1] + 1; i <= end[1] - 1; i++) { for (let i = start[1] + 1; i <= end[1] - 1; i++) {
const bufferLine = buffer.lines.get(i); const bufferLine = buffer.lines.get(i);
const lineText = buffer.translateBufferLineToString(i, true); const lineText = buffer.translateBufferLineToString(i, true);
if (bufferLine && bufferLine.isWrapped) { if (bufferLine?.isWrapped) {
result[result.length - 1] += lineText; result[result.length - 1] += lineText;
} else { } else {
result.push(lineText); result.push(lineText);
@@ -924,7 +924,7 @@ export class SelectionService extends Disposable implements ISelectionService {
if (followWrappedLinesBelow) { if (followWrappedLinesBelow) {
if (start + length === this._bufferService.cols && bufferLine.getCodePoint(this._bufferService.cols - 1) !== 32 /* ' ' */) { if (start + length === this._bufferService.cols && bufferLine.getCodePoint(this._bufferService.cols - 1) !== 32 /* ' ' */) {
const nextBufferLine = buffer.lines.get(coords[1] + 1); const nextBufferLine = buffer.lines.get(coords[1] + 1);
if (nextBufferLine && nextBufferLine.isWrapped && nextBufferLine.getCodePoint(0) !== 32 /* ' ' */) { if (nextBufferLine?.isWrapped && nextBufferLine.getCodePoint(0) !== 32 /* ' ' */) {
const nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true); const nextLineWordPosition = this._getWordAt([0, coords[1] + 1], false, false, true);
if (nextLineWordPosition) { if (nextLineWordPosition) {
length += nextLineWordPosition.length; length += nextLineWordPosition.length;
+1 -1
View File
@@ -349,7 +349,7 @@ export function evaluateKeyboardEvent(
} else if ((!isMac || macOptionIsMeta) && ev.altKey && !ev.metaKey) { } else if ((!isMac || macOptionIsMeta) && ev.altKey && !ev.metaKey) {
// On macOS this is a third level shift when !macOptionIsMeta. Use <Esc> instead. // On macOS this is a third level shift when !macOptionIsMeta. Use <Esc> instead.
const keyMapping = KEYCODE_KEY_MAPPINGS[ev.keyCode]; const keyMapping = KEYCODE_KEY_MAPPINGS[ev.keyCode];
const key = keyMapping && keyMapping[!ev.shiftKey ? 0 : 1]; const key = keyMapping?.[!ev.shiftKey ? 0 : 1];
if (key) { if (key) {
result.key = C0.ESC + key; result.key = C0.ESC + key;
} else if (ev.keyCode >= 65 && ev.keyCode <= 90) { } else if (ev.keyCode >= 65 && ev.keyCode <= 90) {
+1 -1
View File
@@ -162,7 +162,7 @@ it('wcwidth should match all values from the old implementation', function(): vo
// we are only interested in 2 LSBs, cut off higher bits // we are only interested in 2 LSBs, cut off higher bits
// ==> n = n & 3 e.g. 000000000000000000000000000000XX // ==> n = n & 3 e.g. 000000000000000000000000000000XX
return (num: number): number => { return (num: number): number => {
num = num | 0; // get asm.js like optimization under V8 num |= 0; // get asm.js like optimization under V8
if (num < 32) { if (num < 32) {
return control | 0; return control | 0;
} }
+2 -2
View File
@@ -52,9 +52,9 @@ export class Params implements IParams {
return params; return params;
} }
// skip leading sub params // skip leading sub params
for (let i = (values[0] instanceof Array) ? 1 : 0; i < values.length; ++i) { for (let i = (Array.isArray(values[0])) ? 1 : 0; i < values.length; ++i) {
const value = values[i]; const value = values[i];
if (value instanceof Array) { if (Array.isArray(value)) {
for (let k = 0; k < value.length; ++k) { for (let k = 0; k < value.length; ++k) {
params.addSubParam(value[k]); params.addSubParam(value[k]);
} }
+3 -3
View File
@@ -71,11 +71,11 @@ export function getBrowserType(): playwright.BrowserType<playwright.WebKitBrowse
export function launchBrowser() { export function launchBrowser() {
const browserType = getBrowserType(); const browserType = getBrowserType();
const options: Record<string, unknown> = { const options: Record<string, unknown> = {
headless: process.argv.includes('--headless'), headless: process.argv.includes('--headless')
} };
const index = process.argv.indexOf('--executablePath'); const index = process.argv.indexOf('--executablePath');
if(index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') { if (index > 0 && process.argv.length > index + 1 && typeof process.argv[index + 1] === 'string') {
options.executablePath = process.argv[index + 1]; options.executablePath = process.argv[index + 1];
} }
+1 -2
View File
@@ -21,8 +21,7 @@
}, },
"include": [ "include": [
"./**/*", "./**/*",
"../../typings/xterm.d.ts", "../../typings/xterm.d.ts"
"../../out/**/*"
], ],
"exclude": [ "exclude": [
"../../**/*test.ts" "../../**/*test.ts"