Compare commits

...
4 Commits
Author SHA1 Message Date
paris 0997f4398f Proper event handling
Bump bower version to 0.7
2014-04-10 14:39:17 +00:00
paris e278837de8 Fix focus on refresh 2014-04-09 16:49:29 +00:00
paris e572734a21 Syntax fix
Bumped bower version to 0.5
2014-04-09 15:42:37 +00:00
paris 4f2cadd6c9 Fixed paste
Bumped bower version to 0.4
2014-04-09 15:37:45 +00:00
4 changed files with 16 additions and 17 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
{ {
"name": "xterm.js", "name": "xterm.js",
"version": "0.3", "version": "0.7",
"ignore": ["demo", "docs", "test", ".gitignore"] "ignore": ["demo", "docs", "test", ".gitignore"]
} }
-1
View File
@@ -17,7 +17,6 @@ term.on('key', function (key, ev) {
var printable = (!ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey); var printable = (!ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey);
if (ev.keyIdentifier == 'Enter') { if (ev.keyIdentifier == 'Enter') {
ev.preventDefault();
term.prompt(); term.prompt();
} else if (ev.keyCode == 8) { } else if (ev.keyCode == 8) {
term.write('\b \b'); term.write('\b \b');
-1
View File
@@ -1 +0,0 @@
/mnt/project/
+14 -13
View File
@@ -419,7 +419,6 @@ Terminal.bindPaste = function(term) {
ev.stopPropagation(); ev.stopPropagation();
if (ev.clipboardData) { if (ev.clipboardData) {
var text = ev.clipboardData.getData('text/plain'); var text = ev.clipboardData.getData('text/plain');
term.write(text);
term.handler(text); term.handler(text);
} }
term.textarea.value = ''; term.textarea.value = '';
@@ -954,7 +953,7 @@ Terminal.prototype.destroy = function() {
* 1=bold, 2=underline, 4=blink, 8=inverse, 16=invisible * 1=bold, 2=underline, 4=blink, 8=inverse, 16=invisible
*/ */
Terminal.prototype.refresh = function(start, end) { Terminal.prototype.refresh = function(start, end) {
var x, y, i, line, out, ch, width, data, attr, bg, fg, flags, row, parent; var x, y, i, line, out, ch, width, data, attr, bg, fg, flags, row, parent, focused = document.activeElement;
if (end - start >= this.rows / 2) { if (end - start >= this.rows / 2) {
parent = this.element.parentNode; parent = this.element.parentNode;
@@ -1087,6 +1086,10 @@ Terminal.prototype.refresh = function(start, end) {
parent.appendChild(this.element); parent.appendChild(this.element);
} }
/*
* Return focus to previously focused element
*/
focused.focus();
this.emit('refresh', {element: this.element, start: start, end: end}); this.emit('refresh', {element: this.element, start: start, end: end});
}; };
@@ -2170,14 +2173,17 @@ Terminal.prototype.keyDown = function(ev) {
break; break;
} }
key = '\t'; key = '\t';
this.cancel(ev, true);
break; break;
// return/enter // return/enter
case 13: case 13:
key = '\r'; key = '\r';
this.cancel(ev, true);
break; break;
// escape // escape
case 27: case 27:
key = '\x1b'; key = '\x1b';
this.cancel(ev, true);
break; break;
// left-arrow // left-arrow
case 37: case 37:
@@ -2351,7 +2357,7 @@ Terminal.prototype.keyDown = function(ev) {
this.emit('keydown', ev); this.emit('keydown', ev);
this.emit('key', key, ev); this.emit('key', key, ev);
console.log('keydown');
this.showCursor(); this.showCursor();
this.handler(key); this.handler(key);
@@ -2393,7 +2399,7 @@ Terminal.prototype.keyPress = function(ev) {
this.emit('keypress', key, ev); this.emit('keypress', key, ev);
this.emit('key', key, ev); this.emit('key', key, ev);
console.log('keypress');
this.showCursor(); this.showCursor();
this.handler(key); this.handler(key);
@@ -4657,17 +4663,12 @@ function off(el, type, handler, capture) {
el.removeEventListener(type, handler, capture || false); el.removeEventListener(type, handler, capture || false);
} }
function cancel(ev) { function cancel(ev, force) {
if (!this.cancelEvents) { if (!this.cancelEvents && !force) {
return; return;
} }
if (ev.preventDefault) { ev.preventDefault();
ev.preventDefault(); ev.stopPropagation();
}
if (ev.stopPropagation) {
ev.stopPropagation();
}
ev.cancelBubble = true;
return false; return false;
} }