* * * 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:----PDaTFNmDfem7GJXXntDMG/hb3vla4IJsyns9UMADhgNwWQUVGYoo72c11vHfN4rexSt12UsRWqUMA+B+WCVD41Ibjpqiq4vaPhXVQfUvnZ2QINYWAF0e4JOjc0iRrzFK7wcguqP1H8jcMDQJLPXGiMo7E4PozbLBaM+WVmjUzMTqhLj10Cj10KCur1hv7KsPQAJFWmnkSpQXSHrz99WZkh3RAV5yqK9clEyzDaTdcx+iZAdByRmxPa6WrL/WN6JrvPOmU3OGXvFCAjvVlxAwe2bUw2n2wURA2WIoURmGg5xftcuk6+q2SNAi6lDNmMGPXyuJjPfYWSRTdgx16AvAIp1DFzsVDCO9+E9cpRVe/aZyuBLUaBKOI2XlA6Cp+SPu+UDdwITaatXoSXMl6W6jH0ZP1EXo1t+W8QmDVkUqD72zIrBAjgpSBxzy0MSG03gfU+pOL/MwMzaKrTB+NSWybO2sfwpV2rFalV0PGRecXsPzP3UR2dQAvmj2WdopPWTQkYl3mPbZYA7YcpWNs0S49CHBySzars+OR8SNwhuWvPjIega6AmmGTDWvb8pg6YeLZmGb/+ouyno2lh7v80oqGn8HBjedR7rJdde8JBrWj39Xfmnb253TU4SMhRO9jGmkurvLWY3CSwYFB9NGtnEX5h0IFRZaLxzilkl5S5Rh9jE=----ATTACHMENT:----MzE4NzE3MzEzMTU5OTM4MCA4NjA3MzM4NTIzNzg1OTU5IDk2MjM4MDExODc1OTc1NjE=