Merge branch 'master' into webgl2

This commit is contained in:
Daniel Imms
2019-06-15 14:37:04 -07:00
committed by GitHub
12 changed files with 105 additions and 30 deletions
+1
View File
@@ -2,3 +2,4 @@
**/*.api.ts
tsconfig.json
.yarnrc
webpack.config.js
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xterm-addon-attach",
"version": "0.1.0-beta11",
"version": "0.1.0",
"author": {
"name": "The xterm.js authors",
"url": "https://xtermjs.org/"
+1
View File
@@ -2,3 +2,4 @@
**/*.api.ts
tsconfig.json
.yarnrc
webpack.config.js
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xterm-addon-fit",
"version": "0.1.0-beta3",
"version": "0.1.0",
"author": {
"name": "The xterm.js authors",
"url": "https://xtermjs.org/"
+1
View File
@@ -2,3 +2,4 @@
**/*.api.ts
tsconfig.json
.yarnrc
webpack.config.js
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xterm-addon-search",
"version": "0.1.0-beta6",
"version": "0.1.0",
"author": {
"name": "The xterm.js authors",
"url": "https://xtermjs.org/"
+1
View File
@@ -2,3 +2,4 @@
**/*.api.ts
tsconfig.json
.yarnrc
webpack.config.js
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xterm-addon-web-links",
"version": "0.1.0-beta10",
"version": "0.1.0",
"author": {
"name": "The xterm.js authors",
"url": "https://xtermjs.org/"
+74 -23
View File
@@ -6,33 +6,76 @@
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const packageJson = require('../package.json');
// Setup auth
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);
// Determine if this is a stable or beta release
const publishedVersions = getPublishedVersions();
const isStableRelease = publishedVersions.indexOf(packageJson.version) === -1;
// Get the next version
let nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
console.log(`Publishing version: ${nextVersion}`);
// Set the version in package.json
const packageJsonFile = path.resolve(__dirname, '..', 'package.json');
packageJson.version = nextVersion;
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
// Publish
const args = ['publish'];
if (!isStableRelease) {
args.push('--tag', 'beta');
const isDryRun = process.argv.indexOf('--dry') !== -1;
if (isDryRun) {
console.log('Publish dry run');
}
const result = cp.spawn('npm', args, { stdio: 'inherit' });
result.on('exit', code => process.exit(code));
function getNextBetaVersion() {
const changedFiles = getChangedFilesInCommit('HEAD');
// Publish xterm if any files were changed outside of the addons directory
if (changedFiles.some(e => e.search(/^addons\//) === -1)) {
checkAndPublishPackage(path.resolve(__dirname, '..'));
}
// Publish addons if any files were changed inside of the addon
const addonPackageDirs = [
path.resolve(__dirname, '../addons/xterm-addon-attach'),
path.resolve(__dirname, '../addons/xterm-addon-fit'),
path.resolve(__dirname, '../addons/xterm-addon-search'),
path.resolve(__dirname, '../addons/xterm-addon-web-links')
];
addonPackageDirs.forEach(p => {
const addon = path.basename(p);
if (changedFiles.some(e => e.indexOf(addon) !== -1)) {
checkAndPublishPackage(p);
}
});
function checkAndPublishPackage(packageDir) {
const packageJson = require(path.join(packageDir, 'package.json'));
// Determine if this is a stable or beta release
const publishedVersions = getPublishedVersions(packageJson);
const isStableRelease = publishedVersions.indexOf(packageJson.version) === -1;
// Get the next version
let nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion(packageJson);
console.log(`Publishing version: ${nextVersion}`);
// Set the version in package.json
const packageJsonFile = path.join(packageDir, 'package.json');
packageJson.version = nextVersion;
console.log(`Set version of ${packageJsonFile} to ${nextVersion}`);
if (!isDryRun) {
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));
}
// Publish
const args = ['publish'];
if (!isStableRelease) {
args.push('--tag', 'beta');
}
console.log(`Spawn: npm ${args.join(' ')}`);
if (!isDryRun) {
const result = cp.spawnSync('npm', args, {
cwd: packageDir,
stdio: 'inherit'
});
if (result.status) {
console.error(`Spawn exited with code ${result.status}`);
process.exit(result.status);
}
}
console.groupEnd();
}
function getNextBetaVersion(packageJson) {
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
console.error('The package.json version must be of the form x.y.z');
process.exit(1);
@@ -40,7 +83,7 @@ function getNextBetaVersion() {
const tag = 'beta';
const stableVersion = packageJson.version.split('.');
const nextStableVersion = `${stableVersion[0]}.${parseInt(stableVersion[1]) + 1}.0`;
const publishedVersions = getPublishedVersions(nextStableVersion, tag);
const publishedVersions = getPublishedVersions(packageJson, nextStableVersion, tag);
if (publishedVersions.length === 0) {
return `${nextStableVersion}-${tag}1`;
}
@@ -53,7 +96,7 @@ function getNextBetaVersion() {
return `${nextStableVersion}-${tag}${latestTagVersion + 1}`;
}
function getPublishedVersions(version, tag) {
function getPublishedVersions(packageJson, version, tag) {
const versionsProcess = cp.spawnSync('npm', ['view', packageJson.name, 'versions', '--json']);
const versionsJson = JSON.parse(versionsProcess.stdout);
if (tag) {
@@ -61,3 +104,11 @@ function getPublishedVersions(version, tag) {
}
return versionsJson;
}
function getChangedFilesInCommit(commit) {
const args = ['log', '-m', '-1', '--name-only', `--pretty=format:`, commit];
const result = cp.spawnSync('git', args);
const output = result.stdout.toString();
const changedFiles = output.split('\n').filter(e => e.length > 0);
return changedFiles;
}
+2 -2
View File
@@ -1919,7 +1919,7 @@ export class InputHandler extends Disposable implements IInputHandler {
*/
public saveCursor(params: number[]): void {
this._terminal.buffer.savedX = this._terminal.buffer.x;
this._terminal.buffer.savedY = this._terminal.buffer.y;
this._terminal.buffer.savedY = this._terminal.buffer.ybase + this._terminal.buffer.y;
this._terminal.buffer.savedCurAttrData.fg = this._terminal.curAttrData.fg;
this._terminal.buffer.savedCurAttrData.bg = this._terminal.curAttrData.bg;
}
@@ -1932,7 +1932,7 @@ export class InputHandler extends Disposable implements IInputHandler {
*/
public restoreCursor(params: number[]): void {
this._terminal.buffer.x = this._terminal.buffer.savedX || 0;
this._terminal.buffer.y = this._terminal.buffer.savedY || 0;
this._terminal.buffer.y = Math.max(this._terminal.buffer.savedY - this._terminal.buffer.ybase, 0);
this._terminal.curAttrData.fg = this._terminal.buffer.savedCurAttrData.fg;
this._terminal.curAttrData.bg = this._terminal.buffer.savedCurAttrData.bg;
}
+4 -1
View File
@@ -126,6 +126,7 @@ export class Buffer implements IBuffer {
public clear(): void {
this.ydisp = 0;
this.ybase = 0;
this.savedY = 0;
this.y = 0;
this.x = 0;
this.lines = new CircularList<IBufferLine>(this._getCorrectBufferLength(this._rows));
@@ -205,6 +206,7 @@ export class Buffer implements IBuffer {
this.lines.trimStart(amountToTrim);
this.ybase = Math.max(this.ybase - amountToTrim, 0);
this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
this.savedY = Math.max(this.savedY - amountToTrim, 0);
}
this.lines.maxLength = newMaxLength;
}
@@ -215,7 +217,6 @@ export class Buffer implements IBuffer {
if (addToY) {
this.y += addToY;
}
this.savedY = Math.min(this.savedY, newRows - 1);
this.savedX = Math.min(this.savedX, newCols - 1);
this.scrollTop = 0;
@@ -284,6 +285,7 @@ export class Buffer implements IBuffer {
this.ybase--;
}
}
this.savedY = Math.max(this.savedY - countRemoved, 0);
}
private _reflowSmaller(newCols: number, newRows: number): void {
@@ -395,6 +397,7 @@ export class Buffer implements IBuffer {
}
}
}
this.savedY = Math.min(this.savedY + linesToAdd, this.ybase + newRows - 1);
}
// Rearrange lines in the buffer if there are any insertions, this is done at the end rather
+17
View File
@@ -292,6 +292,23 @@ describe('InputHandler Integration Tests', function(): void {
assert.deepEqual(await getLinesAsArray(3), ['#', ' #', 'abcd####']);
});
});
describe('ESC', () => {
describe('DECRC: Save cursor, ESC 7', () => {
it('should save the absolute cursor position so resizing restores to the correct position', async () => {
await page.evaluate(`
window.term.resize(10, 2);
window.term.write('1\\n\\r2\\n\\r3\\n\\r4\\n\\r5');
window.term.write('\\x1b7\\x1b[?47h');
`);
await page.evaluate(`
window.term.resize(10, 4);
window.term.write('\\x1b[?47l\\x1b8');
`);
assert.deepEqual(await getCursor(), {col: 1, row: 3});
});
});
});
});
async function openTerminal(options: ITerminalOptions = {}): Promise<void> {