master ohmu/fastfetch-openbsd / src / options / display.h
ohmu  ·  2026-10-15
 1#pragma once
 2
 3#include "common/ffdata.h"
 4#include "common/percent.h"
 5#include "common/FFstrbuf.h"
 6#include "common/FFlist.h"
 7
 8typedef enum FFSizeBinaryPrefixType: uint8_t {
 9    FF_SIZE_BINARY_PREFIX_TYPE_IEC,   // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard)
10    FF_SIZE_BINARY_PREFIX_TYPE_SI,    // 1000 Bytes = 1 kB, 1000 kB = 1 MB, ...
11    FF_SIZE_BINARY_PREFIX_TYPE_JEDEC, // 1024 Bytes = 1 KB, 1024 KB = 1 MB, ...
12} FFSizeBinaryPrefixType;
13
14typedef enum FFTemperatureUnit: uint8_t {
15    FF_TEMPERATURE_UNIT_DEFAULT,
16    FF_TEMPERATURE_UNIT_CELSIUS,
17    FF_TEMPERATURE_UNIT_FAHRENHEIT,
18    FF_TEMPERATURE_UNIT_KELVIN,
19} FFTemperatureUnit;
20
21typedef enum FFSpaceBeforeUnitType: uint8_t {
22    FF_SPACE_BEFORE_UNIT_DEFAULT,
23    FF_SPACE_BEFORE_UNIT_ALWAYS,
24    FF_SPACE_BEFORE_UNIT_NEVER,
25} FFSpaceBeforeUnitType;
26
27typedef enum FFFractionTrailingZerosType: uint8_t {
28    FF_FRACTION_TRAILING_ZEROS_TYPE_DEFAULT,
29    FF_FRACTION_TRAILING_ZEROS_TYPE_ALWAYS,
30    FF_FRACTION_TRAILING_ZEROS_TYPE_NEVER,
31} FFFractionTrailingZerosType;
32
33typedef struct FFOptionsDisplay {
34    // If one of those is empty, ffLogoPrint will set them
35    FFstrbuf colorKeys;
36    FFstrbuf colorTitle;
37    FFstrbuf colorOutput;
38    FFstrbuf colorSeparator;
39
40    bool brightColor;
41
42    FFstrbuf keyValueSeparator;
43
44    int32_t stat; // <0: disable stat; 0: no threshold; >0: threshold in ms
45    bool pipe;    // disables all escape sequences
46    bool showErrors;
47#ifndef NDEBUG
48    bool debugMode;
49#endif
50    bool disableLinewrap;
51    bool durationAbbreviation;
52    FFSpaceBeforeUnitType durationSpaceBeforeUnit;
53    bool hideCursor;
54    FFSizeBinaryPrefixType sizeBinaryPrefix;
55    uint8_t sizeNdigits;
56    uint8_t sizeMaxPrefix;
57    FFSpaceBeforeUnitType sizeSpaceBeforeUnit;
58    FFTemperatureUnit tempUnit;
59    uint8_t tempNdigits;
60    FFstrbuf tempColorGreen;
61    FFstrbuf tempColorYellow;
62    FFstrbuf tempColorRed;
63    FFSpaceBeforeUnitType tempSpaceBeforeUnit;
64    FFstrbuf barCharElapsed;
65    FFstrbuf barCharTotal;
66    FFstrbuf barBorderLeft;
67    FFstrbuf barBorderRight;
68    FFstrbuf barBorderLeftElapsed;
69    FFstrbuf barBorderRightElapsed;
70    FFstrbuf barColorElapsed; // "auto" for auto selection from percent config; empty for no custom color (inherits)
71    FFstrbuf barColorTotal;   // empty for no custom color (inherits)
72    FFstrbuf barColorBorder;  // empty for no custom color (inherits)
73    uint8_t barWidth;
74    FFPercentageTypeFlags percentType;
75    uint8_t percentNdigits;
76    FFstrbuf percentColorGreen;
77    FFstrbuf percentColorYellow;
78    FFstrbuf percentColorRed;
79    FFSpaceBeforeUnitType percentSpaceBeforeUnit;
80    uint8_t percentWidth;
81    bool noBuffer;
82    FFModuleKeyType keyType;
83    uint32_t keyLanguage; // Offset of FFModuleDisplayName member
84    uint16_t keyWidth;
85    uint16_t keyPaddingLeft;
86    int8_t freqNdigits;
87    FFSpaceBeforeUnitType freqSpaceBeforeUnit;
88    int8_t fractionNdigits;
89    FFFractionTrailingZerosType fractionTrailingZeros;
90
91    FFlist constants; // list of FFstrbuf
92} FFOptionsDisplay;
93
94const char* ffOptionsParseDisplayJsonConfig(FFOptionsDisplay* options, yyjson_val* root, yyjson_val** pkey);
95bool ffOptionsParseDisplayCommandLine(FFOptionsDisplay* options, const char* key, const char* value);
96void ffOptionsInitDisplay(FFOptionsDisplay* options);
97void ffOptionsDestroyDisplay(FFOptionsDisplay* options);
98void ffOptionsGenerateDisplayJsonConfig(FFdata* data, FFOptionsDisplay* options);