diff --git a/CHANGELOG.md b/CHANGELOG.md index ab3384e8d..711ce403a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Features: * Support MATE Terminal version & terminal font detection * Add `--no-buffer` option for easier debugging. CMake option `ENABLE_BUFFER` is removed and always enabled. * Support `--*-key-color` option to change the key color of specified module -* Support `--colors-symbol` +* Support `--colors-symbol` and `--colors-padding-left` # 1.11.3 diff --git a/src/data/help.txt b/src/data/help.txt index 5feb254b6..137a09597 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -137,6 +137,7 @@ Module specific options: --command-key : Set the module key to display --command-text : Set the command text to be executed --colors-symbol : Set the symbol to be printed by Colors module. Default is block + --colors-padding-left : Set the number of white spaces to print before the symbol. Default is 0 Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci" If a value starts with a ?, it is optional. "true" will be used if not set. diff --git a/src/data/json_schema.jsonc b/src/data/json_schema.jsonc index b579fb7a1..b5edf812f 100644 --- a/src/data/json_schema.jsonc +++ b/src/data/json_schema.jsonc @@ -678,6 +678,13 @@ "star" ], "default": "block" + }, + "paddingLeft": { + "title": "modules.colors.paddingLeft", + "description": "Set the number of white spaces to print before the symbol", + "type": "integer", + "minimum": 0, + "default": 0 } } }, diff --git a/src/fastfetch.c b/src/fastfetch.c index f7587004a..c601ed647 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -941,6 +941,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(ffParseSeparatorCommandOptions(&instance->config.separator, key, value)) {} else if(ffParseSoundCommandOptions(&instance->config.sound, key, value)) {} else if(ffParseGamepadCommandOptions(&instance->config.gamepad, key, value)) {} + else if(ffParseColorsCommandOptions(&instance->config.colors, key, value)) {} /////////////////// //Library options// diff --git a/src/modules/colors/colors.c b/src/modules/colors/colors.c index 5e16578c6..646205bd0 100644 --- a/src/modules/colors/colors.c +++ b/src/modules/colors/colors.c @@ -11,6 +11,9 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options) ffLogoPrintLine(instance); + if(options->paddingLeft > 0) + ffPrintCharTimes(' ', options->paddingLeft); + if (options->symbol == FF_COLORS_SYMBOL_BLOCK) { // 4%d: Set the background color @@ -22,6 +25,9 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options) ffLogoPrintLine(instance); + if(options->paddingLeft > 0) + ffPrintCharTimes(' ', options->paddingLeft); + // 1: Set everything to bolt. This causes normal colors on some systems to be bright. // 4%d: Set the backgound to the not bright color // 3%d: Set the foreground to the not bright color @@ -53,6 +59,7 @@ void ffInitColorsOptions(FFColorsOptions* options) { options->moduleName = FF_COLORS_MODULE_NAME; options->symbol = FF_COLORS_SYMBOL_BLOCK; + options->paddingLeft = 0; } bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value) @@ -74,6 +81,12 @@ bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, cons return true; } + if (ffStrEqualsIgnCase(subKey, "padding-left")) + { + options->paddingLeft = ffOptionParseUInt32(key, value); + return true; + } + return false; } @@ -115,6 +128,12 @@ void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module) continue; } + if (ffStrEqualsIgnCase(key, "paddingLeft")) + { + options.paddingLeft = (uint32_t) yyjson_get_uint(val); + continue; + } + ffPrintErrorString(instance, FF_COLORS_MODULE_NAME, 0, NULL, NULL, "Unknown JSON key %s", key); } } diff --git a/src/modules/colors/colors.h b/src/modules/colors/colors.h index 7ab1a5efd..bcf2c2315 100644 --- a/src/modules/colors/colors.h +++ b/src/modules/colors/colors.h @@ -7,4 +7,5 @@ void ffPrintColors(FFinstance* instance, FFColorsOptions* options); void ffInitColorsOptions(FFColorsOptions* options); void ffDestroyColorsOptions(FFColorsOptions* options); +bool ffParseColorsCommandOptions(FFColorsOptions* options, const char* key, const char* value); void ffParseColorsJsonObject(FFinstance* instance, yyjson_val* module); diff --git a/src/modules/colors/option.h b/src/modules/colors/option.h index 4e2e0b2d9..6a4061ae2 100644 --- a/src/modules/colors/option.h +++ b/src/modules/colors/option.h @@ -18,4 +18,5 @@ typedef struct FFColorsOptions { const char* moduleName; FFColorssymbol symbol; + uint32_t paddingLeft; } FFColorsOptions;