1 | <?php |
||
16 | class ANSI implements CursorInterface |
||
17 | { |
||
18 | const ESCAPE = "\e"; |
||
19 | |||
20 | const CODE_MOVE_POSITION = '[%d;%dH'; // line, column |
||
21 | const CODE_MOVE_UP_LINES = '[%dA'; // lines |
||
22 | const CODE_MOVE_DOWN_LINES = '[%dB'; // lines |
||
23 | const CODE_MOVE_FORWARD = '[%dC'; // columns |
||
24 | const CODE_MOVE_BACKWARDS = '[%dD'; // columns |
||
25 | |||
26 | const CODE_ERASE_TO_END_OF_LINE = '[K'; |
||
27 | const CODE_ERASE_TO_START_OF_LINE = '[1K'; |
||
28 | const CODE_ERASE_LINE = '[2K'; |
||
29 | const CODE_ERASE_DOWN = '[J'; |
||
30 | const CODE_ERASE_UP = '[1J'; |
||
31 | const CODE_ERASE_SCREEN = '[2J'; |
||
32 | |||
33 | /** @var array */ |
||
34 | protected $filter = []; |
||
35 | |||
36 | /** |
||
37 | * @param int $line |
||
38 | * @param int $column |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | public function move($line, $column) |
||
46 | |||
47 | /** |
||
48 | * @param int $lines |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | public function moveUp($lines) |
||
56 | |||
57 | /** |
||
58 | * @param int $lines |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function moveDown($lines) |
||
66 | |||
67 | /** |
||
68 | * @param int $columns |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | public function moveLeft($columns) |
||
76 | |||
77 | /** |
||
78 | * @param int $columns |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | public function moveRight($columns) |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function eraseToEnd() |
||
94 | |||
95 | /** |
||
96 | * @return string |
||
97 | */ |
||
98 | public function eraseToStart() |
||
102 | |||
103 | /** |
||
104 | * @return string |
||
105 | */ |
||
106 | public function eraseDown() |
||
110 | |||
111 | /** |
||
112 | * @return string |
||
113 | */ |
||
114 | public function eraseUp() |
||
118 | |||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | public function eraseScreen() |
||
126 | |||
127 | /** |
||
128 | * Filter takes a string with Cursor movements and filters them out |
||
129 | * |
||
130 | * @param string $string |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function filter($string) |
||
159 | } |
||
160 |