2022-10-18 22:55:28 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-01-20 14:10:13 +08:00
|
|
|
#include "util/FFstrbuf.h"
|
2024-02-26 15:12:04 +08:00
|
|
|
#include "common/parsing.h"
|
2024-05-08 15:25:59 +08:00
|
|
|
#include "common/option.h"
|
2022-10-18 22:55:28 +08:00
|
|
|
|
2024-05-24 10:19:58 +08:00
|
|
|
enum FFPercentageTypeFlags
|
2022-10-18 22:55:28 +08:00
|
|
|
{
|
2023-01-31 19:42:02 +08:00
|
|
|
FF_PERCENTAGE_TYPE_NUM_BIT = 1 << 0,
|
|
|
|
|
FF_PERCENTAGE_TYPE_BAR_BIT = 1 << 1,
|
|
|
|
|
FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT = 1 << 2,
|
|
|
|
|
FF_PERCENTAGE_TYPE_NUM_COLOR_BIT = 1 << 3,
|
2024-05-24 10:19:58 +08:00
|
|
|
FF_PERCENTAGE_TYPE_BAR_MONOCHROME_BIT = FF_PERCENTAGE_TYPE_NUM_COLOR_BIT,
|
2022-10-18 22:55:28 +08:00
|
|
|
};
|
|
|
|
|
|
2024-01-20 13:27:55 +08:00
|
|
|
// if (green <= yellow)
|
|
|
|
|
// [0, green]: print green
|
|
|
|
|
// (green, yellow]: print yellow
|
|
|
|
|
// (yellow, 100]: print red
|
|
|
|
|
//
|
|
|
|
|
// if (green > yellow)
|
|
|
|
|
// [green, 100]: print green
|
|
|
|
|
// [yellow, green): print yellow
|
|
|
|
|
// [0, yellow): print red
|
|
|
|
|
|
2024-05-08 15:25:59 +08:00
|
|
|
void ffPercentAppendBar(FFstrbuf* buffer, double percent, FFColorRangeConfig config, const FFModuleArgs* module);
|
|
|
|
|
void ffPercentAppendNum(FFstrbuf* buffer, double percent, FFColorRangeConfig config, bool parentheses, const FFModuleArgs* module);
|
2024-01-20 18:40:12 +08:00
|
|
|
|
|
|
|
|
typedef struct yyjson_val yyjson_val;
|
|
|
|
|
typedef struct yyjson_mut_doc yyjson_mut_doc;
|
|
|
|
|
typedef struct yyjson_mut_val yyjson_mut_val;
|
2024-02-26 15:12:04 +08:00
|
|
|
bool ffPercentParseCommandOptions(const char* key, const char* subkey, const char* value, FFColorRangeConfig* config);
|
|
|
|
|
bool ffPercentParseJsonObject(const char* key, yyjson_val* value, FFColorRangeConfig* config);
|
|
|
|
|
void ffPercentGenerateJsonConfig(yyjson_mut_doc* doc, yyjson_mut_val* module, FFColorRangeConfig defaultConfig, FFColorRangeConfig config);
|