Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Readline proposal and bugfixes. #2757

Closed
wants to merge 1 commit into from
Closed

Conversation

Southern
Copy link

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
Copy link
Author

Working on docs.

@bnoordhuis
Copy link
Member

cc @indutny

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.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Southern
Copy link
Author

May need a few more changes. Will continue testing.

@Southern
Copy link
Author

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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@indutny
Copy link
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
Copy link
Member

indutny commented Feb 16, 2012

otherwise, lgtm.

@indutny
Copy link
Member

indutny commented Feb 16, 2012

But please squash commits once you'll fix error

@indutny
Copy link
Member

indutny commented Feb 16, 2012

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

Related: nodejs#2737 nodejs#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
@indutny
Copy link
Member

indutny commented Feb 16, 2012

landed in ce48579

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants