mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-10 13:37:25 +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:
1 parent
cdd4cee968
commit
e0eba8ce21
690 files changed
+28093
-30062
No files matched your search
+45
-64
@@ -3,10 +3,10 @@
|
||||
#include "common/textModifier.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig config, const FFModuleArgs* module)
|
||||
{
|
||||
if (celsius == -DBL_MAX) // ignores invalid value
|
||||
void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig config, const FFModuleArgs* module) {
|
||||
if (celsius == -DBL_MAX) { // ignores invalid value
|
||||
return;
|
||||
}
|
||||
|
||||
const FFOptionsDisplay* options = &instance.config.display;
|
||||
const char* colorGreen = options->tempColorGreen.chars;
|
||||
@@ -15,76 +15,68 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
|
||||
|
||||
uint8_t green = config.green, yellow = config.yellow;
|
||||
|
||||
if (!options->pipe)
|
||||
{
|
||||
if(green <= yellow)
|
||||
{
|
||||
if (celsius > yellow)
|
||||
if (!options->pipe) {
|
||||
if (green <= yellow) {
|
||||
if (celsius > yellow) {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorRed);
|
||||
else if (celsius > green)
|
||||
} else if (celsius > green) {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorYellow);
|
||||
else
|
||||
} else {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorGreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (celsius < yellow)
|
||||
}
|
||||
} else {
|
||||
if (celsius < yellow) {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorRed);
|
||||
else if (celsius < green)
|
||||
} else if (celsius < green) {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorYellow);
|
||||
else
|
||||
} else {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", colorGreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (options->tempUnit)
|
||||
{
|
||||
switch (options->tempUnit) {
|
||||
case FF_TEMPERATURE_UNIT_DEFAULT:
|
||||
case FF_TEMPERATURE_UNIT_CELSIUS:
|
||||
ffStrbufAppendF(buffer, "%.*f%s°C", options->tempNdigits, celsius,
|
||||
options->tempSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_ALWAYS ? " " : "");
|
||||
ffStrbufAppendF(buffer, "%.*f%s°C", options->tempNdigits, celsius, options->tempSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_ALWAYS ? " " : "");
|
||||
break;
|
||||
case FF_TEMPERATURE_UNIT_FAHRENHEIT:
|
||||
ffStrbufAppendF(buffer, "%.*f%s°F", options->tempNdigits, celsius * 1.8 + 32,
|
||||
options->tempSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_ALWAYS ? " " : "");
|
||||
ffStrbufAppendF(buffer, "%.*f%s°F", options->tempNdigits, celsius * 1.8 + 32, options->tempSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_ALWAYS ? " " : "");
|
||||
break;
|
||||
case FF_TEMPERATURE_UNIT_KELVIN:
|
||||
ffStrbufAppendF(buffer, "%.*f%sK", options->tempNdigits, celsius + 273.15,
|
||||
options->tempSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_NEVER ? "" : " ");
|
||||
ffStrbufAppendF(buffer, "%.*f%sK", options->tempNdigits, celsius + 273.15, options->tempSpaceBeforeUnit == FF_SPACE_BEFORE_UNIT_NEVER ? "" : " ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!options->pipe)
|
||||
{
|
||||
if (!options->pipe) {
|
||||
ffStrbufAppendS(buffer, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
if (module->outputColor.length)
|
||||
if (module->outputColor.length) {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", module->outputColor.chars);
|
||||
else if (instance.config.display.colorOutput.length)
|
||||
} else if (instance.config.display.colorOutput.length) {
|
||||
ffStrbufAppendF(buffer, "\e[%sm", instance.config.display.colorOutput.chars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ffTempsParseCommandOptions(const char* key, const char* subkey, const char* value, bool* useTemp, FFColorRangeConfig* config)
|
||||
{
|
||||
if (!ffStrStartsWithIgnCase(subkey, "temp"))
|
||||
bool ffTempsParseCommandOptions(const char* key, const char* subkey, const char* value, bool* useTemp, FFColorRangeConfig* config) {
|
||||
if (!ffStrStartsWithIgnCase(subkey, "temp")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (subkey[strlen("temp")] == '\0')
|
||||
{
|
||||
if (subkey[strlen("temp")] == '\0') {
|
||||
*useTemp = ffOptionParseBoolean(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (subkey[strlen("temp")] != '-')
|
||||
if (subkey[strlen("temp")] != '-') {
|
||||
return false;
|
||||
}
|
||||
|
||||
subkey += strlen("temp-");
|
||||
|
||||
if (ffStrEqualsIgnCase(subkey, "green"))
|
||||
{
|
||||
if (ffStrEqualsIgnCase(subkey, "green")) {
|
||||
uint32_t num = ffOptionParseUInt32(key, value);
|
||||
if (num > 100)
|
||||
{
|
||||
if (num > 100) {
|
||||
fprintf(stderr, "Error: usage: %s must be between 0 and 100\n", key);
|
||||
exit(480);
|
||||
}
|
||||
@@ -92,11 +84,9 @@ bool ffTempsParseCommandOptions(const char* key, const char* subkey, const char*
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ffStrEqualsIgnCase(subkey, "yellow"))
|
||||
{
|
||||
if (ffStrEqualsIgnCase(subkey, "yellow")) {
|
||||
uint32_t num = ffOptionParseUInt32(key, value);
|
||||
if (num > 100)
|
||||
{
|
||||
if (num > 100) {
|
||||
fprintf(stderr, "Error: usage: %s must be between 0 and 100\n", key);
|
||||
exit(480);
|
||||
}
|
||||
@@ -107,27 +97,24 @@ bool ffTempsParseCommandOptions(const char* key, const char* subkey, const char*
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, FFColorRangeConfig* config)
|
||||
{
|
||||
bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, FFColorRangeConfig* config) {
|
||||
assert(key);
|
||||
|
||||
if (!unsafe_yyjson_equals_str(key, "temp"))
|
||||
if (!unsafe_yyjson_equals_str(key, "temp")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (yyjson_is_bool(value))
|
||||
{
|
||||
if (yyjson_is_bool(value)) {
|
||||
*useTemp = yyjson_get_bool(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (yyjson_is_null(value))
|
||||
{
|
||||
if (yyjson_is_null(value)) {
|
||||
*useTemp = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!yyjson_is_obj(value))
|
||||
{
|
||||
if (!yyjson_is_obj(value)) {
|
||||
fprintf(stderr, "Error: usage: %s must be an object or a boolean\n", unsafe_yyjson_get_str(key));
|
||||
exit(480);
|
||||
}
|
||||
@@ -135,11 +122,9 @@ bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, F
|
||||
*useTemp = true;
|
||||
|
||||
yyjson_val* greenVal = yyjson_obj_get(value, "green");
|
||||
if (greenVal)
|
||||
{
|
||||
if (greenVal) {
|
||||
int num = yyjson_get_int(greenVal);
|
||||
if (num < 0 || num > 100)
|
||||
{
|
||||
if (num < 0 || num > 100) {
|
||||
fputs("Error: usage: temp.green must be between 0 and 100\n", stderr);
|
||||
exit(480);
|
||||
}
|
||||
@@ -147,11 +132,9 @@ bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, F
|
||||
}
|
||||
|
||||
yyjson_val* yellowVal = yyjson_obj_get(value, "yellow");
|
||||
if (yellowVal)
|
||||
{
|
||||
if (yellowVal) {
|
||||
int num = yyjson_get_int(yellowVal);
|
||||
if (num < 0 || num > 100)
|
||||
{
|
||||
if (num < 0 || num > 100) {
|
||||
fputs("Error: usage: temp.yellow must be between 0 and 100\n", stderr);
|
||||
exit(480);
|
||||
}
|
||||
@@ -161,12 +144,10 @@ bool ffTempsParseJsonObject(yyjson_val* key, yyjson_val* value, bool* useTemp, F
|
||||
return true;
|
||||
}
|
||||
|
||||
void ffTempsGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, bool temp, FFColorRangeConfig config)
|
||||
{
|
||||
if (!temp)
|
||||
void ffTempsGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, bool temp, FFColorRangeConfig config) {
|
||||
if (!temp) {
|
||||
yyjson_mut_obj_add_bool(doc, module, "temp", false);
|
||||
else
|
||||
{
|
||||
} else {
|
||||
yyjson_mut_val* temp = yyjson_mut_obj_add_obj(doc, module, "temp");
|
||||
yyjson_mut_obj_add_uint(doc, temp, "green", config.green);
|
||||
yyjson_mut_obj_add_uint(doc, temp, "yellow", config.yellow);
|
||||
|
||||
Reference in new issue
Block a user