Add compact mode, toggle with 'c'

This commit is contained in:
2024-10-02 02:14:36 +02:00
parent bf6756773e
commit be63775334
3 changed files with 28 additions and 10 deletions

View File

@@ -6,18 +6,22 @@ class Settings
{
public static bool $editorQuotedKeys = false;
public static bool $compactGroups = false;
public static function load(string $filename): void
{
if (file_exists($filename) && is_readable($filename)) {
$data = json_decode(file_get_contents($filename));
self::$editorQuotedKeys = $data->editorQuotedKeys ?? false;
self::$compactGroups = $data->compactGroups ?? false;
}
}
public static function save(string $filename): void
{
$data = json_encode([
'editorQuotedKeys' => self::$editorQuotedKeys
'editorQuotedKeys' => self::$editorQuotedKeys,
'compactGroups' => self::$compactGroups,
], JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)."\n";
@file_put_contents($filename, $data);
}
@@ -27,6 +31,8 @@ class Settings
switch ($key) {
case 'editorQuotedKeys':
self::$editorQuotedKeys = (bool)$value; break;
case 'compactGroups':
self::$compactGroups = (bool)$value; break;
}
}
}