Skip to content

Commit

Permalink
1. add cursor toggle to aec
Browse files Browse the repository at this point in the history
  • Loading branch information
scarwu committed Dec 12, 2018
1 parent 290bbe7 commit f693ad5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Oni/CLI/Helper/ANSIEscapeCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,22 @@ public static function color($text, $fgColor = null, $bgColor = null)

return "{$start}{$text}{$end}";
}

/**
* Cursor Show
*
* @return string
*/
public static function cursorShow() {
return self::CSI . '?25h';
}

/**
* Cursor Hide
*
* @return string
*/
public static function cursorHide() {
return self::CSI . '?25l';
}
}
5 changes: 4 additions & 1 deletion src/Oni/CLI/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ public function menuSelect($options) {

readline_callback_handler_install('', function() {});

$this->write(AEC::cursorHide());

do {
switch (ord($char)) {
case 10: // Enter Key
Expand Down Expand Up @@ -337,7 +339,8 @@ public function menuSelect($options) {
$this->write(AEC::moveTo(0, $wHeight - $bHeight));
} while ($char = stream_get_contents(STDIN, 1));

$this->writeln(AEC::moveTo(0, $wHeight));
$this->write(AEC::moveTo(0, $wHeight));
$this->writeln(AEC::cursorShow());

readline_callback_handler_remove();

Expand Down

0 comments on commit f693ad5

Please sign in to comment.