Skip to content

Commit 975dd78

Browse files
committed
Update documentation WRT UTF-8 and multi-byte / multi-cell characters
1 parent db4af71 commit 975dd78

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# clue/stdio-react [![Build Status](https://travis-ci.org/clue/php-stdio-react.svg?branch=master)](https://travis-ci.org/clue/php-stdio-react)
22

3-
Async standard console input & output (STDIN, STDOUT) for React PHP
3+
Async, event-driven and UTF-8 aware standard console input & output (STDIN, STDOUT) for React PHP
44

55
> Note: This project is in early beta stage! Feel free to report any issues you encounter.
66
@@ -181,14 +181,28 @@ simply pass a boolean `true` like this:
181181
$readline->setMove(true);
182182
```
183183

184-
The `getCursorPosition()` method can be used to access the current cursor position.
184+
The `getCursorPosition()` method can be used to access the current cursor position,
185+
measured in number of characters.
185186
This can be useful if you want to get a substring of the current *user input buffer*.
186187
Simply invoke it like this:
187188

188189
```php
189190
$position = $readline->getCursorPosition();
190191
```
191192

193+
The `getCursorCell()` method can be used to get the current cursor position,
194+
measured in number of monospace cells.
195+
Most *normal* characters (plain ASCII and most multi-byte UTF-8 sequences) take a single monospace cell.
196+
However, there are a number of characters that have no visual representation
197+
(and do not take a cell at all) or characters that do not fit within a single
198+
cell (like some asian glyphs).
199+
This method is mostly useful for calculating the visual cursor position on screen,
200+
but you may also invoke it like this:
201+
202+
```php
203+
$cell = $readline->getCursorCell();
204+
```
205+
192206
The `moveCursorTo($position)` method can be used to set the current cursor position to the given absolute character position.
193207
For example, to move the cursor to the beginning of the *user input buffer*, simply call:
194208

0 commit comments

Comments
 (0)