php-kilo/src/Document.php

66 lines
987 B
PHP

<?php declare(strict_types=1);
namespace Aviat\Kilo;
/**
* The representation of the current document being edited
*
* @property-read int $numRows
*/
class Document {
public ?Syntax $syntax = NULL;
private function __construct(
public array $rows = [],
public ?string $filename = NULL,
private bool $dirty = FALSE,
) {}
public function __get(string $name): ?int
{
if ($name === 'numRows')
{
return count($this->rows);
}
return NULL;
}
public static function new(): self
{
return new self();
}
public static function open(?string $filename = NULL): self
{
// @TODO move logic from Editor
return new self(filename: $filename);
}
public function save(): bool
{
// @TODO move logic
return false;
}
public function insertChar(Point $at, string $c): void
{
}
public function isDirty(): bool
{
return $this->dirty;
}
public function deleteChar(Point $at): void
{
}
private function insertNewline(Point $at): void
{
}
}