* * * 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:----2CAY475GSdD9MPJYtkqQ8Sth3hrcXl8M9OQVr1aRvcAUBnwnpZsNKL52H1SL1x7chKILhZ1OR5dbGfex5LOwCYHliP/rgYQ1Bu9XneDHRwjRPr4kvy88ZbAI6/8+SVLchftlWBB2Rhh52GOdScxSGSGAQWcrTIrbqFJmABZZGKaNtzC1A1XryDNrX3aqiTstF98MQtzQ+kweRZWZnFWOZ7aaRhDB76YcmkTw7eaoPWX+2kPgerKORWPa/GZO+faIvGLp2u2Y8qhwKnZo4IU1fvTwK+wQY74I7+6Zxv5U3lmojUTyiaFQZQ2WV+Yf+iCLfBBT6gy+nhtd7OGlJjCkX3lihS4BsBI1mIhKxt+HZjjqX+1P2OlIIjCzReTinm7TEzKPlM4CX5xfH23u8ayMbtGUTdAvD9nn73oEbXrhEpxPCtuPwPBprbg4LY+sWca/hP5w7NmmdECtP6TfnhcDDo0xgnMXL6YULTiyFla6Zg45eY+zshWlmgCX8U3CS7mKSUEm5hKcKaRiJrkQGEYzXVEWPsyfcWo0NOGtEI9h70VrRGtTOrpjdXcqeUwM4iTIiy36HkP7BHglPfYD2oD2iZAswJZtnCZMVvLoAZRw08DJ1n7qzqBD+j/J2yvMmHo1+n6YP9ro72oT75MJktewjtmnSxUelQf+pTxKwEEkCoc=----ATTACHMENT:----NDMxODY0MzYxNDYxMzUgOTcyNDYyMjY4NjAwOTc1NSA1MDk4NTc0NzQ2ODU3ODE=