Commit e181d91b authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

terminal: undo unintercepted moifications to the output area, add emulation...

terminal: undo unintercepted moifications to the output area, add emulation for some special keys for buggy browsers & allow utf8 input. fixes #1924 @4h
parent 954cc628
......@@ -469,6 +469,8 @@ Terminal.prototype.initGlobal = function() {
Terminal.bindKeys(document);
Terminal.bindCopy(document);
Terminal.bindInput(document);
if (this.isIpad || this.isIphone) {
Terminal.fixIpad(document);
......@@ -597,6 +599,27 @@ Terminal.bindCopy = function(document) {
});
};
/**
* Bind to input event
*/
Terminal.bindInput = function(document) {
on(document, 'input', function(ev) {
var term = Terminal.focus;
if (!term) return;
var n = term.element.childNodes;
// remove foreign nodes
for(var i=0; i<n.length; i++) {
if (n[i].nodeType!=1 || n[i].nodeName!='DIV') {
term.element.removeChild(n[i--]);
}
}
term.refresh(0, term.rows - 1);
return cancel(ev);
});
};
/**
* Fix iPad - no idea if this works
*/
......@@ -2615,6 +2638,23 @@ Terminal.prototype.keyDown = function(ev) {
break;
}
if (!key && ev.key) {
key = Terminal.emulatedKey[ev.key]
if (!key && (key=Terminal.emulatedAccent[ev.key])) {
if (this.lastTranslatedKey == key) {
key += key;
this.lastTranslatedKey = undefined;
} else {
this.lastTranslatedKey = key;
return true;
}
} else {
this.lastTranslatedKey = undefined;
}
} else {
this.lastTranslatedKey = undefined;
}
if (!key) return true;
if (this.prefixMode) {
......@@ -5611,6 +5651,16 @@ Terminal.charsets.Swedish = null; // (H or (7
Terminal.charsets.Swiss = null; // (=
Terminal.charsets.ISOLatin = null; // /A
Terminal.emulatedKey = {
'DeadTilde': '~',
'DeadCedilla': '´'
};
Terminal.emulatedAccent = {
'DeadAcute': '´',
'DeadGrave': '`',
'DeadCircumflex': '^'
}
/**
* Helpers
*/
......
......@@ -100,4 +100,4 @@ class Terminal(object):
def write(self, input_data):
fin = self.__master_stdin.fileno()
os.write(fin, input_data)
os.write(fin, input_data.encode('utf8'))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment