Merge remote-tracking branch 'upstream/master' into 455_linkify

This commit is contained in:
Daniel Imms
2017-02-17 10:05:22 -08:00
22 changed files with 4518 additions and 5526 deletions
+1 -1
View File
@@ -1394,7 +1394,7 @@ export class InputHandler implements IInputHandler {
this._terminal.cursorHidden = false;
this._terminal.insertMode = false;
this._terminal.originMode = false;
this._terminal.wraparoundMode = false; // autowrap
this._terminal.wraparoundMode = true; // defaults: xterm - true, vt100 - false
this._terminal.applicationKeypad = false; // ?
this._terminal.viewport.syncScrollArea();
this._terminal.applicationCursor = false;
+6
View File
@@ -44,6 +44,12 @@ export interface ITerminal {
emit(event: string, data: any);
}
export interface ICharMeasure {
width: number;
height: number;
measure(): void;
}
interface ICircularList<T> {
length: number;
maxLength: number;
+26 -18
View File
@@ -41,13 +41,17 @@ describe('Viewport', () => {
});
describe('refresh', () => {
it('should set the line-height of the terminal', () => {
assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
charMeasure.height = 1;
viewport.refresh();
assert.equal(viewportElement.style.lineHeight, '1px');
assert.equal(terminal.rowContainer.style.lineHeight, '1px');
it('should set the line-height of the terminal', done => {
// Allow CharMeasure to be initialized
setTimeout(() => {
assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
charMeasure.height = 1;
viewport.refresh();
assert.equal(viewportElement.style.lineHeight, '1px');
assert.equal(terminal.rowContainer.style.lineHeight, '1px');
done();
}, 0);
});
it('should set the height of the viewport when the line-height changed', () => {
terminal.lines.push('');
@@ -62,17 +66,21 @@ describe('Viewport', () => {
});
describe('syncScrollArea', () => {
it('should sync the scroll area', () => {
terminal.lines.push('');
terminal.rows = 1;
assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
viewport.syncScrollArea();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
terminal.lines.push('');
viewport.syncScrollArea();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
it('should sync the scroll area', done => {
// Allow CharMeasure to be initialized
setTimeout(() => {
terminal.lines.push('');
terminal.rows = 1;
assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
viewport.syncScrollArea();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
terminal.lines.push('');
viewport.syncScrollArea();
assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
done();
}, 0);
});
});
});
+2 -1
View File
@@ -35,7 +35,8 @@ export class Viewport {
this.terminal.on('resize', this.syncScrollArea.bind(this));
this.viewportElement.addEventListener('scroll', this.onScroll.bind(this));
this.syncScrollArea();
// Perform this async to ensure the CharMeasure is ready.
setTimeout(() => this.syncScrollArea(), 0);
}
/**
+6 -1
View File
@@ -32,6 +32,9 @@
var exports = {};
exports.proposeGeometry = function (term) {
if (!term.element.parentElement) {
return null;
}
var parentElementStyle = window.getComputedStyle(term.element.parentElement),
parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17),
@@ -66,7 +69,9 @@
exports.fit = function (term) {
var geometry = exports.proposeGeometry(term);
term.resize(geometry.cols, geometry.rows);
if (geometry) {
term.resize(geometry.cols, geometry.rows);
}
};
Xterm.prototype.proposeGeometry = function () {
+6
View File
@@ -1,9 +1,15 @@
var glob = require('glob');
var fs = require('fs');
var os = require('os');
var pty = require('node-pty');
var sleep = require('sleep');
var Terminal = require('../xterm');
if (os.platform() === 'win32') {
// Skip tests on Windows since pty.open isn't supported
return;
}
var CONSOLE_LOG = console.log;
// expect files need terminal at 80x25!
+65
View File
@@ -0,0 +1,65 @@
/**
* @license MIT
*/
import { ICharMeasure, ITerminal } from '../Interfaces';
declare var assert: Chai.Assert;
declare var Terminal: ITerminal;
// Do not describe tests unless in PhantomJS environment
if (typeof Terminal !== 'undefined') {
const CharMeasure = (<any>Terminal).CharMeasure;
describe('CharMeasure', () => {
const parentElement = document.createElement('div');
let charMeasure: ICharMeasure;
beforeEach(() => {
charMeasure = new CharMeasure(parentElement);
document.querySelector('#xterm').appendChild(parentElement);
});
afterEach(() => {
if (parentElement && parentElement.parentElement) {
parentElement.parentElement.removeChild(parentElement);
}
});
describe('measure', () => {
it('should be performed async on first call', done => {
assert.equal(charMeasure.width, null);
charMeasure.measure();
assert.equal(charMeasure.width, null);
setTimeout(() => {
assert.isTrue(charMeasure.width > 0);
done();
}, 0);
});
it('should be performed sync on successive calls', done => {
charMeasure.measure();
setTimeout(() => {
const firstWidth = charMeasure.width;
parentElement.style.fontSize = '2em';
charMeasure.measure();
assert.equal(charMeasure.width, firstWidth * 2);
done();
}, 0);
});
it('should NOT do a measure when the parent is hidden', done => {
charMeasure.measure();
setTimeout(() => {
const firstWidth = charMeasure.width;
parentElement.style.display = 'none';
parentElement.style.fontSize = '2em';
charMeasure.measure();
assert.equal(charMeasure.width, firstWidth);
done();
}, 0);
});
});
});
}
+2 -5
View File
@@ -97,13 +97,10 @@
}
@keyframes xterm-cursor-blink {
0% {
background-color: #fff;
color: #000;
}
0% { }
50% {
background-color: transparent;
color: #FFF;
color: inherit;
}
}
+4 -1
View File
@@ -1781,7 +1781,7 @@ Terminal.prototype.error = function() {
* @param {number} y The number of rows to resize to.
*/
Terminal.prototype.resize = function(x, y) {
if (Number.isNaN(x) || Number.isNaN(y)) {
if (isNaN(x) || isNaN(y)) {
return;
}
@@ -2303,6 +2303,9 @@ function keys(obj) {
Terminal.EventEmitter = EventEmitter;
Terminal.inherits = inherits;
// Expose for Phantom.JS tests
Terminal.CharMeasure = CharMeasure;
/**
* Adds an event listener to the terminal.
*