getch/functions.php

30 lines
672 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
/*
2024-07-18 12:44:34 -07:00
* Copyright (c) 2020-2024 https://sikofitt.com sikofitt@gmail.com
2020-12-22 14:19:32 -08:00
*
* 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/.
*/
2022-05-17 10:29:20 -07:00
use Olive\Console\Getch;
2020-12-22 14:19:32 -08:00
if (!function_exists('getch')) {
2024-07-18 12:34:40 -07:00
function getch(?string $linuxLibrary = null): int
2020-12-22 14:19:32 -08:00
{
2024-07-18 12:34:40 -07:00
return (new Getch($linuxLibrary))->getch();
2020-12-22 14:19:32 -08:00
}
}
2021-01-07 13:58:46 -08:00
2021-01-25 12:35:32 -08:00
if (!function_exists('ungetch')) {
2024-07-18 12:34:40 -07:00
function ungetch($char, ?string $linuxLibrary = null): int
2021-01-07 13:58:46 -08:00
{
2024-07-18 12:34:40 -07:00
return (new Getch($linuxLibrary))->ungetch($char);
2021-01-07 13:58:46 -08:00
}
}