Граф коммитов

115 Коммитов

Автор SHA1 Сообщение Дата
Dan Kaplun 4a90f51bfe readline: implements keypress buffering
There was an underlying assumption in readline.emitKeypressEvents (and
by extension emitKey) that the given stream (usually process.stdin)
would emit 'data' once per keypress, which is not always the case.

This commit buffers the input stream and ensures a 'keypress' event is
triggered for every keypress (including escape codes).

Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-05-13 13:36:53 +04:00
Yazhong Liu e1aa066fe1 readline: fix close event of readline.Interface()
Not removing 'end' listeners for input and output on the 'close' event
resulted in an EventEmitter related memory leak.

This issue also might be reproduced at:
https://github.com/npm/npm/issues/5203

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-05-12 14:13:14 -07:00
Yazhong Liu 93c3674ff7 readline: consider newlines for cursor position
Fixes #7266.
Closes #7279.
2014-03-12 14:47:17 -03:00
Yazhong Liu cfe0bab85b readline: fix `line` event, if input emit 'end'
If an input stream would emit `end` event, like
`fs.createReadStream`, then readline need to get the last line
correctly even though that line isnt ended with `\n`.
2014-02-17 16:21:29 -08:00
Timothy J Fontaine 42af62f33a Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	configure
	deps/uv/ChangeLog
	deps/uv/src/version.c
	lib/tls.js
	src/node_version.h
2013-09-24 16:49:01 -07:00
Eric Schrock 35ae696822 readline: handle input starting with control chars
Handle control characters only when there is a single byte in the
stream, otherwise fall through to the standard multibyte handling.
2013-09-23 14:22:37 -07:00
isaacs 689e5c9d3d stream: return this from pause()/resume() 2013-09-04 11:17:28 -07:00
Matthew Aynalem c171c490f2 fixes #6031 spelling errors
explictly => explicitly
accesss => access
througput => throughput
epxression => expression
communiction => communication
becuase => because
repersent => represent
condonitions => conditions
decompresion => decompression
intentially => intentionally
eventes => events
listning => listening
resicved => received
becuase => because
fundimental => fundamental
colapse => collapse
privlages => privileges
sufficently => sufficiently
hapepns => happens
expliclitly => explicitly
thier => their
shold => should
2013-08-19 16:42:16 -07:00
Daniel Chatfield 5453619eb2 readline: pause stdin before turning off terminal raw mode
On windows, libuv will immediately make a `ReadConsole` call (in the
thread pool) when a 'flowing' `uv_tty_t` handle is switched to
line-buffered mode. That causes an immediate issue for some users,
since libuv can't cancel the `ReadConsole` operation on Windows 8 /
Server 2012 and up if the program switches back to raw mode later.

But even if this will be fixed in libuv at some point, it's better to
avoid the overhead of starting work in the thread pool and immediately
cancelling it afther that.

See also f34f1e3, where the same change is made for the opposite
flow, e.g. move `resume()` after `_setRawMode(true)`.

Fixes #5927

This is a backport of dfb0461 (see #5930) to the v0.10 branch.
2013-08-17 15:35:09 +02:00
Daniel Chatfield dfb0461c4c readline: pause stdin before turning off terminal raw mode
On windows, libuv will immediately make a `ReadConsole` call (in the
thread pool) when a 'flowing' `uv_tty_t` handle is switched to
line-buffered mode. That causes an immediate issue for some users,
since libuv can't cancel the `ReadConsole` operation on Windows 8 /
Server 2012 and up if the program switches back to raw mode later.

But even if this will be fixed in libuv at some point, it's better to
avoid the overhead of starting work in the thread pool and immediately
cancelling it afther that.

See also f34f1e3, where the same change is made for the opposite
flow, e.g. move `resume()` after `_setRawMode(true)`.

Fixes #5927
Closes #5930
2013-08-17 15:22:50 +02:00
Brian White 6d842897c5 lib: remove unused variables and functions 2013-08-15 17:19:17 -07:00
isaacs 22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Ben Noordhuis 0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
isaacs adf9b67e59 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/build/common.gypi
	deps/v8/src/frames.h
	deps/v8/src/runtime.cc
	deps/v8/test/mjsunit/debug-set-variable-value.js
	lib/http.js
	src/node_version.h
2013-06-25 11:12:33 -07:00
Krzysztof Chrapka ffcd8b94c2 readline: strip ctrl chars for prompt width calc
Use regular expression to strip vt ansi escape codes from display when
calulating prompt display width and cursor position

Fixes #3860 and #5628.
2013-06-17 16:19:12 +02:00
Yuan Chuan 18574bfaf1 readline: make `ctrl + L` clear the screen 2013-06-17 15:57:04 +02:00
Nao Iizuka 94284e7d2e readline: handle wide characters properly
Handle wide characters (such as あ, 谢, 고) as two column wide to make
cursor move properly.

Closes #555.
Closes #4994.
2013-03-15 16:18:30 -10:00
Trevor Norris 75305f3bab events: add check for listeners length
Ability to return just the length of listeners for a given type, using
EventEmitter.listenerCount(emitter, event). This will be a lot cheaper
than creating a copy of the listeners array just to check its length.
2013-03-01 17:36:47 -08:00
isaacs f64d1febc8 lint 2013-01-29 23:57:23 -08:00
isaacs 60f18ede39 readline: treat bare \r as a line ending
Fixes #3305
2013-01-29 18:21:31 -08:00
Ben Noordhuis 9bd9c546c8 readline: make \r\n emit one 'line' event
Make lines ending \r\n emit one 'line' event, not two (where the second
one is an empty string).

This adds a new keypress name: 'return' (as in: 'carriage return').

Fixes #3305.
2013-01-29 17:15:24 +01:00
Nathan Rajlich 3c91a7ae10 readline: use a "string_decoder" to parse "keypress" events
While updating the readline test cases to test both "terimal: false" and
"terminal: true" mode, it turned out that the test case testing utf8 chars
being sent over multiple write() calls was failing. The solution is to use
a string_decoder instance when parsing the "keypress" events.
2012-11-06 16:28:30 -08:00
Nathan Rajlich e95e095289 readline: don't emit "line" events with a trailing '\n' char
Before this commit, readline was inconsistent in whether or not it would emit
"line" events with or without the trailing "\n" included. When "terminal"
mode was true, then there would be no "\n", when it was false, then the "\n"
would be present. However, the trailing "\n" doesn't add much, and most of the
time people just end up stripping it manually.

Part of #4243.
2012-11-06 16:28:24 -08:00
Bert Belder 6822488c93 repl: call resume() after setRawMode()
Solves #4178, but does not fix the underlying issue
2012-10-24 02:42:57 +02:00
isaacs e5498331f4 Merge remote-tracking branch 'ry/v0.8'
Conflicts:
	AUTHORS
	ChangeLog
	src/node_version.h
2012-07-26 11:58:03 -07:00
isaacs e4c9c9f412 readline: Remove event listeners on close
Fix #3756
2012-07-24 15:36:53 -07:00
isaacs 424cd5a020 Merge remote-tracking branch 'ry/v0.8' into v0.8-merge
Conflicts:
	src/node_version.h
2012-07-11 17:38:11 -07:00
Nathan Rajlich 8a9e8d60d2 readline: don't use Function#call()
It wasn't necessary.
2012-07-06 19:41:01 -07:00
Jonas Westerlund 2297d638c1 Forgotten commit: add arguments to handleGroup 2012-07-06 19:28:35 -07:00
Jonas Westerlund 0b0b72c2fa Move function declaration to top-level
Gets rid of a strict mode error and a few levels of indentation.
2012-07-06 19:28:35 -07:00
Tim Macfarlane 0dba28b5c2 readline: fix for unicode prompts
prompt length is char length, not byte length
2012-07-06 02:14:47 +02:00
Vladimir Beloborodov 3ea0397a1a readline: Use one history item for reentered line
If the command entered is exactly the same as the last history item,
don't dupe it in the history
2012-07-05 01:40:43 +02:00
Andreas Madsen 1e0ce5d1bd domain: the EventEmitter constructor is now always called in nodecore 2012-06-15 09:49:05 -07:00
Nathan Rajlich 032fc42e64 readline: don't cache the "keypress" listeners
it's not safe to since `removeAllListeners()` will detach the returned
Array from the stream instance if that's ever called by the user.
2012-06-14 17:26:50 -07:00
isaacs 54a4f99c4e lint 2012-06-11 08:13:36 -07:00
Nathan Rajlich 3f69c71157 readline: explicitly disable and re-enable "raw mode" on Ctrl+Z
Fixes #3295.
2012-05-21 21:09:46 -03:00
Nathan Rajlich 2b9967fbcc readline: move the "setRawMode" logic into a private function 2012-05-21 21:09:46 -03:00
Kyle Robinson Young da56c72f59 readline: remove unused vars in _ttyWrite 2012-04-21 05:30:24 +02:00
Kyle Robinson Young e67a0f80e0 readline: _normalWrite() doesn't take a key modifier arg 2012-04-18 23:36:46 +02:00
Kyle Robinson Young 57148f54e1 readline: change char to ch to avoid reserved word 2012-04-18 21:57:39 +02:00
Nathan Rajlich 9c3559f0ad readline: re-add the Interface#close() method; rename "end" to "close"
The idea here is to reduce the number of times that `setRawMode()` is called
on the `input` stream, since it is expensive, and simply pause()/resume()
should not call it.

So now `setRawMode()` only gets called at the beginning of the Interface
instance, and then when `Interface#close()` is called.

Test case included.
2012-04-17 11:53:50 -07:00
Nathan Rajlich 78eb174ea2 readline: use StringDecoder for decoding "normal" data
The fix from #3059 was not handling multi-byte utf8 data properly.
2012-04-06 16:13:40 -07:00
Nathan Friedly e28f77cbad readline: buffer data to only emit 'line' on '\n'
In "terminal: false" mode.

(And fire it multiple times if multiple lines arrive at once.)

This is necessary because the Windows telnet client sends every single
keystroke as it's typed.

See: http://stackoverflow.com/questions/9962197/node-js-readline-not-waiting-for-a-full-line-on-socket-connections

Closes #3059.
2012-04-06 16:13:40 -07:00
Ben Noordhuis b031671138 tty, readline: fix style errors 2012-03-29 01:36:46 +02:00
Nathan Rajlich f41901cdf6 repl: make ^D emit an 'end' event on the readline instance
Also emit 'exit' on the repl when 'end' is emitted on the readline.

Fixes `node debug test/fixtures/breakpoints.js` when ^D is pressed.
2012-03-27 13:54:49 -07:00
Nathan Rajlich aad12d0b26 readline: migrate ansi/vt100 logic from tty to readline
The overall goal here is to make readline more interoperable with other node
Streams like say a net.Socket instance, in "terminal" mode.

See #2922 for all the details.
Closes #2922.
2012-03-26 15:21:25 -07:00
Alex Kocharin ab518ae50e readline: fix for terminals that insert newlines automatically
Fixes #2985.
2012-03-26 09:21:55 -07:00
isaacs 81cd3a3cd6 lint readline.js - single-quotes preferred 2012-03-20 19:42:34 -07:00
Alex Kocharin 06a058d731 readline: row-agnostic multiline readline implementation
Fixes #2959.
2012-03-20 15:37:06 -07:00
Nathan Rajlich 8517089b3e Revert "readline: add multiline support"
This reverts commit 443071db57.

Patch was overly compilicated and made some incorrect assumptions about the
position of the cursor being at the bottom of the screen. @rlidwka and I are
working on getting a proper implementation written.
2012-03-20 15:37:06 -07:00