Merge remote-tracking branch 'upstream/master' into 478_cursorBlink_refresh
This commit is contained in:
@@ -1,11 +1,6 @@
|
|||||||
FROM node:6.9
|
FROM node:6.9
|
||||||
MAINTAINER Paris Kasidiaris <paris@sourcelair.com>
|
MAINTAINER Paris Kasidiaris <paris@sourcelair.com>
|
||||||
|
|
||||||
# Install cpio, used for building
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y --no-install-recommends cpio \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
#! /usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# $BUILD_DIR should default to "build"
|
|
||||||
BUILD_DIR=${BUILD_DIR:=build}
|
|
||||||
|
|
||||||
# Create the build directory
|
|
||||||
mkdir -p $BUILD_DIR
|
|
||||||
|
|
||||||
|
|
||||||
# Clean lib/* to prevent confusion if files were deleted in src/
|
|
||||||
rm -rf lib/*
|
|
||||||
|
|
||||||
# Build all TypeScript files (including tests) to lib/
|
|
||||||
tsc
|
|
||||||
|
|
||||||
# Concat all xterm.js files into a single file and output as a UMD to $BUILD_DIR/xterm.js
|
|
||||||
browserify ./lib/xterm.js --standalone Terminal --debug --outfile ./$BUILD_DIR/xterm.js
|
|
||||||
cat ./$BUILD_DIR/xterm.js | exorcist ./$BUILD_DIR/xterm.js.map -b ./$BUILD_DIR > ./$BUILD_DIR/xterm.temp.js
|
|
||||||
rm ./$BUILD_DIR/xterm.js
|
|
||||||
mv ./$BUILD_DIR/xterm.temp.js ./$BUILD_DIR/xterm.js
|
|
||||||
|
|
||||||
# Resolve the chain of sourcemaps so that ./$BUILD_DIR/xterm.js.map points at ./src
|
|
||||||
sorcery -i $BUILD_DIR/xterm.js
|
|
||||||
|
|
||||||
# Copy all CSS files from src/ to $BUILD_DIR/ and lib/
|
|
||||||
cd src
|
|
||||||
find . -name '*.css' | cpio -pdm ../$BUILD_DIR
|
|
||||||
find . -name '*.css' | cpio -pdm ../lib
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
# Copy addons from lib/ to $BUILD_DIR/
|
|
||||||
cd lib/addons
|
|
||||||
find . -name '*.js' | cpio -pdm ../../$BUILD_DIR/addons
|
|
||||||
cd ../..
|
|
||||||
+1
-1
@@ -21,7 +21,7 @@ CURRENT_BOWER_JSON_VERSION=$(cat bower.json \
|
|||||||
|
|
||||||
# Build xterm.js into `dist`
|
# Build xterm.js into `dist`
|
||||||
export BUILD_DIR=dist
|
export BUILD_DIR=dist
|
||||||
./bin/build
|
npm run build
|
||||||
|
|
||||||
# Update AUTHORS file
|
# Update AUTHORS file
|
||||||
sh bin/generate-authors
|
sh bin/generate-authors
|
||||||
|
|||||||
+6
-1
@@ -16,7 +16,12 @@
|
|||||||
<div id="terminal-container"></div>
|
<div id="terminal-container"></div>
|
||||||
<div>
|
<div>
|
||||||
<h2>Options</h2>
|
<h2>Options</h2>
|
||||||
<label><input type="checkbox" id="option-cursor-blink"> cursorBlink</label>
|
<p>
|
||||||
|
<label><input type="checkbox" id="option-cursor-blink"> cursorBlink</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>Scrollback <input type="number" id="option-scrollback" value="1000" /></label>
|
||||||
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<h3>Size</h3>
|
<h3>Size</h3>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
+7
-3
@@ -8,7 +8,8 @@ var term,
|
|||||||
|
|
||||||
var terminalContainer = document.getElementById('terminal-container'),
|
var terminalContainer = document.getElementById('terminal-container'),
|
||||||
optionElements = {
|
optionElements = {
|
||||||
cursorBlink: document.querySelector('#option-cursor-blink')
|
cursorBlink: document.querySelector('#option-cursor-blink'),
|
||||||
|
scrollback: document.querySelector('#option-scrollback')
|
||||||
},
|
},
|
||||||
colsElement = document.getElementById('cols'),
|
colsElement = document.getElementById('cols'),
|
||||||
rowsElement = document.getElementById('rows');
|
rowsElement = document.getElementById('rows');
|
||||||
@@ -30,6 +31,9 @@ rowsElement.addEventListener('change', setTerminalSize);
|
|||||||
optionElements.cursorBlink.addEventListener('change', function () {
|
optionElements.cursorBlink.addEventListener('change', function () {
|
||||||
term.setOption('cursorBlink', optionElements.cursorBlink.checked);
|
term.setOption('cursorBlink', optionElements.cursorBlink.checked);
|
||||||
});
|
});
|
||||||
|
optionElements.scrollback.addEventListener('change', function () {
|
||||||
|
terminal.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));
|
||||||
|
});
|
||||||
|
|
||||||
createTerminal();
|
createTerminal();
|
||||||
|
|
||||||
@@ -39,7 +43,8 @@ function createTerminal() {
|
|||||||
terminalContainer.removeChild(terminalContainer.children[0]);
|
terminalContainer.removeChild(terminalContainer.children[0]);
|
||||||
}
|
}
|
||||||
term = new Terminal({
|
term = new Terminal({
|
||||||
cursorBlink: optionElements.cursorBlink.checked
|
cursorBlink: optionElements.cursorBlink.checked,
|
||||||
|
scrollback: parseInt(optionElements.scrollback.value, 10)
|
||||||
});
|
});
|
||||||
term.on('resize', function (size) {
|
term.on('resize', function (size) {
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
@@ -80,7 +85,6 @@ function createTerminal() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function runRealTerminal() {
|
function runRealTerminal() {
|
||||||
term.attach(socket);
|
term.attach(socket);
|
||||||
term._initialized = true;
|
term._initialized = true;
|
||||||
|
|||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
const browserify = require('browserify');
|
||||||
|
const buffer = require('vinyl-buffer');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const gulp = require('gulp');
|
||||||
|
const merge = require('merge-stream');
|
||||||
|
const sorcery = require('sorcery');
|
||||||
|
const source = require('vinyl-source-stream');
|
||||||
|
const sourcemaps = require('gulp-sourcemaps');
|
||||||
|
const ts = require('gulp-typescript');
|
||||||
|
const tsify = require('tsify');
|
||||||
|
|
||||||
|
|
||||||
|
let buildDir = process.env.BUILD_DIR || 'build';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript
|
||||||
|
* file compiled.
|
||||||
|
*/
|
||||||
|
gulp.task('tsc', function () {
|
||||||
|
// Remove the lib/ directory to prevent confusion if files were deleted in src/
|
||||||
|
fs.emptyDirSync('lib');
|
||||||
|
|
||||||
|
// Build all TypeScript files (including tests) to lib/, based on the configuration defined in
|
||||||
|
// `tsconfig.json`.
|
||||||
|
let tsProject = ts.createProject('tsconfig.json');
|
||||||
|
let tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject());
|
||||||
|
let tsc = tsResult.js.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest('lib'));
|
||||||
|
|
||||||
|
// Copy all addons from src/ to lib/
|
||||||
|
let copyAddons = gulp.src('src/addons/**/*').pipe(gulp.dest('lib/addons'));
|
||||||
|
|
||||||
|
// Copy stylesheets from src/ to lib/
|
||||||
|
let copyStylesheets = gulp.src('src/**/*.css').pipe(gulp.dest('lib'));
|
||||||
|
|
||||||
|
return merge(tsc, copyAddons, copyStylesheets);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with
|
||||||
|
* Browserify.
|
||||||
|
*/
|
||||||
|
gulp.task('browserify', ['tsc'], function() {
|
||||||
|
// Ensure that the build directory exists
|
||||||
|
fs.ensureDirSync(buildDir);
|
||||||
|
|
||||||
|
let browserifyOptions = {
|
||||||
|
basedir: buildDir,
|
||||||
|
debug: true,
|
||||||
|
entries: ['../lib/xterm.js'],
|
||||||
|
standalone: 'Terminal',
|
||||||
|
cache: {},
|
||||||
|
packageCache: {}
|
||||||
|
};
|
||||||
|
let bundleStream = browserify(browserifyOptions)
|
||||||
|
.plugin(tsify)
|
||||||
|
.bundle()
|
||||||
|
.pipe(source('xterm.js'))
|
||||||
|
.pipe(buffer())
|
||||||
|
.pipe(sourcemaps.init({loadMaps: true, sourceRoot: '..'}))
|
||||||
|
.pipe(sourcemaps.write('./'))
|
||||||
|
.pipe(gulp.dest(buildDir));
|
||||||
|
|
||||||
|
// Copy all add-ons from lib/ to buildDir
|
||||||
|
let copyAddons = gulp.src('lib/addons/**/*').pipe(gulp.dest(`${buildDir}/addons`));
|
||||||
|
|
||||||
|
// Copy stylesheets from src/ to lib/
|
||||||
|
let copyStylesheets = gulp.src('lib/**/*.css').pipe(gulp.dest(buildDir));
|
||||||
|
|
||||||
|
return merge(bundleStream, copyAddons, copyStylesheets);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use `sorcery` to resolve the source map chain and point back to the TypeScript files.
|
||||||
|
* (Without this task the source maps produced for the JavaScript bundle points into the
|
||||||
|
* compiled JavaScript files in lib/).
|
||||||
|
*/
|
||||||
|
gulp.task('sorcery', ['browserify'], function () {
|
||||||
|
var chain = sorcery.loadSync(`${buildDir}/xterm.js`);
|
||||||
|
var map = chain.apply();
|
||||||
|
chain.writeSync();
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('build', ['sorcery']);
|
||||||
|
|
||||||
|
gulp.task('default', ['build']);
|
||||||
+11
-3
@@ -38,18 +38,26 @@
|
|||||||
"browserify": "^13.1.0",
|
"browserify": "^13.1.0",
|
||||||
"chai": "3.5.0",
|
"chai": "3.5.0",
|
||||||
"docdash": "0.4.0",
|
"docdash": "0.4.0",
|
||||||
"exorcist": "^0.4.0",
|
|
||||||
"express": "4.13.4",
|
"express": "4.13.4",
|
||||||
"express-ws": "2.0.0-rc.1",
|
"express-ws": "2.0.0-rc.1",
|
||||||
|
"fs-extra": "^1.0.0",
|
||||||
"glob": "^7.0.5",
|
"glob": "^7.0.5",
|
||||||
|
"gulp": "^3.9.1",
|
||||||
|
"gulp-cli": "^1.2.2",
|
||||||
|
"gulp-sourcemaps": "1.9.1",
|
||||||
|
"gulp-typescript": "^3.1.3",
|
||||||
"jsdoc": "3.4.3",
|
"jsdoc": "3.4.3",
|
||||||
|
"merge-stream": "^1.0.1",
|
||||||
"mocha": "2.5.3",
|
"mocha": "2.5.3",
|
||||||
"nodemon": "1.10.2",
|
"nodemon": "1.10.2",
|
||||||
"pty.js": "0.3.1",
|
"pty.js": "0.3.1",
|
||||||
"sleep": "^3.0.1",
|
"sleep": "^3.0.1",
|
||||||
"sorcery": "^0.10.0",
|
"sorcery": "^0.10.0",
|
||||||
|
"tsify": "^3.0.0",
|
||||||
"tslint": "^4.0.2",
|
"tslint": "^4.0.2",
|
||||||
"typescript": "^2.0.3"
|
"typescript": "^2.0.3",
|
||||||
|
"vinyl-buffer": "^1.0.0",
|
||||||
|
"vinyl-source-stream": "^1.1.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prestart": "npm run build",
|
"prestart": "npm run build",
|
||||||
@@ -58,7 +66,7 @@
|
|||||||
"lint": "tslint src/**/*.ts",
|
"lint": "tslint src/**/*.ts",
|
||||||
"test": "mocha --recursive ./lib",
|
"test": "mocha --recursive ./lib",
|
||||||
"build:docs": "jsdoc -c jsdoc.json",
|
"build:docs": "jsdoc -c jsdoc.json",
|
||||||
"build": "./bin/build",
|
"build": "gulp build",
|
||||||
"prepublish": "npm run build"
|
"prepublish": "npm run build"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-7
@@ -10,13 +10,13 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { CompositionHelper } from './CompositionHelper.js';
|
import { CompositionHelper } from './CompositionHelper';
|
||||||
import { EventEmitter } from './EventEmitter.js';
|
import { EventEmitter } from './EventEmitter';
|
||||||
import { Viewport } from './Viewport.js';
|
import { Viewport } from './Viewport';
|
||||||
import { rightClickHandler, pasteHandler, copyHandler } from './handlers/Clipboard.js';
|
import { rightClickHandler, pasteHandler, copyHandler } from './handlers/Clipboard';
|
||||||
import { CircularList } from './utils/CircularList.js';
|
import { CircularList } from './utils/CircularList';
|
||||||
import { C0 } from './EscapeSequences';
|
import { C0 } from './EscapeSequences';
|
||||||
import { CharMeasure } from './utils/CharMeasure.js';
|
import { CharMeasure } from './utils/CharMeasure';
|
||||||
import * as Browser from './utils/Browser';
|
import * as Browser from './utils/Browser';
|
||||||
import * as Keyboard from './utils/Keyboard';
|
import * as Keyboard from './utils/Keyboard';
|
||||||
|
|
||||||
@@ -405,6 +405,24 @@ Terminal.prototype.setOption = function(key, value) {
|
|||||||
if (!(key in Terminal.defaults)) {
|
if (!(key in Terminal.defaults)) {
|
||||||
throw new Error('No option with key "' + key + '"');
|
throw new Error('No option with key "' + key + '"');
|
||||||
}
|
}
|
||||||
|
switch (key) {
|
||||||
|
case 'scrollback':
|
||||||
|
if (this.options[key] !== value) {
|
||||||
|
if (this.lines.length > value) {
|
||||||
|
const amountToTrim = this.lines.length - value;
|
||||||
|
const needsRefresh = (this.ydisp - amountToTrim < 0);
|
||||||
|
this.lines.trimStart(amountToTrim);
|
||||||
|
this.ybase = Math.max(this.ybase - amountToTrim, 0);
|
||||||
|
this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
|
||||||
|
if (needsRefresh) {
|
||||||
|
this.refresh(0, this.rows - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lines.maxLength = value;
|
||||||
|
this.viewport.syncScrollArea();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
this[key] = value;
|
this[key] = value;
|
||||||
this.options[key] = value;
|
this.options[key] = value;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@@ -618,7 +636,7 @@ Terminal.prototype.open = function(parent) {
|
|||||||
}
|
}
|
||||||
this.parent.appendChild(this.element);
|
this.parent.appendChild(this.element);
|
||||||
|
|
||||||
this.charMeasure = new CharMeasure(this.rowContainer);
|
this.charMeasure = new CharMeasure(this.helperContainer);
|
||||||
this.charMeasure.on('charsizechanged', function () {
|
this.charMeasure.on('charsizechanged', function () {
|
||||||
self.updateCharSizeCSS();
|
self.updateCharSizeCSS();
|
||||||
});
|
});
|
||||||
@@ -1143,6 +1161,10 @@ Terminal.prototype.refresh = function(start, end) {
|
|||||||
row = y + this.ydisp;
|
row = y + this.ydisp;
|
||||||
|
|
||||||
line = this.lines.get(row);
|
line = this.lines.get(row);
|
||||||
|
if (!line || !this.children[y]) {
|
||||||
|
// Continue if the line is not available, this means a resize is currently in progress
|
||||||
|
continue;
|
||||||
|
}
|
||||||
out = '';
|
out = '';
|
||||||
|
|
||||||
if (this.y === y - (this.ybase - this.ydisp)
|
if (this.y === y - (this.ybase - this.ydisp)
|
||||||
@@ -1157,6 +1179,10 @@ Terminal.prototype.refresh = function(start, end) {
|
|||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (; i < width; i++) {
|
for (; i < width; i++) {
|
||||||
|
if (!line[i]) {
|
||||||
|
// Continue if the character is not available, this means a resize is currently in progress
|
||||||
|
continue;
|
||||||
|
}
|
||||||
data = line[i][0];
|
data = line[i][0];
|
||||||
ch = line[i][1];
|
ch = line[i][1];
|
||||||
ch_width = line[i][2];
|
ch_width = line[i][2];
|
||||||
|
|||||||
+6
-2
@@ -7,13 +7,17 @@
|
|||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
},
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*"
|
||||||
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"addons",
|
"src/addons/**/*",
|
||||||
"build",
|
"build",
|
||||||
"demo",
|
"demo",
|
||||||
"dist",
|
"dist",
|
||||||
"out",
|
"out",
|
||||||
"test",
|
"test",
|
||||||
"node_modules"
|
"node_modules",
|
||||||
|
"docs"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user