diff options
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/readline.js b/lib/readline.js index aba30985b8..5711c5c867 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -290,6 +290,7 @@ Interface.prototype._tabComplete = function() { } }; + function commonPrefix(strings) { if (!strings || strings.length == 0) { return ''; @@ -305,6 +306,7 @@ function commonPrefix(strings) { return min; } + Interface.prototype._deleteLeft = function() { if (this.cursor > 0 && this.line.length > 0) { this.line = this.line.slice(0, this.cursor - 1) + @@ -315,11 +317,13 @@ Interface.prototype._deleteLeft = function() { } }; + Interface.prototype._deleteRight = function() { this.line = this.line.slice(0, this.cursor) + this.line.slice(this.cursor + 1, this.line.length); this._refreshLine(); -} +}; + Interface.prototype._line = function() { var line = this._addHistory(); @@ -327,6 +331,7 @@ Interface.prototype._line = function() { this._onLine(line); }; + Interface.prototype._historyNext = function() { if (this.historyIndex > 0) { this.historyIndex--; @@ -342,6 +347,7 @@ Interface.prototype._historyNext = function() { } }; + Interface.prototype._historyPrev = function() { if (this.historyIndex + 1 < this.history.length) { this.historyIndex++; @@ -478,7 +484,10 @@ Interface.prototype._ttyWrite = function(s, key) { case 'f': // forward word if (this.cursor < this.line.length) { - next_word = this.line.slice(this.cursor, this.line.length).search(/\w/); + next_word = this.line + .slice(this.cursor, this.line.length) + .search(/\w/); + if (next_word !== -1) { next_non_word = this.line.slice(this.cursor + next_word, this.line.length).search(/\W/); @@ -495,7 +504,10 @@ Interface.prototype._ttyWrite = function(s, key) { case 'd': // delete forward word if (this.cursor < this.line.length) { - next_word = this.line.slice(this.cursor, this.line.length).search(/\w/); + next_word = this.line + .slice(this.cursor, this.line.length) + .search(/\w/); + if (next_word !== -1) { next_non_word = this.line.slice(this.cursor + next_word, this.line.length).search(/\W/); @@ -586,4 +598,5 @@ Interface.prototype._ttyWrite = function(s, key) { } }; + exports.Interface = Interface; |