Skip to content

Commit

Permalink
Add AnsiEscapeSequences class to help with some often used sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Nov 27, 2020
1 parent 14e6f4c commit 79d760c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/AnsiEscapeSequences.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace CodeLts\CliTools;

/**
* ANSI escape sequences
* @see https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
* @see http://ascii-table.com/ansi-escape-sequences.php
*/
class AnsiEscapeSequences
{
/**
* Move the cursor up 1 lines
*/
public const MOVE_CURSOR_UP_1 = "\033[1A";

/**
* Move the cursor up 2 lines
*/
public const MOVE_CURSOR_UP_2 = "\033[2A";

/**
* Move the cursor down 1 lines
*/
public const MOVE_CURSOR_DOWN_1 = "\033[1B";

/**
* Move the cursor down 2 lines
*/
public const MOVE_CURSOR_DOWN_2 = "\033[2B";

/**
* Erase to the end of the line on 2 lines
*/
public const ERASE_TO_LINE_END_1 = "\033[2A";

/**
* Erase to the end of the line on 2 lines
*/
public const ERASE_TO_LINE_END_2 = "\033[2A";

/**
* Clear the screen, move to (0,0)
*/
public const CLEAR_SCREEN_MOVE_0_0 = "\033[2J";
}

0 comments on commit 79d760c

Please sign in to comment.