From 0afc37e96bc3ba524246d2432bfe4877cd4b7f68 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 20 Sep 2012 12:54:00 +0200 Subject: [PATCH] Cmd-K clears the terminal --- static/term.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/static/term.js b/static/term.js index b4f7ee74..f803048c 100644 --- a/static/term.js +++ b/static/term.js @@ -914,6 +914,18 @@ Terminal.prototype.refreshBlink = function() { this._blink = setInterval(this._blinker, 500); }; +Terminal.prototype.clear = function() { + this.lines.splice(0, this.ybase + this.y); + this.lines.splice(1, this.lines.length-1); + while (this.lines.length < this.rows) { + this.lines.push(this.blankLine()); + } + this.y = 0; + this.ybase = 0; + this.ydisp = 0; + this.refresh(0, this.rows - 1); +} + Terminal.prototype.scroll = function() { var row; @@ -2049,6 +2061,12 @@ Terminal.prototype.keyDown = function(ev) { key = '\x1b[6~'; } break; + // CTRL-K + case 75: + if ((!isMac && ev.ctrlKey) || (isMac && ev.metaKey)) { + this.clear(); + return cancel(ev); + } // F1 case 112: key = '\x1bOP';