Readline proposal and bugfixes. #2757

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@Southern

Related: #2737 #2756

  • Removed extra newline from .question(); Users can input a
    newline if it they require it.
  • Removed .close() due to it only emulating closing, causing a bug where
    readline is left open to trigger events such as .on('line', ...').
  • Removed ._attemptClose()
  • .pause() now triggers event .on('pause', ...)
  • .resume() now triggers event .on('resume', ...)
  • CTRL-C (SIGINT) in readline will now default to .pause() if no SIGINT event
    is present.
  • CTRL-D (delete right) will also default to .pause() if there is nothing to
    delete (signaling the end of the file).
  • Added new event SIGTSTP
  • Added new event SIGCONT
  • Added resume to write to resume the stream if paused.
  • Docs updated.
  • Updated repl.js
@Southern

Working on docs.

@bnoordhuis
Member
@Southern Southern commented on the diff Feb 15, 2012
doc/api/readline.markdown
-Take a look at this slightly more complicated
-[example](https://gist.github.com/901104), and
-[http-console](https://github.com/cloudhead/http-console) for a real-life use
-case.
@Southern
Southern Feb 15, 2012

These examples were removed because they are no longer valid with the API change.

@Southern

May need a few more changes. Will continue testing.

@Southern

Known issues:

  • Sending a script to the background with CTRL-Z (SIGTSTP) and bringing it back to the foreground will result in readline not catching CTRL-C (SIGINT) or CTRL-D (EOF).

Working on a solution.

Edit: Solution implemented.

@indutny indutny commented on the diff Feb 16, 2012
doc/api/readline.markdown
@@ -4,8 +4,8 @@ To use this module, do `require('readline')`. Readline allows reading of a
stream (such as STDIN) on a line-by-line basis.
Note that once you've invoked this module, your node program will not
-terminate until you've closed the interface, and the STDIN stream. Here's how
-to allow your program to gracefully terminate:
+terminate until you've paused the interface. Here's how to allow your
@indutny
indutny Feb 16, 2012 Member

Can you change last sentence? It's meaningless now (you're stating same thing as in first sent. )

@indutny
Member
indutny commented Feb 16, 2012

Lets talk about issues:

~/Code/git/indutny/node > ./node
> 
(^C again to quit)
> 
repl.js:133
      rli.close();
          ^
TypeError: Object #<Interface> has no method 'close'
    at Interface.<anonymous> (repl.js:133:11)
    at Interface.emit (events.js:88:20)
    at Interface._ttyWrite (readline.js:473:16)
    at ReadStream.<anonymous> (readline.js:82:12)
    at ReadStream.emit (events.js:88:20)
    at ReadStream._emitKey (tty.js:331:10)
    at ReadStream.onData (tty.js:66:12)
    at ReadStream.emit (events.js:67:17)
    at TTY.onread (net.js:377:14)
@indutny
Member
indutny commented Feb 16, 2012

otherwise, lgtm.

@indutny
Member
indutny commented Feb 16, 2012

But please squash commits once you'll fix error

@indutny
Member
indutny commented Feb 16, 2012

May be we should add a deprecation warning to .close() ?

@Southern Southern Readline proposal and bugfixes.
Related: #2737 #2756

- Removed extra newline from .question(); Users can input a
  newline if it they require it.
- Removed .close() due to it only emulating closing, causing a bug where
  readline is left open to trigger events such as .on('line', ...').
- Removed ._attemptClose()
- .pause() now triggers event .on('pause', ...)
- .resume() now triggers event .on('resume', ...)
- CTRL-C (SIGINT) in readline will now default to .pause() if no SIGINT event
  is present.
- CTRL-D (delete right) will also default to .pause() if there is nothing to
  delete (signaling the end of the file).
- Added new event `SIGTSTP`
- Added new event `SIGCONT`
- Added `resume` to `write` to resume the stream if paused.
- Docs updated.
- Updated repl.js
a0f7221
@indutny
Member
indutny commented Feb 16, 2012

landed in ce48579

Thank you!

@indutny indutny closed this Feb 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment