update files

This commit is contained in:
nuintun 2015-11-25 10:59:33 +08:00
parent 513d1b0149
commit 8694c71a1b
6 changed files with 59 additions and 14 deletions

View File

@ -494,6 +494,6 @@ header [class*=" icon-"] {
height: calc(100% - 32px);
background: url(../images/no-data.png) center no-repeat;
}
.ui-terminal-cursor:before {
content: "_";
.ui-terminal-cursor {
text-decoration: underline;
}

View File

@ -129,7 +129,7 @@ module.exports = Vue.component('app-main', {
xterm.focus();
xterm.startBlink();
console.log(xterm);
//console.log(xterm);
xterm.write(test);
//scroll(xtermNode);

View File

@ -8,13 +8,47 @@ var states = require('./lib/states');
module.exports = Terminal;
function Terminal(opts){
opts = opts || {};
function iterator(from, iterator, context){
for (var key in from) {
if (from.hasOwnProperty(key)) {
iterator.call(context, key, from[key]);
}
}
}
if (!(this instanceof Terminal)) return new Terminal(opts);
function Terminal(options){
options = options || {};
this.cols = opts.cols || 500;
this.rows = opts.rows || 100;
if (!(this instanceof Terminal)) return new Terminal(options);
iterator(Terminal.defaults, function (key, value){
console.log(key);
if (options.hasOwnProperty(options)) {
this[key] = options[key];
} else {
this[key] = value;
}
}, this);
if (Array.isArray(options.colors)) {
if (options.colors.length === 8) {
this.colors = options.colors.concat(Terminal.colors.slice(8));
} else if (options.colors.length === 16) {
this.colors = options.colors.concat(Terminal.colors.slice(16));
} else if (options.colors.length === 10) {
this.colors = options.colors.slice(0, -2).concat(Terminal.colors.slice(8, -2), options.colors.slice(-2));
} else if (options.colors.length === 18) {
this.colors = options.colors.slice(0, -2).concat(Terminal.colors.slice(16, -2), options.colors.slice(-2));
} else {
this.colors = Terminal.colors;
}
} else {
this.colors = Terminal.colors;
}
this.cols = options.cols || Terminal.geometry[0];
this.rows = options.rows || Terminal.geometry[1];
this.ybase = 0;
this.ydisp = 0;

View File

@ -5,7 +5,7 @@
'use strict';
module.exports = function (Terminal){
Terminal.prototype.cursorBlink = function (){
Terminal.prototype.blinkCursor = function (){
if (Terminal.focus !== this) return;
this.cursorState ^= 1;
@ -20,19 +20,19 @@ module.exports = function (Terminal){
};
Terminal.prototype.startBlink = function (){
if (!Terminal.cursorBlink) return;
if (!this.cursorBlink) return;
var self = this;
this._blinker = function (){
self.cursorBlink();
self.blinkCursor();
};
this._blink = setInterval(this._blinker, 500);
};
Terminal.prototype.refreshBlink = function (){
if (!Terminal.cursorBlink) return;
if (!this.cursorBlink) return;
clearInterval(this._blink);

View File

@ -14,4 +14,15 @@ module.exports = function (Terminal){
Terminal.screenKeys = false;
Terminal.programFeatures = false;
Terminal.debug = false;
Terminal.defaults = {
termName: Terminal.termName,
cursorBlink: Terminal.cursorBlink,
visualBell: Terminal.visualBell,
popOnBell: Terminal.popOnBell,
scrollback: Terminal.scrollback,
screenKeys: Terminal.screenKeys,
programFeatures: Terminal.programFeatures,
debug: Terminal.debug
};
};

View File

@ -107,11 +107,11 @@ module.exports = function (Terminal){
}
if (bgColor !== 256) {
out += 'background-color:' + Terminal.colors[bgColor] + ';';
out += 'background-color:' + this.colors[bgColor] + ';';
}
if (fgColor !== 257) {
out += 'color:' + Terminal.colors[fgColor] + ';';
out += 'color:' + this.colors[fgColor] + ';';
}
out += '">';