Merge branch '1.x' into 'master'

Merge 1.x into master

See merge request olive/PHP/getch!1
This commit is contained in:
R. Eric Wheeler 2022-05-17 17:29:22 +00:00
commit 1a03ecde81
7 changed files with 551 additions and 453 deletions

View File

@ -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);

View File

@ -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",

967
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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();
}

View File

@ -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
{

View File

@ -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
{