mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-01 10:32:35 +01:00
Colors: add --colors-padding-left
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ Module specific options:
|
||||
--command-key <str>: Set the module key to display
|
||||
--command-text <str>: Set the command text to be executed
|
||||
--colors-symbol <str>: Set the symbol to be printed by Colors module. Default is block
|
||||
--colors-padding-left <value>: 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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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//
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -18,4 +18,5 @@ typedef struct FFColorsOptions
|
||||
{
|
||||
const char* moduleName;
|
||||
FFColorssymbol symbol;
|
||||
uint32_t paddingLeft;
|
||||
} FFColorsOptions;
|
||||
|
||||
Reference in New Issue
Block a user