Files
fastfetch/src/fastfetch.h
T

125 lines
2.6 KiB
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#pragma once
#ifndef FASTFETCH_INCLUDED
#define FASTFETCH_INCLUDED
2022-06-18 14:25:31 +02:00
#include "fastfetch_config.h"
2021-02-18 22:25:36 +01:00
#include <stdint.h>
#include <stdbool.h>
2023-08-14 20:00:04 +08:00
2023-08-19 11:10:14 +08:00
#ifdef FF_USE_SYSTEM_YYJSON
#include <yyjson.h>
#else
#include "3rdparty/yyjson/yyjson.h"
#endif
2022-06-18 14:25:31 +02:00
2023-09-26 20:09:41 +08:00
#ifdef _MSC_VER
#define __attribute__(x)
#endif
2021-03-19 20:57:07 +01:00
#include "util/FFstrbuf.h"
2021-04-24 13:05:43 +02:00
#include "util/FFlist.h"
2023-01-15 15:57:26 +01:00
#include "util/platform/FFPlatform.h"
2023-07-25 16:01:38 +08:00
#include "util/unused.h"
2021-04-09 14:07:05 +02:00
2023-10-25 15:38:46 +08:00
#include "options/modules.h"
#include "options/logo.h"
#include "options/general.h"
2023-10-25 16:24:24 +08:00
#include "options/library.h"
2021-11-09 15:14:25 +01:00
2022-08-26 16:02:04 +02:00
typedef enum FFBinaryPrefixType
{
FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard)
FF_BINARY_PREFIX_TYPE_SI, // 1000 Bytes = 1 KB, 1000 KB = 1 MB, ...
FF_BINARY_PREFIX_TYPE_JEDEC, // 1024 Bytes = 1 kB, 1024 K = 1 MB, ...
} FFBinaryPrefixType;
typedef enum FFTemperatureUnit
{
FF_TEMPERATURE_UNIT_CELSIUS,
FF_TEMPERATURE_UNIT_FAHRENHEIT,
FF_TEMPERATURE_UNIT_KELVIN,
} FFTemperatureUnit;
2021-02-27 18:30:05 +01:00
typedef struct FFconfig
2021-02-18 22:25:36 +01:00
{
2023-10-25 14:43:46 +08:00
FFOptionsLogo logo;
FFOptionsGeneral general;
2023-10-25 15:38:46 +08:00
FFOptionsModules modules;
2021-06-13 14:23:35 +02:00
2022-09-07 19:50:10 +02:00
//If one of those is empty, ffLogoPrint will set them
FFstrbuf colorKeys;
FFstrbuf colorTitle;
2023-08-04 16:05:25 +08:00
bool brightColor;
FFstrbuf keyValueSeparator;
2022-04-02 14:35:43 +02:00
bool stat;
bool pipe; //disables logo and all escape sequences
2021-02-19 16:23:41 +01:00
bool showErrors;
2021-06-17 13:49:25 +02:00
bool disableLinewrap;
bool hideCursor;
2022-08-26 16:02:04 +02:00
FFBinaryPrefixType binaryPrefixType;
uint8_t sizeNdigits;
uint8_t sizeMaxPrefix;
FFTemperatureUnit temperatureUnit;
FFstrbuf barCharElapsed;
FFstrbuf barCharTotal;
2023-08-16 16:46:21 +08:00
uint8_t barWidth;
bool barBorder;
2023-08-24 09:35:17 +08:00
uint8_t percentType;
uint8_t percentNdigits;
2023-06-13 11:08:49 +08:00
bool noBuffer;
2023-08-15 17:10:09 +08:00
uint32_t keyWidth;
2021-03-03 21:03:12 +01:00
2023-10-25 16:24:24 +08:00
FFOptionsLibrary library;
2021-02-27 18:30:05 +01:00
} FFconfig;
2021-02-19 16:23:41 +01:00
2021-06-20 21:04:55 +02:00
typedef struct FFstate
{
2022-04-06 14:02:05 +02:00
uint32_t logoWidth;
2022-04-02 14:35:43 +02:00
uint32_t logoHeight;
uint32_t keysHeight;
2021-06-20 21:04:55 +02:00
2023-01-15 15:57:26 +01:00
FFPlatform platform;
2023-06-10 21:34:41 +08:00
yyjson_doc* configDoc;
2023-08-29 11:13:55 +08:00
yyjson_mut_doc* resultDoc;
yyjson_mut_doc* migrateConfigDoc;
2021-06-20 21:04:55 +02:00
} FFstate;
typedef struct FFinstance
{
FFconfig config;
FFstate state;
} FFinstance;
extern FFinstance instance; // Defined in `common/init.c`
extern FFModuleBaseInfo** ffModuleInfos[];
2021-06-20 21:04:55 +02:00
2022-04-02 14:35:43 +02:00
//////////////////////
2022-07-25 15:01:11 +02:00
// Init functions //
2022-04-02 14:35:43 +02:00
//////////////////////
2021-04-09 14:07:05 +02:00
//common/init.c
void ffInitInstance();
void ffStart();
void ffFinish();
void ffDestroyInstance();
2021-04-09 14:07:05 +02:00
2022-02-13 23:51:13 +01:00
void ffListFeatures();
2022-04-02 14:35:43 +02:00
////////////////////
// Logo functions //
////////////////////
void ffLogoPrint();
void ffLogoPrintRemaining();
void ffLogoPrintLine();
2022-04-02 14:35:43 +02:00
void ffLogoBuiltinPrint();
2022-06-08 10:59:33 +02:00
void ffLogoBuiltinList();
void ffLogoBuiltinListAutocompletion();
2022-04-02 14:35:43 +02:00
2021-03-27 18:14:19 +01:00
#endif