mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-03 03:41:04 +01:00
Chore: run clang-format
```bash find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.hpp" \) ! -path "src/3rdparty/*" -print0 | xargs -0 clang-format -i ```
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
|
||||
#include "common/option.h"
|
||||
|
||||
typedef struct FFTerminalThemeOptions
|
||||
{
|
||||
typedef struct FFTerminalThemeOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFTerminalThemeOptions;
|
||||
|
||||
|
||||
@@ -8,66 +8,61 @@
|
||||
|
||||
#define FF_TERMINALTHEME_DISPLAY_NAME "Terminal Theme"
|
||||
|
||||
bool ffPrintTerminalTheme(FFTerminalThemeOptions* options)
|
||||
{
|
||||
bool ffPrintTerminalTheme(FFTerminalThemeOptions* options) {
|
||||
FFTerminalThemeResult result = {};
|
||||
|
||||
if(!ffDetectTerminalTheme(&result, false))
|
||||
{
|
||||
if (!ffDetectTerminalTheme(&result, false)) {
|
||||
ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Failed to detect terminal theme");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
printf("#%02" PRIX16 "%02" PRIX16 "%02" PRIX16 " (FG) - #%02" PRIX16 "%02" PRIX16 "%02" PRIX16 " (BG) [%s]\n",
|
||||
result.fg.r, result.fg.g, result.fg.b,
|
||||
result.bg.r, result.bg.g, result.bg.b,
|
||||
result.fg.r,
|
||||
result.fg.g,
|
||||
result.fg.b,
|
||||
result.bg.r,
|
||||
result.bg.g,
|
||||
result.bg.b,
|
||||
result.bg.dark ? "Dark" : "Light");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
char fg[32], bg[32];
|
||||
const char* fgType = result.fg.dark ? "Dark" : "Light";
|
||||
const char* bgType = result.bg.dark ? "Dark" : "Light";
|
||||
snprintf(fg, ARRAY_SIZE(fg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.fg.r, result.fg.g, result.fg.b);
|
||||
snprintf(bg, ARRAY_SIZE(bg), "#%02" PRIX16 "%02" PRIX16 "%02" PRIX16, result.bg.r, result.bg.g, result.bg.b);
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_ARG(fg, "fg-color"),
|
||||
FF_ARG(fgType, "fg-type"),
|
||||
FF_ARG(bg, "bg-color"),
|
||||
FF_ARG(bgType, "bg-type"),
|
||||
}));
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_ARG(fg, "fg-color"),
|
||||
FF_ARG(fgType, "fg-type"),
|
||||
FF_ARG(bg, "bg-color"),
|
||||
FF_ARG(bgType, "bg-type"),
|
||||
}));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseTerminalThemeJsonObject(FFTerminalThemeOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseTerminalThemeJsonObject(FFTerminalThemeOptions* options, yyjson_val* module) {
|
||||
yyjson_val *key, *val;
|
||||
size_t idx, max;
|
||||
yyjson_obj_foreach(module, idx, max, key, val)
|
||||
{
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
|
||||
yyjson_obj_foreach (module, idx, max, key, val) {
|
||||
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ffPrintError(FF_TERMINALTHEME_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateTerminalThemeJsonConfig(FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateTerminalThemeJsonConfig(FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalThemeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FFTerminalThemeResult result = {};
|
||||
|
||||
if(!ffDetectTerminalTheme(&result, false))
|
||||
{
|
||||
if (!ffDetectTerminalTheme(&result, false)) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "Failed to detect terminal theme");
|
||||
return false;
|
||||
}
|
||||
@@ -89,13 +84,11 @@ bool ffGenerateTerminalThemeJsonResult(FF_MAYBE_UNUSED FFTerminalThemeOptions* o
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options)
|
||||
{
|
||||
void ffInitTerminalThemeOptions(FFTerminalThemeOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
void ffDestroyTerminalThemeOptions(FFTerminalThemeOptions* options)
|
||||
{
|
||||
void ffDestroyTerminalThemeOptions(FFTerminalThemeOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
@@ -113,5 +106,4 @@ FFModuleBaseInfo ffTerminalThemeModuleInfo = {
|
||||
{"Terminal foreground type (Dark / Light)", "fg-type"},
|
||||
{"Terminal background color", "bg-color"},
|
||||
{"Terminal background type (Dark / Light)", "bg-type"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
Reference in New Issue
Block a user