2021-02-18 22:25:36 +01:00
#pragma once
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"
2023-10-25 10:44:34 +08:00
#include "options/logo.h"
2023-10-26 10:26:15 +08:00
#include "options/display.h"
2023-10-25 13:39:13 +08:00
#include "options/general.h"
2021-11-09 15:14:25 +01:00
2024-10-18 21:07:50 +08:00
#ifdef __has_builtin
#if __has_builtin(__builtin_types_compatible_p)
2024-10-25 14:48:11 +08:00
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
2024-10-18 21:07:50 +08:00
#endif
#endif
#ifndef ARRAY_SIZE
2024-10-25 14:48:11 +08:00
#define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x))))
2024-10-18 16:15:48 +08:00
#endif
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 ;
2023-10-26 10:26:15 +08:00
FFOptionsDisplay display ;
2023-10-25 14:37:48 +08:00
FFOptionsGeneral general ;
2023-10-25 15:38:46 +08:00
FFOptionsModules modules ;
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 ;
2024-06-04 14:23:30 +08:00
bool terminalLightTheme ;
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 ;
2023-11-10 15:47:09 +08:00
FFstrbuf genConfigPath ;
2021-06-20 21:04:55 +02:00
} FFstate ;
typedef struct FFinstance
{
FFconfig config ;
FFstate state ;
} FFinstance ;
2023-06-24 10:59:53 +08:00
extern FFinstance instance ; // Defined in `common/init.c`
2023-08-20 20:51:55 +08:00
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
2023-06-24 10:59:53 +08:00
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 //
////////////////////
2023-06-24 10:59:53 +08:00
void ffLogoPrint ();
void ffLogoPrintRemaining ();
void ffLogoPrintLine ();
2022-04-02 14:35:43 +02:00
2023-06-24 10:59:53 +08:00
void ffLogoBuiltinPrint ();
2022-06-08 10:59:33 +02:00
void ffLogoBuiltinList ();
void ffLogoBuiltinListAutocompletion ();