Merge 1.x into master #1
11
README.md
11
README.md
|
@ -2,15 +2,16 @@
|
|||
|
||||
This simply uses the FFI extension to enable _getch and _ungetch in Windows and linux.
|
||||
|
||||
[![pipeline status](https://repos.bgemi.net/sikofitt/getch/badges/1.x/pipeline.svg)](https://repos.bgemi.net/sikofitt/getch/-/commits/1.x)
|
||||
[![coverage report](https://repos.bgemi.net/sikofitt/getch/badges/1.x/coverage.svg)](https://repos.bgemi.net/sikofitt/getch/-/commits/1.x)
|
||||
[![Pipeline status](https://code.bgemi.net/olive/PHP/getch/badges/1.x/pipeline.svg)](https://code.bgemi.net/olive/PHP/getch/-/commits/1.x)
|
||||
[![Coverage report](https://code.bgemi.net/olive/PHP/getch/badges/1.x/coverage.svg)](https://code.bgemi.net/olive/PHP/getch/-/commits/1.x)
|
||||
[![Latest Release](https://code.bgemi.net/olive/PHP/getch/-/badges/release.svg)](https://code.bgemi.net/olive/PHP/getch/-/releases)
|
||||
|
||||
```shell script
|
||||
$ composer require sikofitt/getch:dev-master
|
||||
$ composer require olivebbs/getch
|
||||
```
|
||||
|
||||
```php
|
||||
use Sikofitt\Console\Getch;
|
||||
use Olive\Console\Getch;
|
||||
$g = new Getch($linuxLibrary = null); // can also be a library that implements a function called _getch;
|
||||
// by default uses the bundled Resources/libgetch.so
|
||||
// on windows uses the built in _getch function.
|
||||
|
@ -45,7 +46,7 @@ Note that if you want to put a word into the STDIN stack, you need to do it in r
|
|||
There are also helper functions called getch() and ungetch();
|
||||
|
||||
```php
|
||||
use function Sikofitt\Console\getch;
|
||||
use function Olive\Console\getch;
|
||||
$ord = getch($linuxLibrary = null);
|
||||
print \chr($ord);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "sikofitt/getch",
|
||||
"name": "olivebbs/getch",
|
||||
"description": "Implements _getch and _ungetch for windows and linux using ffi",
|
||||
"type": "library",
|
||||
"require": {
|
||||
|
@ -8,12 +8,11 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.18",
|
||||
"jetbrains/phpstorm-stubs": "dev-master",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Sikofitt\\Console\\": "src/Console/"
|
||||
"Olive\\Console\\": "src/Console/"
|
||||
},
|
||||
"files": [
|
||||
"functions.php"
|
||||
|
@ -21,7 +20,7 @@
|
|||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Sikofitt\\Tests\\Console\\": "tests/"
|
||||
"Olive\\Tests\\Console\\": "tests/"
|
||||
}
|
||||
},
|
||||
"license": "MPL-2.0",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
use Sikofitt\Console\Getch;
|
||||
use Olive\Console\Getch;
|
||||
|
||||
if (!function_exists('getch')) {
|
||||
function getch(string $linuxLibrary = null): int
|
||||
|
|
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
namespace Sikofitt\Console;
|
||||
namespace Olive\Console;
|
||||
|
||||
use FFI;
|
||||
use RuntimeException;
|
||||
|
@ -92,10 +92,13 @@ final class Getch
|
|||
if ($ffi->_kbhit()) {
|
||||
$result = $ffi->_getch();
|
||||
$ffi->_ungetch($result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return $ffi->cinPeek();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Sikofitt\Tests\Console\Getch;
|
||||
namespace Olive\Tests\Console\Getch;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Sikofitt\Console\Getch;
|
||||
use Olive\Console\Getch;
|
||||
|
||||
class GetchTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Sikofitt\Tests\Console\Ungetch;
|
||||
namespace Olive\Tests\Console\Ungetch;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Sikofitt\Console\Getch;
|
||||
use Olive\Console\Getch;
|
||||
|
||||
class UngetchTest extends TestCase
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue