php-kilo/kilo
2019-10-18 16:20:34 -04:00

48 lines
706 B
PHP
Executable File

#!/usr/bin/php
<?php declare(strict_types=1);
namespace Kilo;
require_once __DIR__ . '/src/constants.php';
require_once __DIR__ . '/src/functions.php';
require_once __DIR__ . '/src/Editor.php';
function main(int $argc, array $argv): int
{
global $ffi;
enableRawMode();
$editor = Editor::new($ffi);
if ($argc >= 2)
{
$editor->open($argv[1]);
}
$editor->setStatusMessage('HELP: Ctrl-Q = quit');
// Input Loop
while (true)
{
$editor->refreshScreen();
// Spin while waiting for a keypress
$char = $editor->processKeypress();
while ($char === '')
{
$char = $editor->processKeypress();
}
if ($char === NULL)
{
break;
}
}
return 0;
}
//! Init
main($argc, $argv);