Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ It wraps a given `ReadableStreamInterface` and exposes its plain data through
the same interface.

```php
<?php

require __DIR__ . '/vendor/autoload.php';

$stdin = new React\Stream\ReadableResourceStream(STDIN);

$stream = new ControlCodeParser($stdin);
$stream = new Clue\React\Term\ControlCodeParser($stdin);

$stream->on('data', function ($chunk) {
var_dump($chunk);
Expand Down
10 changes: 3 additions & 7 deletions examples/random-colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
// with random colors:
// $ phpunit --color=always | php random-colors.php

use Clue\React\Term\ControlCodeParser;
use React\Stream\ReadableResourceStream;
use React\Stream\WritableResourceStream;

require __DIR__ . '/../vendor/autoload.php';

if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
Expand All @@ -23,10 +19,10 @@
}

// process control codes from STDIN
$stdin = new ReadableResourceStream(STDIN);
$parser = new ControlCodeParser($stdin);
$stdin = new React\Stream\ReadableResourceStream(STDIN);
$parser = new Clue\React\Term\ControlCodeParser($stdin);

$stdout = new WritableResourceStream(STDOUT);
$stdout = new React\Stream\WritableResourceStream(STDOUT);

// pass all c0 codes through to output
$parser->on('c0', array($stdout, 'write'));
Expand Down
10 changes: 3 additions & 7 deletions examples/remove-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
// codes like this:
// $ phpunit --color=always | php remove-codes.php

use Clue\React\Term\ControlCodeParser;
use React\Stream\ReadableResourceStream;
use React\Stream\WritableResourceStream;

require __DIR__ . '/../vendor/autoload.php';

if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
Expand All @@ -20,11 +16,11 @@
}

// process control codes from STDIN
$stdin = new ReadableResourceStream(STDIN);
$parser = new ControlCodeParser($stdin);
$stdin = new React\Stream\ReadableResourceStream(STDIN);
$parser = new Clue\React\Term\ControlCodeParser($stdin);

// pipe data from STDIN to STDOUT without any codes
$stdout = new WritableResourceStream(STDOUT);
$stdout = new React\Stream\WritableResourceStream(STDOUT);
$parser->pipe($stdout);

// only forward \r, \n and \t
Expand Down
7 changes: 2 additions & 5 deletions examples/stdin-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
// codes like this:
// $ phpunit --color=always | php stdin-codes.php

use Clue\React\Term\ControlCodeParser;
use React\Stream\ReadableResourceStream;

require __DIR__ . '/../vendor/autoload.php';

if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
Expand All @@ -20,8 +17,8 @@
}

// process control codes from STDIN
$stdin = new ReadableResourceStream(STDIN);
$parser = new ControlCodeParser($stdin);
$stdin = new React\Stream\ReadableResourceStream(STDIN);
$parser = new Clue\React\Term\ControlCodeParser($stdin);

$decoder = function ($code) {
echo 'Code:';
Expand Down