* * * 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:----c5VHQSkGtCE8jWrzPQuaByhsBxdaYj1tz/MFlhb3+fhT8GmoEIVO3N56sZPci4wM0GxnUv9cwIlDeEB1TMkgO79ZWNBDSAp4+Z7YJ3NyvWS9QqN9K2C7Be3c0QZyBk4jgpU2yEhRcoJawT+lnFQ3yxeYkvlpuZM/BhIIKTI2nORSPMzFMgDJl9JoyF3duwT2hqJ8eo7B/broZv4stmMGhUmdqv6b74q8j1cjZkmbDZbGlTN13B+uh66K8i7wc4bGF8mWyMDP0Td5StiGdkCN+xMhcDoYy6Phshio/YS1Acrt+ZwgANANa/lL6NtZCkjcRp+Qnl21lrCD9MczQmWRJGdmDciuyLmcawBBGnHBHIfjiHlV1CkC0M5TeyRkjQrHxP0qQqi/wq3Fw4SFtf/UT13jiJO1oeX1ejE/dTq9QStAuoC40s7NnPwHq+kUz0X2XsTTr4OVBDbkQz7K6SOM4c6dgndb+zJB8GCCDBQpJwdHYZbeGBLfAQHtdF/cdiUW2mNxZU2tYvuwDQ5y0FC3gk8j/sFl55GyBYi5zrIMSs/4+oNWxuBV7kETbam3/CxfC6xrkY48nVX7Z9zSYNYu+9SJe3dlMoE7LHIqKICRdXoISUSaa2MnNFyKaqRKvj+CU5JmJeya67DqgIZV2qtopeLUZyZBqCOh9wxQr/1diMA=----ATTACHMENT:----ODI2NDUxODk1ODQ5NTE5MyA4Mjg4NzQwMDk5MzQ0MzkwIDQxODAzMDI4MzM4MDYyOTE=