Skip to content

Commit 3721d6b

Browse files
Document console cursor
1 parent 6884947 commit 3721d6b

File tree

6 files changed

+42
-1
lines changed

6 files changed

+42
-1
lines changed

_images/components/console/cursor.gif

63.4 KB
Loading

components/console/helpers/cursor.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

components/console/helpers/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The Console Helpers
1313
questionhelper
1414
table
1515
debug_formatter
16+
cursor
1617

1718
The Console component comes with some useful helpers. These helpers contain
1819
functions to ease some common tasks.

components/console/helpers/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
* :doc:`/components/console/helpers/questionhelper`
55
* :doc:`/components/console/helpers/table`
66
* :doc:`/components/console/helpers/debug_formatter`
7+
* :doc:`/components/console/helpers/cursor`

components/console/helpers/progressbar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ placeholder before displaying the progress bar::
349349
// 0/100 -- Start
350350

351351
$progressBar->setMessage('Task is in progress...');
352-
$progressBar->advance();
352+
$progressBar->advance();
353353
// 1/100 -- Task is in progress...
354354

355355
Messages can be combined with custom placeholders too. In this example, the

console.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,5 +454,6 @@ tools capable of helping you with different tasks:
454454
* :doc:`/components/console/helpers/table`: displays tabular data as a table
455455
* :doc:`/components/console/helpers/debug_formatter`: provides functions to
456456
output debug information when running an external program
457+
* :doc:`/components/console/helpers/cursor`: allows to manipulate the cursor in the terminal
457458

458459
.. _`exit status`: https://en.wikipedia.org/wiki/Exit_status

0 commit comments

Comments
 (0)