php-kilo/src/Document.php

66 lines
987 B
PHP
Raw Normal View History

2021-03-10 16:24:02 -05:00
<?php declare(strict_types=1);
namespace Aviat\Kilo;
/**
* The representation of the current document being edited
*
* @property-read int $numRows
*/
2021-03-10 16:24:02 -05:00
class Document {
public ?Syntax $syntax = NULL;
2021-03-10 16:24:02 -05:00
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();
}
2021-03-10 16:24:02 -05:00
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
{
}
}