8000 Merge pull request #80 from clue-labs/mac · PaulRotmann/reactphp-stdio@52bb083 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52bb083

Browse files
authored
Merge pull request clue#80 from clue-labs/mac
Revert "Don't use ext-readline handler on Mac to fix CR/LF issues on Mac only
2 parents 011c0c7 + 91cb6d3 commit 52bb083

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,11 @@ If this extension is missing, then this library will use a slighty slower Regex
607607
work-around that should otherwise work equally well.
608608
Installing `ext-mbstring` is highly recommended.
609609

610-
Internally, it will use the `ext-readline` to enable raw terminal input mode (on
611-
Linux only as it is known to cause issues on Macs). Otherwise, this library will
612-
manually set the required TTY settings on start and will try to restore previous
613-
settings on exit. Input line editing is handled entirely within this library and
614-
does not rely on `ext-readline`.
610+
Internally, it will use the `ext-readline` to enable raw terminal input mode.
611+
If this extension is missing, then this library will manually set the required
612+
TTY settings on start and will try to restore previous settings on exit.
613+
Input line editing is handled entirely within this library and does not rely on
614+
`ext-readline`.
615615
Installing `ext-readline` is entirely optional.
616616

617617
Note that *Microsoft Windows is not supported*.

src/Stdio.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class Stdio extends EventEmitter implements DuplexStreamInterface
2121
private $closed = false;
2222
private $incompleteLine = '';
2323
private $originalTtyMode = null;
24-
private $usesExtReadlineHandler = false;
2524

2625
public function __construct(LoopInterface $loop, ReadableStreamInterface $input = null, WritableStreamInterface $output = null, Readline $readline = null)
2726
{
@@ -245,9 +244,8 @@ public function handleCloseOutput()
245244
*/
246245
private function restoreTtyMode()
247246
{
248-
if ($this->usesExtReadlineHandler) {
247+
if (function_exists('readline_callback_handler_remove')) {
249248
// remove dummy readline handler to turn to default input mode
250-
$this->usesExtReadlineHandler = false;
251249
readline_callback_handler_remove();
252250
} elseif ($this->originalTtyMode !== null && is_resource(STDIN) && $this->isTty()) {
253251
// Reset stty so it behaves normally again
@@ -279,14 +277,11 @@ private function createStdin(LoopInterface $loop)
279277

280278
$stream = new ReadableResourceStream(STDIN, $loop);
281279

282-
if (PHP_OS === 'Linux' && function_exists('readline_callback_handler_install')) {
280+
if (function_exists('readline_callback_handler_install')) {
283281
// Prefer `ext-readline` to install dummy handler to turn on raw input mode.
284-
// This is known to work on Linux and known to cause issues with CR/LF
285-
// on Mac, so we only use this on Linux for now, see also issue #66.
286-
// We will nevery actually feed the readline handler and instead
282+
// We will never actually feed the readline handler and instead
287283
// handle all input in our `Readline` implementation.
288284
readline_callback_handler_install('', function () { });
289-
$this->usesExtReadlineHandler = true;
290285
return $stream;
291286
}
292287

0 commit comments

Comments
 (0)
0