Show child keys of folded key, count of folded arrays
This commit is contained in:
parent
1cccfc0187
commit
f023de0198
@ -174,6 +174,8 @@ class Editor
|
|||||||
'value' => "Insert Value",
|
'value' => "Insert Value",
|
||||||
'object' => "Insert Object{}",
|
'object' => "Insert Object{}",
|
||||||
'array' => "Insert Array[]",
|
'array' => "Insert Array[]",
|
||||||
|
'sep0' => "---",
|
||||||
|
'__paste' => "Paste from clipboard",
|
||||||
], 'Insert');
|
], 'Insert');
|
||||||
$this->redrawInfoBar([ '^C' => 'Cancel', '↑/↓' => 'Select option', 'Enter' => 'Accept' ]);
|
$this->redrawInfoBar([ '^C' => 'Cancel', '↑/↓' => 'Select option', 'Enter' => 'Accept' ]);
|
||||||
$sel = $menu->display(0, 0, 30, 0, "value");
|
$sel = $menu->display(0, 0, 30, 0, "value");
|
||||||
|
@ -81,7 +81,7 @@ class Menu
|
|||||||
|
|
||||||
private function redraw(int $left, int $top, int $width, int $height) {
|
private function redraw(int $left, int $top, int $width, int $height) {
|
||||||
|
|
||||||
$visibleItems = $height - 4;
|
$visibleItems = $height - 2;
|
||||||
|
|
||||||
$scrollTop = $this->scroll;
|
$scrollTop = $this->scroll;
|
||||||
$scrollVisible = $visibleItems / count($this->items); // / $visibleItems;
|
$scrollVisible = $visibleItems / count($this->items); // / $visibleItems;
|
||||||
@ -93,24 +93,30 @@ class Menu
|
|||||||
echo "\e[40;37m";
|
echo "\e[40;37m";
|
||||||
$this->terminal
|
$this->terminal
|
||||||
->writeAt($left, $top + 0, self::U_CORNER_ROUNDED_TOPLEFT.str_repeat(self::U_EDGE_HORIZONTAL,$width - 2).self::U_CORNER_ROUNDED_TOPRIGHT)
|
->writeAt($left, $top + 0, self::U_CORNER_ROUNDED_TOPLEFT.str_repeat(self::U_EDGE_HORIZONTAL,$width - 2).self::U_CORNER_ROUNDED_TOPRIGHT)
|
||||||
->writeAt($left, $top + 1, self::U_EDGE_VERTICAL.str_repeat(" ",$width - 2).self::U_EDGE_VERTICAL)
|
//->writeAt($left, $top + 1, self::U_EDGE_VERTICAL.str_repeat(" ",$width - 2).self::U_EDGE_VERTICAL)
|
||||||
->writeAt($left + 2, $top + 1, "\e[1m" . $this->title . "\e[22m")
|
//->writeAt($left + 2, $top + 1, "\e[1m" . $this->title . "\e[22m")
|
||||||
->writeAt($left, $top + 2, self::U_EDGE_VERTICAL_RIGHT.str_repeat(self::U_EDGE_HORIZONTAL,$width - 2).self::U_EDGE_VERTICAL_LEFT)
|
//->writeAt($left, $top + 2, self::U_EDGE_VERTICAL_RIGHT.str_repeat(self::U_EDGE_HORIZONTAL,$width - 2).self::U_EDGE_VERTICAL_LEFT)
|
||||||
->writeAt($left, $top + $height - 1, self::U_CORNER_BOTTOMLEFT.str_repeat(self::U_EDGE_HORIZONTAL,$width - 2).self::U_CORNER_BOTTOMRIGHT)
|
->writeAt($left, $top + $height - 1, self::U_CORNER_BOTTOMLEFT.str_repeat(self::U_EDGE_HORIZONTAL,$width - 2).self::U_CORNER_BOTTOMRIGHT)
|
||||||
;
|
;
|
||||||
$keys = array_keys($this->items);
|
$keys = array_keys($this->items);
|
||||||
for ($n = 0; $n < $visibleItems; $n++) {
|
for ($n = 0; $n < $visibleItems; $n++) {
|
||||||
$key = $keys[$n]??null;
|
$key = $keys[$n]??null;
|
||||||
$item = " " . ($key ? ($this->items[$key]) : null);
|
$item = ($key ? ($this->items[$key]) : null);
|
||||||
$item = $item . str_repeat(" ", $width - 2 - $this->itemlen($item)) . "\e[40;37m";
|
if ($item === "---") {
|
||||||
|
$item = "\e[2m".str_repeat("\u{2500}", $width - 2)."\e[22m";
|
||||||
|
} elseif (is_null($item)) {
|
||||||
|
$item = str_repeat(" ", $width - 2);
|
||||||
|
} else {
|
||||||
|
$item = " " . $item . str_repeat(" ", $width - 3 - $this->itemlen($item)) . "\e[40;37m";
|
||||||
$item = (($n == $this->index)?"\e[37;44m":"\e[40;37m") . $item;
|
$item = (($n == $this->index)?"\e[37;44m":"\e[40;37m") . $item;
|
||||||
|
}
|
||||||
if ($n >= $thumbTop && $n <= $thumbBottom) {
|
if ($n >= $thumbTop && $n <= $thumbBottom) {
|
||||||
$scrollbar = "\e[97;1m".self::U_EDGE_VERTICAL_THUMB."\e[40;37;22m";
|
$scrollbar = "\e[97;1m".self::U_EDGE_VERTICAL_THUMB."\e[40;37;22m";
|
||||||
} else {
|
} else {
|
||||||
$scrollbar = "\e[37;2m".self::U_EDGE_VERTICAL_SCROLL."\e[40;37;22m";
|
$scrollbar = "\e[37;2m".self::U_EDGE_VERTICAL_SCROLL."\e[40;37;22m";
|
||||||
}
|
}
|
||||||
$this->terminal
|
$this->terminal
|
||||||
->writeAt($left, $top + 3 + $n, self::U_EDGE_VERTICAL.$item.$scrollbar);
|
->writeAt($left, $top + 1 + $n, self::U_EDGE_VERTICAL.$item.$scrollbar);
|
||||||
}
|
}
|
||||||
echo "\e[0m";
|
echo "\e[0m";
|
||||||
}
|
}
|
||||||
|
@ -175,14 +175,14 @@ class TreeList implements Countable
|
|||||||
if ($entry->node instanceof ArrayNode) {
|
if ($entry->node instanceof ArrayNode) {
|
||||||
echo "[" . (Settings::$compactGroups ? "…]":"");
|
echo "[" . (Settings::$compactGroups ? "…]":"");
|
||||||
if ($entry->node->isCollapsed()) {
|
if ($entry->node->isCollapsed()) {
|
||||||
echo " \e[90m\u{25ba} \e[2m".count($entry->node->items)."\e[22m";
|
echo " \e[90m\u{25ba} \e[2m[".count($entry->node->items)."]\e[22m";
|
||||||
} else {
|
} else {
|
||||||
echo " \e[90m\u{25bc}";
|
echo " \e[90m\u{25bc}";
|
||||||
}
|
}
|
||||||
} elseif ($entry->node instanceof ObjectNode) {
|
} elseif ($entry->node instanceof ObjectNode) {
|
||||||
echo "{" . (Settings::$compactGroups ? "…}":"");
|
echo "{" . (Settings::$compactGroups ? "…}":"");
|
||||||
if ($entry->node->isCollapsed()) {
|
if ($entry->node->isCollapsed()) {
|
||||||
echo " \e[90m\u{25ba} \e[2m".count($entry->node->properties)."\e[22m";
|
echo " \e[90m\u{25ba} \e[2m".join(", ",array_keys($entry->node->properties))."\e[22m";
|
||||||
} else {
|
} else {
|
||||||
echo " \e[90m\u{25bc}";
|
echo " \e[90m\u{25bc}";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user