File tree 6 files changed +42
-1
lines changed
_images/components/console
components/console/helpers
6 files changed +42
-1
lines changed Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Console Helpers; Cursor Helper
3
+
4
+ Cursor Helper
5
+ =============
6
+
7
+ .. versionadded :: 5.1
8
+
9
+ The :class: `Symfony\\ Component\\ Console\\ Cursor `
10
+ class was introduced in Symfony 5.1.
11
+
12
+ The :class: `Symfony\\ Component\\ Console\\ Cursor ` allows you to manipulate
13
+ the cursor in a console command like this:
14
+
15
+ .. image :: /_images/components/console/cursor.gif
16
+ :align: center
17
+
18
+ Using the cursor
19
+ ----------------
20
+
21
+ The cursor defines several functions and can be used as follow::
22
+
23
+ use Symfony\Component\Console\Cursor;
24
+ use Symfony\Component\Console\Output\OutputInterface;
25
+
26
+ // creates a new cursor
27
+ $cursor = new Cursor($output);
28
+
29
+ // moves the cursor to column and row
30
+ $cursor->moveToPosition(7, 11);
31
+
32
+ // moves the cursor to the right
33
+ $cursor->moveRight();
34
+
35
+ // clear the current cursor line
36
+ $cursor->clearLine();
37
+
38
+ // [...] read the class to see all the features
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ The Console Helpers
13
13
questionhelper
14
14
table
15
15
debug_formatter
16
+ cursor
16
17
17
18
The Console component comes with some useful helpers. These helpers contain
18
19
functions to ease some common tasks.
Original file line number Diff line number Diff line change 4
4
* :doc:` /components/console/helpers/questionhelper`
5
5
* :doc:` /components/console/helpers/table`
6
6
* :doc:` /components/console/helpers/debug_formatter`
7
+ * :doc:` /components/console/helpers/cursor`
Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ placeholder before displaying the progress bar::
349
349
// 0/100 -- Start
350
350
351
351
$progressBar->setMessage('Task is in progress...');
352
- $progressBar->advance();
352
+ $progressBar->advance();
353
353
// 1/100 -- Task is in progress...
354
354
355
355
Messages can be combined with custom placeholders too. In this example, the
Original file line number Diff line number Diff line change @@ -454,5 +454,6 @@ tools capable of helping you with different tasks:
454
454
* :doc: `/components/console/helpers/table `: displays tabular data as a table
455
455
* :doc: `/components/console/helpers/debug_formatter `: provides functions to
456
456
output debug information when running an external program
457
+ * :doc: `/components/console/helpers/cursor `: allows to manipulate the cursor in the terminal
457
458
458
459
.. _`exit status` : https://en.wikipedia.org/wiki/Exit_status
You can’t perform that action at this time.
0 commit comments