php-kilo/kilo
Timothy Warren 85e96264a8
Some checks failed
timw4mail/php-kilo/pipeline/head There was a failure building this commit
Get syntax highlighting and keyboard natvigation working again...buggy editing functionality
2021-03-17 13:14:16 -04:00

46 lines
963 B
PHP
Executable File

#!/usr/bin/env php
<?php declare(strict_types=1);
namespace Aviat\Kilo;
require_once __DIR__ . '/vendor/autoload.php';
// Log notices/errors/warnings to file
set_error_handler(static function (
$errno,
$errstr,
$errfile,
$errline
) {
$msg = print_r([
'code' => $errno,
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
], TRUE);
file_put_contents('error.log', $msg, FILE_APPEND);
return true;
}, -1);
set_exception_handler(static function (mixed $e) {
$msg = print_r([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTraceAsString(),
], TRUE);
file_put_contents('exception.log', $msg, FILE_APPEND);
});
// ! Init with an IIFE
return (static function (int $argc, array $argv): int {
Termios::enableRawMode();
register_shutdown_function([Termios::class, 'disableRawMode']);
Editor::new($argc, $argv)->run();
return 0;
})($argc, $argv);