mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-04 12:14:19 +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 FFTerminalSizeOptions
|
||||
{
|
||||
typedef struct FFTerminalSizeOptions {
|
||||
FFModuleArgs moduleArgs;
|
||||
} FFTerminalSizeOptions;
|
||||
|
||||
|
||||
@@ -6,62 +6,54 @@
|
||||
|
||||
#define FF_TERMINALSIZE_DISPLAY_NAME "Terminal Size"
|
||||
|
||||
bool ffPrintTerminalSize(FFTerminalSizeOptions* options)
|
||||
{
|
||||
bool ffPrintTerminalSize(FFTerminalSizeOptions* options) {
|
||||
FFTerminalSizeResult result = {};
|
||||
|
||||
if(!ffDetectTerminalSize(&result))
|
||||
{
|
||||
if (!ffDetectTerminalSize(&result)) {
|
||||
ffPrintError(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Failed to detect terminal size");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
printf("%u columns x %u rows", result.columns, result.rows);
|
||||
|
||||
if (result.width != 0 && result.height != 0)
|
||||
if (result.width != 0 && result.height != 0) {
|
||||
printf(" (%upx x %upx)", result.width, result.height);
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
else
|
||||
{
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){
|
||||
FF_ARG(result.rows, "rows"),
|
||||
FF_ARG(result.columns, "columns"),
|
||||
FF_ARG(result.width, "width"),
|
||||
FF_ARG(result.height, "height"),
|
||||
}));
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_TERMINALSIZE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_ARG(result.rows, "rows"),
|
||||
FF_ARG(result.columns, "columns"),
|
||||
FF_ARG(result.width, "width"),
|
||||
FF_ARG(result.height, "height"),
|
||||
}));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffParseTerminalSizeJsonObject(FFTerminalSizeOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseTerminalSizeJsonObject(FFTerminalSizeOptions* 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_TERMINALSIZE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", unsafe_yyjson_get_str(key));
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateTerminalSizeJsonConfig(FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateTerminalSizeJsonConfig(FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
}
|
||||
|
||||
bool ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalSizeOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FFTerminalSizeResult result;
|
||||
|
||||
if(!ffDetectTerminalSize(&result))
|
||||
{
|
||||
if (!ffDetectTerminalSize(&result)) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", "Failed to detect terminal size");
|
||||
return false;
|
||||
}
|
||||
@@ -75,13 +67,11 @@ bool ffGenerateTerminalSizeJsonResult(FF_MAYBE_UNUSED FFTerminalSizeOptions* opt
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options)
|
||||
{
|
||||
void ffInitTerminalSizeOptions(FFTerminalSizeOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
}
|
||||
|
||||
void ffDestroyTerminalSizeOptions(FFTerminalSizeOptions* options)
|
||||
{
|
||||
void ffDestroyTerminalSizeOptions(FFTerminalSizeOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user