Logo: move logo command line option parser to a separate file

Prepare for JSON config support
This commit is contained in:
李通洲
2023-03-10 17:49:03 +08:00
parent ae08966d40
commit e812380f20
10 changed files with 331 additions and 222 deletions
+4 -37
View File
@@ -16,25 +16,8 @@ static inline void ffUnused(int dummy, ...) { (void) dummy; }
#define FF_UNUSED(...) ffUnused(0, __VA_ARGS__);
#define FF_MAYBE_UNUSED __attribute__ ((__unused__))
#define FASTFETCH_LOGO_MAX_COLORS 9 //two digits would make parsing much more complicated (index 1 - 9)
#include "modules/options.h"
typedef enum FFLogoType
{
FF_LOGO_TYPE_AUTO, //if something is given, first try builtin, then file. Otherwise detect logo
FF_LOGO_TYPE_BUILTIN, //builtin ascii art
FF_LOGO_TYPE_FILE, //text file, printed with color code replacement
FF_LOGO_TYPE_FILE_RAW, //text file, printed as is
FF_LOGO_TYPE_DATA, //text data, printed with color code replacement
FF_LOGO_TYPE_DATA_RAW, //text data, printed as is
FF_LOGO_TYPE_IMAGE_SIXEL, //image file, printed as sixel codes.
FF_LOGO_TYPE_IMAGE_KITTY, //image file, printed as kitty graphics protocol
FF_LOGO_TYPE_IMAGE_ITERM, //image file, printed as iterm graphics protocol
FF_LOGO_TYPE_IMAGE_CHAFA, //image file, printed as ascii art using libchafa
FF_LOGO_TYPE_IMAGE_RAW, //image file, printed as raw binary string
FF_LOGO_TYPE_NONE, //--logo none
} FFLogoType;
#include "logo/option.h"
typedef enum FFSoundType
{
@@ -88,25 +71,7 @@ typedef enum FFLocalIpType
typedef struct FFconfig
{
struct
{
FFstrbuf source;
FFLogoType type;
FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
uint32_t width;
uint32_t height;
uint32_t paddingTop;
uint32_t paddingLeft;
uint32_t paddingRight;
bool printRemaining;
bool preserveAspectRadio;
bool chafaFgOnly;
FFstrbuf chafaSymbols;
uint32_t chafaCanvasMode;
uint32_t chafaColorSpace;
uint32_t chafaDitherMode;
} logo;
FFLogoOptions logo;
//If one of those is empty, ffLogoPrint will set them
FFstrbuf colorKeys;
@@ -230,6 +195,8 @@ typedef struct FFconfig
FFstrbuf playerName;
uint32_t percentType;
bool jsonConfig;
} FFconfig;
typedef struct FFstate