Updat help, add license
This commit is contained in:
@ -194,42 +194,12 @@ class Editor
|
||||
}
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
$this->doShowAbout();
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
$text = <<<EOT
|
||||
Welcome to JSONEdit! The editor you have missed all this time without even knowing it!
|
||||
|
||||
To get started, press I (shift-i) and add something to the document. Use the arrow keys to get around. To cancel a prompt, close a menu or close a dialog, press ctrl-C. When you are happy with your work, press ctrl-W and enter a filename to write. You can also press ctrl-R and read in a new file, overwriting your masterpiece.
|
||||
|
||||
↑↓ Navigate values in document
|
||||
i Insert a new value
|
||||
I Insert value, array or object
|
||||
e Edit selected value
|
||||
E Edit selected key
|
||||
D Delete selected key
|
||||
^W Write to file
|
||||
^R Read from file
|
||||
^N New document with empty object
|
||||
^C Cancel/Exit
|
||||
|
||||
This is beta software, if not alpha. It kinda works, but there will be issues. Feel free to help out with a patch, or by filing bug reports.
|
||||
Known issues include:
|
||||
|
||||
* Editing long lines will blow up. Don't try to edit anything longer than the terminal is wide.
|
||||
* There is no fullscreen editing, so verbatim blocks in twig will probably not work well either.
|
||||
* Comments are not preserved.
|
||||
* Files are overwritten without confirmation.
|
||||
* There is no command mode, no search.
|
||||
* Some things just don't work yet.
|
||||
* Unhandled keys will appear in the bottom left of the screen with a delay.
|
||||
* Folding is not yet implemented.
|
||||
* There are crashes, and lock-ups. Data corruption is a possibility.
|
||||
|
||||
Go to https://dev.noccylabs.info/noccy/jsonedit to find the source code, issue tracker, and learn more about the project!
|
||||
EOT;
|
||||
$msg = new MessageBox($this->term, $text, "Help");
|
||||
$this->redrawInfoBar([ '^C' => 'Close' ]);
|
||||
$msg->display(10, 4, $w - 20, $h - 8);
|
||||
$this->redrawEditor();
|
||||
$this->doShowHelp();
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
@ -369,6 +339,106 @@ class Editor
|
||||
|
||||
}
|
||||
|
||||
private function doShowHelp(): void
|
||||
{
|
||||
[$w,$h] = $this->term->getSize();
|
||||
|
||||
$text = <<<EOT
|
||||
Welcome to JSONEdit! The editor you have missed all this time without even knowing it!
|
||||
|
||||
# QuickStart
|
||||
|
||||
To get started, press I (shift-i) and add something to the document. Use the arrow keys to get around. To cancel a prompt, close a menu or close a dialog, press ctrl-C. When you are happy with your work, press ctrl-W and enter a filename to write. You can also press ctrl-R and read in a new file, overwriting your masterpiece.
|
||||
|
||||
## Useful keys
|
||||
|
||||
↑↓ Navigate values in document
|
||||
h Show this help
|
||||
H Show information about the app and license
|
||||
i Insert a new value
|
||||
I Insert value, array or object
|
||||
e Edit selected value
|
||||
E Edit selected key
|
||||
D Delete selected key
|
||||
^W Write to file
|
||||
^R Read from file
|
||||
^N New document with empty object
|
||||
^C Cancel/Exit
|
||||
|
||||
## Doing stuff
|
||||
|
||||
### Adding keys or values
|
||||
|
||||
To add a key or a value, navigate to a value in an array or object, or to a specific array or object, and press "i". You will be prompted for the value, and for objects the key.
|
||||
|
||||
You can also press "I" to add arrays and objects. Just select what you want to add in the menu and press enter.
|
||||
|
||||
### Editing keys
|
||||
|
||||
You can edit keys on objects. For this, press "E".
|
||||
|
||||
### Editing values
|
||||
|
||||
### Loading and Saving files
|
||||
|
||||
# Disclaimer
|
||||
|
||||
This is beta software, if not alpha. It kinda works, but there will be issues. Feel free to help out with a patch, or by filing bug reports.
|
||||
Known issues include:
|
||||
|
||||
* Editing long lines will blow up. Don't try to edit anything longer than the terminal is wide.
|
||||
* There is no fullscreen editing, so verbatim blocks in twig will probably not work well either.
|
||||
* Comments are not preserved.
|
||||
* Files are overwritten without confirmation.
|
||||
* There is no command mode, no search.
|
||||
* Some things just don't work yet.
|
||||
* Unhandled keys will appear in the bottom left of the screen with a delay.
|
||||
* Folding is not yet implemented.
|
||||
* There are crashes, and lock-ups. Data corruption is a possibility.
|
||||
|
||||
# Support
|
||||
|
||||
Go to https://dev.noccylabs.info/noccy/jsonedit to find the source code, issue tracker, and learn more about the project!
|
||||
EOT;
|
||||
|
||||
$width = min(90, $w - 10);
|
||||
$height = min(40, $h - 6);
|
||||
$left = round(($w / 2) - ($width / 2));
|
||||
$top = round(($h / 2) - ($height / 2));
|
||||
|
||||
$msg = new MessageBox($this->term, $text, "Help");
|
||||
$this->redrawInfoBar([ '↑/↓' => 'Scroll', '^C' => 'Close' ]);
|
||||
$msg->display($left, $top, $width, $height);
|
||||
$this->redrawEditor();
|
||||
|
||||
}
|
||||
|
||||
private function doShowAbout(): void
|
||||
{
|
||||
[$w,$h] = $this->term->getSize();
|
||||
|
||||
$text = <<<EOT
|
||||
JSONEdit Alpha - Copyright (C) 2024, NoccyLabs
|
||||
|
||||
Licensed under GNU GPL v3.0 or later.
|
||||
|
||||
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;
|
||||
|
||||
$width = 60;
|
||||
$height = 20;
|
||||
$left = round(($w / 2) - ($width / 2));
|
||||
$top = round(($h / 2) - ($height / 2));
|
||||
|
||||
$msg = new MessageBox($this->term, $text, "About JSONEdit");
|
||||
$this->redrawInfoBar([ '↑/↓' => 'Scroll', '^C' => 'Close' ]);
|
||||
$msg->display($left, $top, $width, $height);
|
||||
$this->redrawEditor();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit selected key
|
||||
*
|
||||
|
@ -50,9 +50,6 @@ class MessageBox
|
||||
if ($ch == "\x03") {
|
||||
$showing = false;
|
||||
}
|
||||
if ($ch == "\r") {
|
||||
$showing = false;
|
||||
}
|
||||
} else {
|
||||
if ($ch == "k{UP}") {
|
||||
$this->scroll--;
|
||||
@ -90,11 +87,25 @@ class MessageBox
|
||||
;
|
||||
for ($n = 0; $n < $visibleItems; $n++) {
|
||||
if (isset($wrapped[$n+$this->scroll])) {
|
||||
$item = " " . $wrapped[$n+$this->scroll]??null;
|
||||
$line = $wrapped[$n+$this->scroll]??null;
|
||||
if (str_starts_with($line, "# ")) {
|
||||
$item = " " . mb_substr($line, 2);
|
||||
$pre = "\e[1;4m"; $post = "\e[22;24m";
|
||||
} elseif (str_starts_with($line, "## ")) {
|
||||
$item = " " . mb_substr($line, 3);
|
||||
$pre = "\e[1m"; $post = "\e[22m";
|
||||
} elseif (str_starts_with($line, "### ")) {
|
||||
$item = " " . mb_substr($line, 4);
|
||||
$pre = "\e[1;3m"; $post = "\e[23m";
|
||||
} else {
|
||||
$item = " " . $line;
|
||||
$pre = null; $post = null;
|
||||
}
|
||||
$item = $item . str_repeat(" ", $width - 2 - mb_strlen($item)) . "\e[40;37m";
|
||||
} else {
|
||||
$item = str_repeat(" ", $width - 2)."\e[40;37m";
|
||||
}
|
||||
$item = $pre . $item . $post;
|
||||
if ($n >= $thumbTop && $n <= $thumbBottom) {
|
||||
$scrollbar = "\e[97;1m".self::U_EDGE_VERTICAL_THUMB."\e[40;37;22m";
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user