Change indent guide, comments

This commit is contained in:
Chris 2024-10-07 11:41:00 +02:00
parent 73ac4dd3f6
commit 98576daa67

View File

@ -14,6 +14,12 @@ use NoccyLabs\JsonEdit\Tree\ObjectNode;
use NoccyLabs\JsonEdit\Tree\ValueNode; use NoccyLabs\JsonEdit\Tree\ValueNode;
use Traversable; use Traversable;
/**
* This class flattens a tree into a list that can be indexed and addressed.
* The path separated by slashes is used as the key, and the Entry wraps the
* Node in the tree.
*
*/
class TreeList implements Countable, IteratorAggregate class TreeList implements Countable, IteratorAggregate
{ {
/** @var array<string,Entry> */ /** @var array<string,Entry> */
@ -21,7 +27,7 @@ class TreeList implements Countable, IteratorAggregate
private const TREE_FOLD_OPEN = "\u{f0fe}"; private const TREE_FOLD_OPEN = "\u{f0fe}";
private const TREE_FOLD_CLOSE = "\u{f146}"; private const TREE_FOLD_CLOSE = "\u{f146}";
private const TREE_INDENT_GUIDE = "\u{258f} "; private const TREE_INDENT_GUIDE = "\u{258e} ";
private const TREE_INDENT = " "; private const TREE_INDENT = " ";
private const ICON_NUMERIC = "\u{f89f}"; private const ICON_NUMERIC = "\u{f89f}";
@ -34,11 +40,21 @@ class TreeList implements Countable, IteratorAggregate
{ {
} }
/**
* Iterate over all visible nodes
*
* @return Traversable
*/
public function getIterator(): Traversable public function getIterator(): Traversable
{ {
return new ArrayIterator($this->list); return new ArrayIterator($this->list);
} }
/**
* Return the number of visible nodes
*
* @return int
*/
public function count(): int public function count(): int
{ {
return count($this->list); return count($this->list);
@ -134,6 +150,15 @@ class TreeList implements Countable, IteratorAggregate
return null; return null;
} }
/**
* Draw an entry to a row on the screen.
*
* @param int $screenRow
* @param int $entryRow
* @param int $columns
* @param bool $selected
* @return void
*/
public function drawEntry(int $screenRow, int $entryRow, int $columns, bool $selected): void public function drawEntry(int $screenRow, int $entryRow, int $columns, bool $selected): void
{ {