Add icons to items in before mode, ask to save changes

This commit is contained in:
2024-10-03 16:36:35 +02:00
parent ddfefa124b
commit 0abca3d3a8
2 changed files with 53 additions and 3 deletions

View File

@ -21,6 +21,11 @@ class TreeList implements Countable
private const TREE_INDENT_GUIDE = "\u{258f} ";
private const TREE_INDENT = " ";
private const ICON_NUMERIC = "\u{f89f}";
private const ICON_STRING = "\u{f475}";
private const ICON_BOOL = "\u{f657}";
private const ICON_NULL = "\u{2400}";
public function __construct(private Tree $tree)
{
}
@ -186,6 +191,16 @@ class TreeList implements Countable
}
if (!is_null($entry->key)) {
if (Settings::$collapseBefore && $entry->node instanceof ValueNode) {
echo match (gettype($entry->node->value)) {
'string' => self::ICON_STRING,
'integer' => self::ICON_NUMERIC,
'double' => self::ICON_NUMERIC,
'boolean' => self::ICON_BOOL,
'NULL' => self::ICON_NULL,
default => self::ICON_STRING,
}." ";
}
echo (is_int($entry->key)
?"\e[36;2m\u{e0b6}\e[7m#{$entry->key}\e[27m\u{e0b4}\e[22;37m "
:(Settings::$editorQuotedKeys