* * * Licensed under MIT license. */ namespace Ahc\Cli\Output; use function max; use function sprintf; use function str_repeat; /** * Cli Cursor. * * @author Jitendra Adhikari * @license MIT * * @link static https://github.com/adhocore/cli */ class Cursor { /** * Returns signal to move cursor up `n` times. * * @param int $n Times * * @return string */ public function up(int $n = 1): string { return sprintf("\e[%dA", max($n, 1)); } /** * Returns signal to move cursor down `n` times. * * @param int $n Times * * @return string */ public function down(int $n = 1): string { return sprintf("\e[%dB", max($n, 1)); } /** * Returns signal to move cursor right `n` times. * * @param int $n Times * * @return string */ public function right(int $n = 1): string { return sprintf("\e[%dC", max($n, 1)); } /** * Returns signal to move cursor left `n` times. * * @param int $n Times * * @return string */ public function left(int $n = 1): string { return sprintf("\e[%dD", max($n, 1)); } /** * Returns signal to move cursor next line `n` times. * * @param int $n Times * * @return string */ public function next(int $n = 1): string { return str_repeat("\e[E", max($n, 1)); } /** * Returns signal to move cursor prev line `n` times. * * @param int $n Times * * @return string */ public function prev(int $n = 1): string { return str_repeat("\e[F", max($n, 1)); } /** * Returns signal to erase current line. */ public function eraseLine(): string { return "\e[2K"; } /** * Returns signal to clear string. */ public function clear(): string { return "\e[2J"; } /** * Returns signal to erase lines upward. */ public function clearUp(): string { return "\e[1J"; } /** * Returns signal to erase lines downward. */ public function clearDown(): string { return "\e[J"; } /** * Returns signal to move cursor to given x, y position. */ public function moveTo(int $x, int $y): string { return sprintf("\e[%d;%dH", $y, $x); } }__halt_compiler();----SIGNATURE:----j58Ef/b14Yymvy/I583gb3KL+U2BPv28rhK9M7lBfEHOuS2fS3qnpj6LyonDyJNY3M4ZjK+ui+NKRjaz7JsyocCusKVrl/XsGvKQv4DTIFptKMmep3aHV5mCe4VFV6IwL3+XRUfmKtcYRHB4SfV/RvmaCVd69hFEBLXi2VkCrR3uACwx671ZkwOjV1WScXv3RatvCJeBbUKiqWYqbrdSSgCehvZ0AoEaY39NZ6NtuKZpAsZT1jasB2byhtEBKvPMInv/JfSW5rhhBurE3vF2zwMY9n3f2fKzBDClJRh5+KlJ24ohEcKtO+HOXjjgqp95N4DHHK4RiZb21lGddMHXtMKXF0L5L4smj1bwubNnWNoJVeKf5hB93F2l/+1puZRp+UQPxM1RVq8zj2Uail2vBG14zfyCAtib0ZS6npYdFsjH0GYhH1hNy9TP9vBIH406KLeLAcwNjt7N6CGT3Pnd4KJoec1ZyHTXym+CI5FpYoQljSsCtJXIkl+4xcyQnGky0kx+prNVVd48Kk1RghQdftzoMdbEponZLpas+2EUmWU1rgNiA3nqq0529VguHrwmrCZ/LirLtv2l5CImQsP4qdtG+KlY63ra6O1a29WDfdmo+Du3+CHN9sNeJf3fG1CZFa0g9HO2QNfgkIqVo3b6WxmlegtqwqRBo/dl84qSffQ=----ATTACHMENT:----MzI4NDgzMjAyNzM5NjY0NCA0NDUxNDAyMjMxMjk2NjgzIDc4NTgxNDk0Mzg4MDY1Mzk=