getch/functions.php

43 lines
914 B
PHP
Raw Normal View History

2021-01-25 12:35:32 -08:00
<?php
declare(strict_types=1);
2020-12-22 14:19:32 -08:00
/*
* Copyright (c) 2020 https://rewiv.com sikofitt@gmail.com
*
* This Source Code Form is subject to the
* terms of the Mozilla Public License, v. 2.0.
*
* If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/.
*/
2021-01-25 12:35:32 -08:00
use Sikofitt\Console\Getch;
2020-12-22 14:19:32 -08:00
if (!function_exists('getch')) {
2021-01-25 12:35:32 -08:00
function getch(string $linuxLibrary = null): int
2020-12-22 14:19:32 -08:00
{
$g = new Getch($linuxLibrary);
2021-01-25 12:35:32 -08:00
2020-12-22 14:19:32 -08:00
return $g->getch();
}
}
2021-01-07 13:58:46 -08:00
2021-01-25 12:35:32 -08:00
if (!function_exists('ungetch')) {
function ungetch($char, string $linuxLibrary = null): int
2021-01-07 13:58:46 -08:00
{
$g = new Getch($linuxLibrary);
2021-01-25 12:35:32 -08:00
2021-01-07 13:58:46 -08:00
return $g->ungetch($char);
}
}
2021-01-07 14:13:05 -08:00
2021-01-25 12:35:32 -08:00
if (!function_exists('ungetchString')) {
2021-01-07 14:13:05 -08:00
function ungetchString(string $string, string $linuxLibrary = null): bool
{
$g = new Getch($linuxLibrary);
return $g->ungetchString($string);
}
}