Skip to content

Commit

Permalink
Add input resource stream to Cursor class
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Dec 10, 2019
1 parent 6ff2395 commit 2015276
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Symfony/Component/Console/Cursor.php
Expand Up @@ -20,9 +20,12 @@ class Cursor
{
private $output;

public function __construct(OutputInterface $output)
private $input;

public function __construct(OutputInterface $output, $input = STDIN)
{
$this->output = $output;
$this->input = $input;
}

public function moveUp(int $lines = 1)
Expand Down Expand Up @@ -121,9 +124,9 @@ public function getCurrentPosition(): array
$sttyMode = shell_exec('stty -g');
shell_exec('stty -icanon -echo');

fwrite(STDIN, "\033[6n");
fwrite($this->input, "\033[6n");

$code = trim(fread(STDIN, 1024));
$code = trim(fread($this->input, 1024));

shell_exec(sprintf('stty %s', $sttyMode));

Expand Down

0 comments on commit 2015276

Please sign in to comment.