Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #3 Process backspace characters properly in raw reads

  • Loading branch information...
commit d746f7565cec3b4768c6a323bd3b19fc1e16f52a 1 parent ce40398
@isaacs authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/read.js
View
8 lib/read.js
@@ -128,6 +128,11 @@ function rawRead (def, timeout, delim, silent, num, cb) {
case "": // probably just a \r that was ignored.
break
+ case "\u007f": // backspace
+ val = val.substr(0, val.length - 1)
+ if (!silent) process.stdout.write('\b \b')
+ break
+
case "\u0004": // EOF
case delim:
raw(false)
@@ -151,7 +156,8 @@ function rawRead (def, timeout, delim, silent, num, cb) {
buffer = ""
if (!silent) process.stdout.write(c)
- // explicitly process a delim if we have enough chars.
+ // explicitly process a delim if we have enough chars
+ // and stop the processing.
if (num && val.length >= num) D(delim)
break
}
Please sign in to comment.
Something went wrong with that request. Please try again.