Skip to content

Commit 5147651

Browse files
committed
Temps: rename display.temperature to display.temp
1 parent ba60d90 commit 5147651

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# 2.8.6
22

33
Changes:
4-
* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temperature": { "unit": "C" } }`
4+
* Due to newly introduced configs, JSONC option `{ "temperatureUnit": "C" }` has been changed to `{ "temp": { "unit": "C" } }`
55

66
Bugfixes:
77
* Fix incorrect GPU name detection for Intel iGPU on Linux (#736, GPU, Linux)
88

99
Features:
1010
* Support additional temperature formatting options (#737)
11-
* `{ "temperature": { "ndigits": 1 } }`
12-
* `{ "temperature": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
11+
* `{ "temp": { "ndigits": 1 } }`
12+
* `{ "temp": { "color": { "green": "green", "yellow": "yellow", "red": "red" } } }`
1313

1414
# 2.8.5
1515

doc/json_schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
"type": "integer",
6060
"minimum": 0,
6161
"maximum": 100,
62-
"description": "Value less then green will be shown in green"
62+
"description": "Value (in celsius) less then green will be shown in green"
6363
},
6464
"yellow": {
6565
"type": "integer",
6666
"minimum": 0,
6767
"maximum": 100,
68-
"description": "Value greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
68+
"description": "Value (in celsius) greater than green and less then yellow will be shown in yellow.\nValue greater than yellow will be shown in red"
6969
}
7070
}
7171
}
@@ -433,9 +433,9 @@
433433
}
434434
}
435435
},
436-
"temperature": {
436+
"temp": {
437437
"type": "object",
438-
"description": "Set how a temperature value should be displayed",
438+
"description": "Set how temperature values should be displayed",
439439
"properties": {
440440
"unit": {
441441
"type": "string",

src/common/temps.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
99
return;
1010

1111
const FFOptionsDisplay* options = &instance.config.display;
12-
const char* colorGreen = options->temperatureColorGreen.chars;
13-
const char* colorYellow = options->temperatureColorYellow.chars;
14-
const char* colorRed = options->temperatureColorRed.chars;
12+
const char* colorGreen = options->tempColorGreen.chars;
13+
const char* colorYellow = options->tempColorYellow.chars;
14+
const char* colorRed = options->tempColorRed.chars;
1515

1616
uint8_t green = config.green, yellow = config.yellow;
1717

@@ -40,13 +40,13 @@ void ffTempsAppendNum(double celsius, FFstrbuf* buffer, FFColorRangeConfig confi
4040
switch (options->temperatureUnit)
4141
{
4242
case FF_TEMPERATURE_UNIT_CELSIUS:
43-
ffStrbufAppendF(buffer, "%.*f°C", options->temperatureNdigits, celsius);
43+
ffStrbufAppendF(buffer, "%.*f°C", options->tempNdigits, celsius);
4444
break;
4545
case FF_TEMPERATURE_UNIT_FAHRENHEIT:
46-
ffStrbufAppendF(buffer, "%.*f°F", options->temperatureNdigits, celsius * 1.8 + 32);
46+
ffStrbufAppendF(buffer, "%.*f°F", options->tempNdigits, celsius * 1.8 + 32);
4747
break;
4848
case FF_TEMPERATURE_UNIT_KELVIN:
49-
ffStrbufAppendF(buffer, "%.*f K", options->temperatureNdigits, celsius + 273.15);
49+
ffStrbufAppendF(buffer, "%.*f K", options->tempNdigits, celsius + 273.15);
5050
break;
5151
}
5252

src/data/help.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@
656656
}
657657
},
658658
{
659-
"long": "temperature-unit",
659+
"long": "temp-unit",
660660
"desc": "Set the unit of the temperature",
661661
"arg": {
662662
"type": "enum",
@@ -669,15 +669,15 @@
669669
}
670670
},
671671
{
672-
"long": "temperature-ndigits",
672+
"long": "temp-ndigits",
673673
"desc": "Set the number of digits to keep after the decimal point when printing temperature",
674674
"arg": {
675675
"type": "num",
676676
"default": 2
677677
}
678678
},
679679
{
680-
"long": "temperature-color-green",
680+
"long": "temp-color-green",
681681
"desc": "Set color used in green state of temperature values",
682682
"remark": "See `-h color` for the list of available colors",
683683
"arg": {
@@ -686,7 +686,7 @@
686686
}
687687
},
688688
{
689-
"long": "temperature-color-yellow",
689+
"long": "temp-color-yellow",
690690
"desc": "Set color used in yellow state of temperature values",
691691
"remark": "See `-h color` for the list of available colors",
692692
"arg": {
@@ -695,7 +695,7 @@
695695
}
696696
},
697697
{
698-
"long": "temperature-color-red",
698+
"long": "temp-color-red",
699699
"desc": "Set color used in red state of temperature values",
700700
"remark": "See `-h color` for the list of available colors",
701701
"arg": {

src/options/display.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
9494
yyjson_val* ndigits = yyjson_obj_get(val, "ndigits");
9595
if (ndigits) options->percentNdigits = (uint8_t) yyjson_get_uint(ndigits);
9696
}
97-
else if (ffStrEqualsIgnCase(key, "temperature"))
97+
else if (ffStrEqualsIgnCase(key, "temp"))
9898
{
9999
if (!yyjson_is_obj(val))
100-
return "display.temperature must be an object";
100+
return "display.temp must be an object";
101101

102102
yyjson_val* unit = yyjson_obj_get(val, "unit");
103103
if (unit)
@@ -117,7 +117,7 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
117117
}
118118

119119
yyjson_val* ndigits = yyjson_obj_get(val, "ndigits");
120-
if (ndigits) options->temperatureNdigits = (uint8_t) yyjson_get_uint(ndigits);
120+
if (ndigits) options->tempNdigits = (uint8_t) yyjson_get_uint(ndigits);
121121

122122
yyjson_val* color = yyjson_obj_get(val, "color");
123123
if (color)
@@ -126,13 +126,13 @@ const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_va
126126
return "display.temperature.color must be an object";
127127

128128
yyjson_val* green = yyjson_obj_get(color, "green");
129-
if (green) ffOptionParseColor(yyjson_get_str(green), &options->temperatureColorGreen);
129+
if (green) ffOptionParseColor(yyjson_get_str(green), &options->tempColorGreen);
130130

131131
yyjson_val* yellow = yyjson_obj_get(color, "yellow");
132-
if (yellow) ffOptionParseColor(yyjson_get_str(yellow), &options->temperatureColorYellow);
132+
if (yellow) ffOptionParseColor(yyjson_get_str(yellow), &options->tempColorYellow);
133133

134134
yyjson_val* red = yyjson_obj_get(color, "red");
135-
if (red) ffOptionParseColor(yyjson_get_str(red), &options->temperatureColorRed);
135+
if (red) ffOptionParseColor(yyjson_get_str(red), &options->tempColorRed);
136136
}
137137
}
138138
else if (ffStrEqualsIgnCase(key, "percent"))
@@ -295,13 +295,13 @@ bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key
295295
});
296296
}
297297
else if (ffStrEqualsIgnCase(subkey, "ndigits"))
298-
options->temperatureNdigits = (uint8_t) ffOptionParseUInt32(key, value);
298+
options->tempNdigits = (uint8_t) ffOptionParseUInt32(key, value);
299299
else if(ffStrEqualsIgnCase(subkey, "color-green"))
300-
ffOptionParseColor(value, &options->temperatureColorGreen);
300+
ffOptionParseColor(value, &options->tempColorGreen);
301301
else if(ffStrEqualsIgnCase(subkey, "color-yellow"))
302-
ffOptionParseColor(value, &options->temperatureColorYellow);
302+
ffOptionParseColor(value, &options->tempColorYellow);
303303
else if(ffStrEqualsIgnCase(subkey, "color-red"))
304-
ffOptionParseColor(value, &options->temperatureColorRed);
304+
ffOptionParseColor(value, &options->tempColorRed);
305305
else
306306
return false;
307307
}
@@ -368,10 +368,10 @@ void ffOptionsInitDisplay(FFOptionsDisplay* options)
368368
options->keyWidth = 0;
369369

370370
options->temperatureUnit = FF_TEMPERATURE_UNIT_CELSIUS;
371-
options->temperatureNdigits = 1;
372-
ffStrbufInitStatic(&options->temperatureColorGreen, FF_COLOR_FG_GREEN);
373-
ffStrbufInitStatic(&options->temperatureColorYellow, FF_COLOR_FG_LIGHT_YELLOW);
374-
ffStrbufInitStatic(&options->temperatureColorRed, FF_COLOR_FG_LIGHT_RED);
371+
options->tempNdigits = 1;
372+
ffStrbufInitStatic(&options->tempColorGreen, FF_COLOR_FG_GREEN);
373+
ffStrbufInitStatic(&options->tempColorYellow, FF_COLOR_FG_LIGHT_YELLOW);
374+
ffStrbufInitStatic(&options->tempColorRed, FF_COLOR_FG_LIGHT_RED);
375375

376376
ffStrbufInitStatic(&options->barCharElapsed, "■");
377377
ffStrbufInitStatic(&options->barCharTotal, "-");
@@ -492,21 +492,21 @@ void ffOptionsGenerateDisplayJsonConfig(FFOptionsDisplay* options, yyjson_mut_do
492492
break;
493493
}
494494
}
495-
if (options->temperatureNdigits != defaultOptions.temperatureNdigits)
496-
yyjson_mut_obj_add_uint(doc, temperature, "ndigits", options->temperatureNdigits);
495+
if (options->tempNdigits != defaultOptions.tempNdigits)
496+
yyjson_mut_obj_add_uint(doc, temperature, "ndigits", options->tempNdigits);
497497
{
498498
yyjson_mut_val* color = yyjson_mut_obj(doc);
499-
if (!ffStrbufEqual(&options->temperatureColorGreen, &defaultOptions.temperatureColorGreen))
500-
yyjson_mut_obj_add_strbuf(doc, color, "green", &options->temperatureColorGreen);
501-
if (!ffStrbufEqual(&options->temperatureColorYellow, &defaultOptions.temperatureColorYellow))
502-
yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->temperatureColorYellow);
503-
if (!ffStrbufEqual(&options->temperatureColorRed, &defaultOptions.temperatureColorRed))
504-
yyjson_mut_obj_add_strbuf(doc, color, "red", &options->temperatureColorRed);
499+
if (!ffStrbufEqual(&options->tempColorGreen, &defaultOptions.tempColorGreen))
500+
yyjson_mut_obj_add_strbuf(doc, color, "green", &options->tempColorGreen);
501+
if (!ffStrbufEqual(&options->tempColorYellow, &defaultOptions.tempColorYellow))
502+
yyjson_mut_obj_add_strbuf(doc, color, "yellow", &options->tempColorYellow);
503+
if (!ffStrbufEqual(&options->tempColorRed, &defaultOptions.tempColorRed))
504+
yyjson_mut_obj_add_strbuf(doc, color, "red", &options->tempColorRed);
505505
if (yyjson_mut_obj_size(color) > 0)
506506
yyjson_mut_obj_add_val(doc, temperature, "color", color);
507507
}
508508
if (yyjson_mut_obj_size(temperature) > 0)
509-
yyjson_mut_obj_add_val(doc, obj, "temperature", temperature);
509+
yyjson_mut_obj_add_val(doc, obj, "temp", temperature);
510510
}
511511

512512
{

src/options/display.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ typedef struct FFOptionsDisplay
3535
uint8_t sizeNdigits;
3636
uint8_t sizeMaxPrefix;
3737
FFTemperatureUnit temperatureUnit;
38-
uint8_t temperatureNdigits;
39-
FFstrbuf temperatureColorGreen;
40-
FFstrbuf temperatureColorYellow;
41-
FFstrbuf temperatureColorRed;
38+
uint8_t tempNdigits;
39+
FFstrbuf tempColorGreen;
40+
FFstrbuf tempColorYellow;
41+
FFstrbuf tempColorRed;
4242
FFstrbuf barCharElapsed;
4343
FFstrbuf barCharTotal;
4444
uint8_t barWidth;

0 commit comments

Comments
 (0)