mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 10:52:08 +02: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:
+40
-69
@@ -5,77 +5,61 @@
|
||||
#include "detection/mouse/mouse.h"
|
||||
#include "modules/mouse/mouse.h"
|
||||
|
||||
static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, uint8_t index)
|
||||
{
|
||||
if(options->moduleArgs.outputFormat.length == 0)
|
||||
{
|
||||
static void printDevice(FFMouseOptions* options, const FFMouseDevice* device, uint8_t index) {
|
||||
if (options->moduleArgs.outputFormat.length == 0) {
|
||||
ffPrintLogoAndKey(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
|
||||
ffStrbufPutTo(&device->name, stdout);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FF_PRINT_FORMAT_CHECKED(FF_MOUSE_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]) {
|
||||
FF_ARG(device->name, "name"),
|
||||
FF_ARG(device->serial, "serial"),
|
||||
}));
|
||||
FF_ARG(device->name, "name"),
|
||||
FF_ARG(device->serial, "serial"),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
bool ffPrintMouse(FFMouseOptions* options)
|
||||
{
|
||||
bool ffPrintMouse(FFMouseOptions* options) {
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFMouseDevice));
|
||||
|
||||
const char* error = ffDetectMouse(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
if (error) {
|
||||
ffPrintError(FF_MOUSE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "%s", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!result.length)
|
||||
{
|
||||
if (!result.length) {
|
||||
ffPrintError(FF_MOUSE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "No devices detected");
|
||||
return false;
|
||||
}
|
||||
|
||||
FF_LIST_AUTO_DESTROY filtered = ffListCreate(sizeof(FFMouseDevice*));
|
||||
FF_LIST_FOR_EACH(FFMouseDevice, device, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFMouseDevice, device, result) {
|
||||
bool ignored = false;
|
||||
FF_LIST_FOR_EACH(FFstrbuf, ignore, options->ignores)
|
||||
{
|
||||
if(ffStrbufStartsWithIgnCase(&device->name, ignore))
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFstrbuf, ignore, options->ignores) {
|
||||
if (ffStrbufStartsWithIgnCase(&device->name, ignore)) {
|
||||
ignored = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!ignored)
|
||||
{
|
||||
if (!ignored) {
|
||||
FFMouseDevice** ptr = ffListAdd(&filtered);
|
||||
*ptr = device;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if(!filtered.length)
|
||||
{
|
||||
if (!filtered.length) {
|
||||
ffPrintError(FF_MOUSE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "All devices are ignored");
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
uint8_t index = 0;
|
||||
FF_LIST_FOR_EACH(FFMouseDevice*, pdevice, filtered)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFMouseDevice*, pdevice, filtered) {
|
||||
FFMouseDevice* device = *pdevice;
|
||||
printDevice(options, device, filtered.length > 1 ? ++index : 0);
|
||||
}
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFMouseDevice, device, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFMouseDevice, device, result) {
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
@@ -83,23 +67,19 @@ bool ffPrintMouse(FFMouseOptions* options)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ffParseMouseJsonObject(FFMouseOptions* options, yyjson_val* module)
|
||||
{
|
||||
void ffParseMouseJsonObject(FFMouseOptions* 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;
|
||||
}
|
||||
|
||||
if (unsafe_yyjson_equals_str(key, "ignores"))
|
||||
{
|
||||
yyjson_val *elem;
|
||||
if (unsafe_yyjson_equals_str(key, "ignores")) {
|
||||
yyjson_val* elem;
|
||||
size_t eidx, emax;
|
||||
yyjson_arr_foreach(val, eidx, emax, elem)
|
||||
{
|
||||
if (yyjson_is_str(elem))
|
||||
{
|
||||
yyjson_arr_foreach (val, eidx, emax, elem) {
|
||||
if (yyjson_is_str(elem)) {
|
||||
FFstrbuf* strbuf = ffListAdd(&options->ignores);
|
||||
ffStrbufInitJsonVal(strbuf, elem);
|
||||
}
|
||||
@@ -111,42 +91,36 @@ void ffParseMouseJsonObject(FFMouseOptions* options, yyjson_val* module)
|
||||
}
|
||||
}
|
||||
|
||||
void ffGenerateMouseJsonConfig(FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
void ffGenerateMouseJsonConfig(FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
ffJsonConfigGenerateModuleArgsConfig(doc, module, &options->moduleArgs);
|
||||
|
||||
if (options->ignores.length > 0)
|
||||
{
|
||||
if (options->ignores.length > 0) {
|
||||
yyjson_mut_val* ignores = yyjson_mut_obj_add_arr(doc, module, "ignores");
|
||||
FF_LIST_FOR_EACH(FFstrbuf, strbuf, options->ignores)
|
||||
FF_LIST_FOR_EACH (FFstrbuf, strbuf, options->ignores) {
|
||||
yyjson_mut_arr_append(ignores, yyjson_mut_strncpy(doc, strbuf->chars, strbuf->length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
|
||||
{
|
||||
bool ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) {
|
||||
FF_LIST_AUTO_DESTROY result = ffListCreate(sizeof(FFMouseDevice));
|
||||
|
||||
const char* error = ffDetectMouse(&result);
|
||||
|
||||
if(error)
|
||||
{
|
||||
if (error) {
|
||||
yyjson_mut_obj_add_str(doc, module, "error", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
yyjson_mut_val* arr = yyjson_mut_obj_add_arr(doc, module, "result");
|
||||
FF_LIST_FOR_EACH(FFMouseDevice, device, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFMouseDevice, device, result) {
|
||||
yyjson_mut_val* obj = yyjson_mut_arr_add_obj(doc, arr);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "serial", &device->serial);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "name", &device->name);
|
||||
|
||||
bool ignored = false;
|
||||
FF_LIST_FOR_EACH(FFstrbuf, ignore, options->ignores)
|
||||
{
|
||||
if(ffStrbufStartsWithIgnCase(&device->name, ignore))
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFstrbuf, ignore, options->ignores) {
|
||||
if (ffStrbufStartsWithIgnCase(&device->name, ignore)) {
|
||||
ignored = true;
|
||||
break;
|
||||
}
|
||||
@@ -154,8 +128,7 @@ bool ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m
|
||||
yyjson_mut_obj_add_bool(doc, obj, "ignored", ignored);
|
||||
}
|
||||
|
||||
FF_LIST_FOR_EACH(FFMouseDevice, device, result)
|
||||
{
|
||||
FF_LIST_FOR_EACH (FFMouseDevice, device, result) {
|
||||
ffStrbufDestroy(&device->serial);
|
||||
ffStrbufDestroy(&device->name);
|
||||
}
|
||||
@@ -163,19 +136,18 @@ bool ffGenerateMouseJsonResult(FF_MAYBE_UNUSED FFMouseOptions* options, yyjson_m
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffInitMouseOptions(FFMouseOptions* options)
|
||||
{
|
||||
void ffInitMouseOptions(FFMouseOptions* options) {
|
||||
ffOptionInitModuleArg(&options->moduleArgs, "");
|
||||
|
||||
ffListInit(&options->ignores, sizeof(FFstrbuf));
|
||||
}
|
||||
|
||||
void ffDestroyMouseOptions(FFMouseOptions* options)
|
||||
{
|
||||
void ffDestroyMouseOptions(FFMouseOptions* options) {
|
||||
ffOptionDestroyModuleArg(&options->moduleArgs);
|
||||
|
||||
FF_LIST_FOR_EACH(FFstrbuf, str, options->ignores)
|
||||
FF_LIST_FOR_EACH (FFstrbuf, str, options->ignores) {
|
||||
ffStrbufDestroy(str);
|
||||
}
|
||||
ffListDestroy(&options->ignores);
|
||||
}
|
||||
|
||||
@@ -191,5 +163,4 @@ FFModuleBaseInfo ffMouseModuleInfo = {
|
||||
.formatArgs = FF_FORMAT_ARG_LIST(((FFModuleFormatArg[]) {
|
||||
{"Mouse name", "name"},
|
||||
{"Mouse serial number", "serial"},
|
||||
}))
|
||||
};
|
||||
}))};
|
||||
|
||||
Reference in New Issue
Block a user