diff --git a/composer.json b/composer.json index b36724b..77caa3d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "noccylabs/jsonedit", - "description": "JSON/YAML editor for terminal junkies", + "description": "A JSON/YAML editor for terminal junkies", "type": "application", "license": "GPL-3.0-or-later", "autoload": { diff --git a/src/Editor/Editor.php b/src/Editor/Editor.php index e74fc6e..a31ecf6 100644 --- a/src/Editor/Editor.php +++ b/src/Editor/Editor.php @@ -350,7 +350,10 @@ class Editor [$w,$h] = $this->term->getSize(); $readFrom = $this->ask("\e[33mRead from:\e[0m ", ""); - + if ($readFrom === null) { + $this->redrawInfoBar(); + return; + } if (!file_exists($readFrom)) { $this->showMessage("\e[97;41mFile does not exist"); return; @@ -525,14 +528,15 @@ class Editor This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - EOT; + + EOT."\n/ Built on: ".APP_BUILDDATE; $width = 60; - $height = 20; + $height = 21; $left = round(($w / 2) - ($width / 2)); $top = round(($h / 2) - ($height / 2)); - $msg = new MessageBox($this->term, $text, "About JSONEdit"); + $msg = new MessageBox($this->term, $text, "About JSONEdit ".APP_VERSION); $this->redrawInfoBar([ '↑/↓' => 'Scroll', '^C' => 'Close' ]); $msg->display($left, $top, $width, $height); $this->redrawEditor(); @@ -776,7 +780,7 @@ class Editor } $cursorOffs = $cursorPos - $scrollPos; $this->term->setCursor(1, $h); - echo $prompt."\e[0m\e[K".mb_substr($value, $scrollPos, $available); + echo "\e[0m".$prompt."\e[0m\e[K".mb_substr($value, $scrollPos, $available); $this->term->setCursor($promptLen+$cursorOffs+1, $h, true); while (null === ($ch = $this->term->readKey())) { usleep(10000); @@ -921,7 +925,7 @@ class Editor ]; } $keys = [ ...$keys, - '^R' => 'Read', + '^O' => 'Open', '^X' => 'Exit', ]; } @@ -971,8 +975,10 @@ Enter Edit string/number, toggle booleans D Delete selected key c Toggle compact list view q Toggle quoted keys in list view - ^W Write to file - ^R Read from file + g Toggle indentation guide lines visibility + t Toggle tail line visibility + ^W Write to a file + ^R Read from a file ^O Open file browser ^N New document with empty object ^X Exit diff --git a/src/Editor/MessageBox.php b/src/Editor/MessageBox.php index 9b79dab..50f26cf 100644 --- a/src/Editor/MessageBox.php +++ b/src/Editor/MessageBox.php @@ -117,7 +117,7 @@ class MessageBox $scrollTop = $this->scroll; $scrollBottom = $scrollTop + $visibleItems - 1; $thumbTop = round(($visibleItems - 1) / count($wrapped) * $scrollTop); - $thumbBottom = round(($visibleItems - 1) / count($wrapped) * $scrollBottom); + $thumbBottom = round($visibleItems / count($wrapped) * $scrollBottom); echo "\e[40;37m"; $this->terminal @@ -139,6 +139,9 @@ class MessageBox } elseif (str_starts_with($line, "### ")) { $item = " " . mb_substr($line, 4); $pre = "\e[1;3m"; $post = "\e[23m"; + } elseif (str_starts_with($line, "/ ")) { + $item = " " . mb_substr($line, 2); + $pre = "\e[3m"; $post = "\e[23m"; } else { $item = " " . $line; $pre = null; $post = null;