};
EventEmitter.prototype.once = function(type, listener) {
+ var self = this;
function on() {
var args = Array.prototype.slice.call(arguments);
- this.removeListener(type, on);
- return listener.apply(this, args);
+ self.removeListener(type, on);
+ return listener.apply(self, args);
}
on.listener = listener;
return this.on(type, on);
var text = ev.clipboardData.getData('text/plain');
term.handler(text);
}
- return term.cancel(ev, true);
});
};
*/
Terminal.bindKeys = function(term) {
on(term.element, 'keydown', function(ev) {
+ /*
+ * Clear all selections if the key pressed was not among
+ * Shift, Alt, Cmd, Ctrl.
+ */
+ var selection = window.getSelection();
+ if (selection.toString() != '') {
+ if ([16, 17, 18, 91].indexOf(ev.keyCode) == -1) {
+ selection.removeAllRanges();
+ }
+ }
term.keyDown(ev);
}, true);
};
+ Terminal.click = function (term) {
+ /*
+ * Do not perform the "drop" event. Altering the contents of the
+ * terminal with drag n drop is unwanted behavior.
+ */
+ on(term.element, 'click', function (ev) {
+ term.cancel(ev, true);
+ });
+ };
+
+
/*
* Insert the given row to the terminal or produce a new one
* if no row argument is passed. Return the inserted row.
this.element.classList.add('xterm');
this.element.classList.add('xterm-theme-' + this.theme);
this.element.setAttribute('tabindex', 0);
- this.element.contentEditable = 'true';
this.element.spellcheck = 'false';
/*