diff --git a/doc/json_schema.json b/doc/json_schema.json index e39d4cf42..f8f34d607 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -1024,9 +1024,30 @@ }, { "const": "both", - "description": "Show both icon and string keys" + "description": "Show both icon and string keys (alias of `both-1`)" + }, + { + "const": "both-0", + "description": "Show both icon and string with no spaces between them" + }, + { + "const": "both-1", + "description": "Show both icon and string with a space between them" + }, + { + "const": "both-2", + "description": "Show both icon and string with 2 spaces between them" + }, + { + "const": "both-3", + "description": "Show both icon and string with 3 spaces between them" + }, + { + "const": "both-4", + "description": "Show both icon and string with 4 spaces between them" } ], + ], "default": "string" }, "paddingLeft": { diff --git a/src/common/option.h b/src/common/option.h index 4b8ea3eab..713e5ba53 100644 --- a/src/common/option.h +++ b/src/common/option.h @@ -44,7 +44,13 @@ typedef enum __attribute__((__packed__)) FFModuleKeyType FF_MODULE_KEY_TYPE_NONE = 0, FF_MODULE_KEY_TYPE_STRING = 1 << 0, FF_MODULE_KEY_TYPE_ICON = 1 << 1, - FF_MODULE_KEY_TYPE_BOTH = FF_MODULE_KEY_TYPE_STRING | FF_MODULE_KEY_TYPE_ICON, + FF_MODULE_KEY_TYPE_SPACE_SHIFT = 4, + FF_MODULE_KEY_TYPE_BOTH_0 = FF_MODULE_KEY_TYPE_STRING | FF_MODULE_KEY_TYPE_ICON, + FF_MODULE_KEY_TYPE_BOTH_1 = FF_MODULE_KEY_TYPE_BOTH_0 | (1 << FF_MODULE_KEY_TYPE_SPACE_SHIFT), + FF_MODULE_KEY_TYPE_BOTH = FF_MODULE_KEY_TYPE_BOTH_1, // alias + FF_MODULE_KEY_TYPE_BOTH_2 = FF_MODULE_KEY_TYPE_BOTH_0 | (2 << FF_MODULE_KEY_TYPE_SPACE_SHIFT), + FF_MODULE_KEY_TYPE_BOTH_3 = FF_MODULE_KEY_TYPE_BOTH_0 | (3 << FF_MODULE_KEY_TYPE_SPACE_SHIFT), + FF_MODULE_KEY_TYPE_BOTH_4 = FF_MODULE_KEY_TYPE_BOTH_0 | (4 << FF_MODULE_KEY_TYPE_SPACE_SHIFT), FF_MODULE_KEY_TYPE_FORCE_UNSIGNED = UINT8_MAX, } FFModuleKeyType; diff --git a/src/common/printing.c b/src/common/printing.c index 857b06c7a..f92677b0a 100644 --- a/src/common/printing.c +++ b/src/common/printing.c @@ -28,17 +28,12 @@ void ffPrintLogoAndKey(const char* moduleName, uint8_t moduleIndex, const FFModu ffPrintColor(&instance.config.display.colorKeys); } - bool hasIcon = false; if (instance.config.display.keyType & FF_MODULE_KEY_TYPE_ICON && moduleArgs && moduleArgs->keyIcon.length > 0) - { ffStrbufWriteTo(&moduleArgs->keyIcon, stdout); - hasIcon = true; - } if (instance.config.display.keyType & FF_MODULE_KEY_TYPE_STRING) { - if(hasIcon) - putchar(' '); + ffPrintCharTimes(' ', instance.config.display.keyType >> FF_MODULE_KEY_TYPE_SPACE_SHIFT); //NULL check is required for modules with custom keys, e.g. disk with the folder path if((printType & FF_PRINT_TYPE_NO_CUSTOM_KEY) || !moduleArgs || moduleArgs->key.length == 0) @@ -136,6 +131,12 @@ void ffPrintCharTimes(char c, uint32_t times) if(times == 0) return; + if(times == 1) + { + putchar(c); + return; + } + char str[32]; memset(str, c, sizeof(str)); //2 instructions when compiling with AVX2 enabled for(uint32_t i = sizeof(str); i <= times; i += (uint32_t)sizeof(str)) diff --git a/src/data/help.json b/src/data/help.json index 335f8563a..745570ff2 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -566,7 +566,12 @@ "none": "Disable keys", "string": "Show string", "icon": "Show icon (requires newest nerd font)", - "both": "Show both icon and string" + "both": "Show both icon and string (alias of `both-1`)", + "both-0": "Show both icon and string with no spaces between them", + "both-1": "Show both icon and string with a space between them", + "both-2": "Show both icon and string with 2 spaces between them", + "both-3": "Show both icon and string with 3 spaces between them", + "both-4": "Show both icon and string with 4 spaces between them" }, "default": "string" } diff --git a/src/options/display.c b/src/options/display.c index ab9d4c372..7ba790d46 100644 --- a/src/options/display.c +++ b/src/options/display.c @@ -451,6 +451,11 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va { "string", FF_MODULE_KEY_TYPE_STRING }, { "icon", FF_MODULE_KEY_TYPE_ICON }, { "both", FF_MODULE_KEY_TYPE_BOTH }, + { "both-0", FF_MODULE_KEY_TYPE_BOTH_0 }, + { "both-1", FF_MODULE_KEY_TYPE_BOTH_1 }, + { "both-2", FF_MODULE_KEY_TYPE_BOTH_2 }, + { "both-3", FF_MODULE_KEY_TYPE_BOTH_3 }, + { "both-4", FF_MODULE_KEY_TYPE_BOTH_4 }, {} }); if (error) return error; @@ -612,6 +617,11 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key { "string", FF_MODULE_KEY_TYPE_STRING }, { "icon", FF_MODULE_KEY_TYPE_ICON }, { "both", FF_MODULE_KEY_TYPE_BOTH }, + { "both-0", FF_MODULE_KEY_TYPE_BOTH_0 }, + { "both-1", FF_MODULE_KEY_TYPE_BOTH_1 }, + { "both-2", FF_MODULE_KEY_TYPE_BOTH_2 }, + { "both-3", FF_MODULE_KEY_TYPE_BOTH_3 }, + { "both-4", FF_MODULE_KEY_TYPE_BOTH_4 }, {} }); }