Skip to content

Commit 79d760c

Browse files
committed
Add AnsiEscapeSequences class to help with some often used sequences
1 parent 14e6f4c commit 79d760c

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/AnsiEscapeSequences.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CodeLts\CliTools;
6+
7+
/**
8+
* ANSI escape sequences
9+
* @see https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
10+
* @see http://ascii-table.com/ansi-escape-sequences.php
11+
*/
12+
class AnsiEscapeSequences
13+
{
14+
/**
15+
* Move the cursor up 1 lines
16+
*/
17+
public const MOVE_CURSOR_UP_1 = "\033[1A";
18+
19+
/**
20+
* Move the cursor up 2 lines
21+
*/
22+
public const MOVE_CURSOR_UP_2 = "\033[2A";
23+
24+
/**
25+
* Move the cursor down 1 lines
26+
*/
27+
public const MOVE_CURSOR_DOWN_1 = "\033[1B";
28+
29+
/**
30+
* Move the cursor down 2 lines
31+
*/
32+
public const MOVE_CURSOR_DOWN_2 = "\033[2B";
33+
34+
/**
35+
* Erase to the end of the line on 2 lines
36+
*/
37+
public const ERASE_TO_LINE_END_1 = "\033[2A";
38+
39+
/**
40+
* Erase to the end of the line on 2 lines
41+
*/
42+
public const ERASE_TO_LINE_END_2 = "\033[2A";
43+
44+
/**
45+
* Clear the screen, move to (0,0)
46+
*/
47+
public const CLEAR_SCREEN_MOVE_0_0 = "\033[2J";
48+
}

0 commit comments

Comments
 (0)