Browse Source

Ctrl+W support for the REPL

FWIW, command-line style (delete back to whitespace) would be:
    leading = leading.replace(/\S+\s*$/, '');
v0.7.4-release
Trent Mick 15 years ago
committed by Ryan Dahl
parent
commit
5330fea954
  1. 11
      lib/readline.js

11
lib/readline.js

@ -331,6 +331,17 @@ Interface.prototype._ttyWrite = function (b) {
this._historyNext(); this._historyNext();
break; break;
case 23: // control-w, delete backwards to a word boundary
if (this.cursor !== 0) {
var leading = this.line.slice(0, this.cursor);
var match = leading.match(/\s?((\W+|\w+)\s*)$/);
leading = leading.slice(0, leading.length - match[1].length);
this.line = leading + this.line.slice(this.cursor, this.line.length);
this.cursor = leading.length;
this._refreshLine();
}
break;
case 9: // tab, completion case 9: // tab, completion
if (this.completer) { if (this.completer) {
this._tabComplete(); this._tabComplete();

Loading…
Cancel
Save