readline should provide a way to stop echoing keypresses #5092

Open
bpytlik opened this Issue Mar 20, 2013 · 7 comments

Comments

Projects
None yet
5 participants

bpytlik commented Mar 20, 2013

As part of my project, I want to take control from readline for a bit to display a stream of data. I can use rl.pause and disable the prompt so that the output looks as desired. However, when the user types a key, the key still shows up on the screen, which is not what's desired. By monkey patching stdout.write, I was eventually able to discover that this was happening because readline was still listening to the "keypress" event (which I couldn't find documentation of). I was only able to achieve what I desired by removing all the listeners to the keypress event and adding my listener in. When I'm done streaming the data, I removed my listener and restored the previously existing listeners.

While I achieved my goals, the steps to get there were not obvious or documented. I'd like to see functionality exposed via a function (stopEcho?) but I could accept better documentation of the keypress event in the readline api.

All of this was done using node 0.8.15.

Have you tried the terminal: false option?

bpytlik commented Mar 20, 2013

That might work if I never wanted the readline instance to echo keypresses. From what I can see of the code, almost all of its effect is at initialization time. Flipping terminal from true to false later doesn't have the desired effect in my testing.

To be clear, what I'm looking for is the ability to start a readline "normally". Then, in response to a command issued by the user, take control from readline for a period of time before returning it.

Crazy possible solution. It is possible to start a repl within a repl. So for that command start a new one with the given parameters, suppress the output from the first then jump out when you're done.

chrisdickinson added the doc label Nov 16, 2014

Owner

jasnell commented May 27, 2015

Going to assume this one is safe to close. Can reopen if new information is received.

jasnell closed this May 27, 2015

bpytlik commented May 28, 2015

Why was this closed? What new information would you like? The original issue still stands as far as I know which is this:
It's hard to dynamically adjust whether keypresses are echoed by readline, and the only way to do so is to use an undocumented interface.
If the documentation has been improved or the interface requested has been added, then please include a link to that information. Thanks.

Owner

jasnell commented May 28, 2015

Because I wasn't able to determine if it was still necessary to keep open. We can reopen and mark as a feature request if you'd like.

bpytlik commented May 28, 2015

Thanks. Please reopen it.

Brock

On Wed, May 27, 2015 at 5:26 PM, James M Snell notifications@github.com
wrote:

Because I wasn't able to determine if it was still necessary to keep open.
We can reopen and mark as a feature request if you'd like.


Reply to this email directly or view it on GitHub
joyent#5092 (comment).

jasnell reopened this May 28, 2015

@joaocgreis joaocgreis pushed a commit to janeasystems/node-v0.x-archive that referenced this issue Feb 26, 2016

@rvagg rvagg 2016-02-23, Version 5.7.0 (Stable)
* buffer:
  - You can now supply an encoding argument when filling a
    Buffer Buffer#fill(string[, start[, end]][, encoding]), supplying
    an existing Buffer will also work with
    Buffer#fill(buffer[, start[, end]]). See the API documentation for
    details on how this works. (Trevor Norris) #4935
  - Buffer#indexOf() no longer requires a byteOffset argument if you
    also wish to specify an encoding:
    Buffer#indexOf(val[, byteOffset][, encoding]).
    (Trevor Norris) #4803
* child_process: spawn() and spawnSync() now support a 'shell' option
  to allow for optional execution of the given command inside a shell.
  If set to true, cmd.exe will be used on Windows and /bin/sh
  elsewhere. A path to a custom shell can also be passed to override
  these defaults. On Windows, this option allows .bat. and .cmd files
  to be executed with spawn() and spawnSync(). (Colin Ihrig) #4598
* http_parser: Update to http-parser 2.6.2 to fix an unintentionally
  strict limitation of allowable header characters.
  (James M Snell) #5237
* dgram: socket.send() now supports accepts an array of Buffers or
  Strings as the first argument. See the API docs for details on how
  this works. (Matteo Collina) #4374
* http: Fix a bug where handling headers will mistakenly trigger an
  'upgrade' event where the server is just advertising its protocols.
  This bug can prevent HTTP clients from communicating with HTTP/2
  enabled servers. (Fedor Indutny) #4337
* net: Added a listening Boolean property to net and http servers to
  indicate whether the server is listening for connections.
  (José Moreira) #4743
* node: The C++ node::MakeCallback() API is now reentrant and calling
  it from inside another MakeCallback() call no longer causes the
  nextTick queue or Promises microtask queue to be processed out of
  order. (Trevor Norris) #4507
* tls: Add a new tlsSocket.getProtocol() method to get the negotiated
  TLS protocol version of the current connection. (Brian White) #4995
* vm: Introduce new 'produceCachedData' and 'cachedData' options to
  new vm.Script() to interact with V8's code cache. When a new
  vm.Script object is created with the 'produceCachedData' set to true
  a Buffer with V8's code cache data will be produced and stored in
  cachedData property of the returned object. This data in turn may be
  supplied back to another vm.Script() object with a 'cachedData'
  option if the supplied source is the same. Successfully executing a
  script from cached data can speed up instantiation time. See the API
  docs for details. (Fedor Indutny) #4777
* performance: Improvements in:
  - process.nextTick() (Ruben Bridgewater) #5092
  - path module (Brian White) #5123
  - querystring module (Brian White) #5012
  - streams module when processing small chunks (Matteo Collina) #4354

PR-URL: nodejs/node#5295
7b0a83d

@richardlau richardlau pushed a commit to ibmruntimes/node that referenced this issue Feb 29, 2016

@rvagg rvagg 2016-02-23, Version 5.7.0 (Stable)
* buffer:
  - You can now supply an encoding argument when filling a
    Buffer Buffer#fill(string[, start[, end]][, encoding]), supplying
    an existing Buffer will also work with
    Buffer#fill(buffer[, start[, end]]). See the API documentation for
    details on how this works. (Trevor Norris) #4935
  - Buffer#indexOf() no longer requires a byteOffset argument if you
    also wish to specify an encoding:
    Buffer#indexOf(val[, byteOffset][, encoding]).
    (Trevor Norris) #4803
* child_process: spawn() and spawnSync() now support a 'shell' option
  to allow for optional execution of the given command inside a shell.
  If set to true, cmd.exe will be used on Windows and /bin/sh
  elsewhere. A path to a custom shell can also be passed to override
  these defaults. On Windows, this option allows .bat. and .cmd files
  to be executed with spawn() and spawnSync(). (Colin Ihrig) #4598
* http_parser: Update to http-parser 2.6.2 to fix an unintentionally
  strict limitation of allowable header characters.
  (James M Snell) #5237
* dgram: socket.send() now supports accepts an array of Buffers or
  Strings as the first argument. See the API docs for details on how
  this works. (Matteo Collina) #4374
* http: Fix a bug where handling headers will mistakenly trigger an
  'upgrade' event where the server is just advertising its protocols.
  This bug can prevent HTTP clients from communicating with HTTP/2
  enabled servers. (Fedor Indutny) #4337
* net: Added a listening Boolean property to net and http servers to
  indicate whether the server is listening for connections.
  (José Moreira) #4743
* node: The C++ node::MakeCallback() API is now reentrant and calling
  it from inside another MakeCallback() call no longer causes the
  nextTick queue or Promises microtask queue to be processed out of
  order. (Trevor Norris) #4507
* tls: Add a new tlsSocket.getProtocol() method to get the negotiated
  TLS protocol version of the current connection. (Brian White) #4995
* vm: Introduce new 'produceCachedData' and 'cachedData' options to
  new vm.Script() to interact with V8's code cache. When a new
  vm.Script object is created with the 'produceCachedData' set to true
  a Buffer with V8's code cache data will be produced and stored in
  cachedData property of the returned object. This data in turn may be
  supplied back to another vm.Script() object with a 'cachedData'
  option if the supplied source is the same. Successfully executing a
  script from cached data can speed up instantiation time. See the API
  docs for details. (Fedor Indutny) #4777
* performance: Improvements in:
  - process.nextTick() (Ruben Bridgewater) #5092
  - path module (Brian White) #5123
  - querystring module (Brian White) #5012
  - streams module when processing small chunks (Matteo Collina) #4354

PR-URL: nodejs/node#5295
cf317e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment