@@ -6,8 +6,8 @@ Cursor Helper
6
6
7
7
.. versionadded :: 5.1
8
8
9
- The :class: `Symfony\\ Component\\ Console\\ Cursor `
10
- class was introduced in Symfony 5.1.
9
+ The :class: `Symfony\\ Component\\ Console\\ Cursor ` class was introduced
10
+ in Symfony 5.1.
11
11
12
12
The :class: `Symfony\\ Component\\ Console\\ Cursor ` allows you to change the
13
13
cursor position in a console command. This allows you to write on any position
@@ -16,10 +16,11 @@ of the output:
16
16
.. image :: /_images/components/console/cursor.gif
17
17
:align: center
18
18
19
-
20
19
.. code-block :: php
21
20
22
- // src/Commande/MyCommand.php
21
+ // src/Command/MyCommand.php
22
+ namespace App\Command;
23
+
23
24
use Symfony\Component\Console\Command\Command;
24
25
use Symfony\Component\Console\Cursor;
25
26
use Symfony\Component\Console\Input\InputInterface;
@@ -29,13 +30,14 @@ of the output:
29
30
{
30
31
// ...
31
32
32
- public function execute(InputInterface $input, OutputInterface $output)
33
+ public function execute(InputInterface $input, OutputInterface $output): int
33
34
{
34
35
// ...
35
36
36
37
$cursor = new Cursor($output);
37
38
38
- // moves the cursor to a specific column and row position
39
+ // moves the cursor to a specific column (1st argument) and
40
+ // row (2nd argument) position
39
41
$cursor->moveToPosition(7, 11);
40
42
41
43
// and write text on this position using the output
@@ -71,7 +73,8 @@ There are fews methods to control moving the command cursor::
71
73
// same for left
72
74
$cursor->moveLeft();
73
75
74
- // move the cursor to a specific position from its current position
76
+ // move the cursor to a specific (column, row) position from the
77
+ // top-left position of the terminal
75
78
$cursor->moveToPosition(7, 11);
76
79
77
80
You can get the current command's cursor position by using::
0 commit comments