ohmu
·
2026-10-15
1#pragma once
2
3#include "common/ffdata.h"
4
5#define FASTFETCH_LOGO_MAX_NAMES 9
6#define FASTFETCH_LOGO_MAX_COLORS 9 // two digits would make parsing much more complicated (index 1 - 9)
7
8typedef enum FFLogoType: uint8_t {
9 FF_LOGO_TYPE_AUTO, // if something is given, first try builtin, then file. Otherwise detect logo
10 FF_LOGO_TYPE_BUILTIN, // builtin ascii art
11 FF_LOGO_TYPE_SMALL, // builtin ascii art, small version
12 FF_LOGO_TYPE_FILE, // text file, printed with color code replacement
13 FF_LOGO_TYPE_FILE_RAW, // text file, printed as is
14 FF_LOGO_TYPE_DATA, // text data, printed with color code replacement
15 FF_LOGO_TYPE_DATA_RAW, // text data, printed as is
16 FF_LOGO_TYPE_COMMAND_RAW, // command to generate text data, printed as is
17 FF_LOGO_TYPE_IMAGE_SIXEL, // image file, printed as sixel codes
18 FF_LOGO_TYPE_IMAGE_KITTY, // image file, printed as kitty graphics protocol
19 FF_LOGO_TYPE_IMAGE_KITTY_DIRECT, // image file, tell the terminal emulator to read image data from the specified file (Supported by kitty and wezterm)
20 FF_LOGO_TYPE_IMAGE_KITTY_ICAT, // image file, use `kitten icat` to display the image. Requires binary `kitten` to be installed"
21 FF_LOGO_TYPE_IMAGE_ITERM, // image file, printed as iterm graphics protocol
22 FF_LOGO_TYPE_IMAGE_CHAFA, // image file, printed as ascii art using libchafa
23 FF_LOGO_TYPE_IMAGE_RAW, // image file, printed as raw binary string
24 FF_LOGO_TYPE_NONE, // `--logo none`, but still applies colors to the system information output (unless `--pipe` is set)
25} FFLogoType;
26
27typedef enum FFLogoPosition: uint8_t {
28 FF_LOGO_POSITION_LEFT,
29 FF_LOGO_POSITION_TOP,
30 FF_LOGO_POSITION_RIGHT,
31 FF_LOGO_POSITION_AUTO,
32} FFLogoPosition;
33
34typedef enum FFLogoCacheStrategy: uint8_t {
35 FF_LOGO_CACHE_ON, // reuse a cached rendering when it is valid, and write it back on a cache miss
36 FF_LOGO_CACHE_OFF, // ignore the image logo cache completely: neither read nor write it
37 FF_LOGO_CACHE_REGEN, // ignore any existing cached rendering and regenerate it
38} FFLogoCacheStrategy;
39
40// Which frame of the image source to render. 0 is the only value that prints an animation; the
41// others all produce a static image, which keeps the default (1, the first frame) byte-identical
42// to the behaviour before animations existed.
43#define FF_LOGO_ANIMATION_FRAME_FIRST 1
44#define FF_LOGO_ANIMATION_FRAME_ANIMATE 0
45
46typedef struct FFOptionsLogo {
47 FFstrbuf source;
48 FFLogoType type;
49 FFLogoPosition position;
50 FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
51 uint32_t width;
52 uint32_t height;
53 uint32_t paddingTop;
54 uint32_t paddingLeft;
55 uint32_t paddingRight;
56 uint32_t paddingBottom;
57 bool printRemaining;
58 bool preserveAspectRatio;
59 FFLogoCacheStrategy cache;
60 // 0 = animate, N > 0 = the N-th frame (1-based), N < 0 = the |N|-th frame from the end.
61 // Kept as given by the user: the cache entry name is built from it before the frame count
62 // is known, and negative values stay meaningful across runs (see image.c).
63 int32_t animationFrame;
64
65#if FF_HAVE_CHAFA
66 bool chafaFgOnly;
67 FFstrbuf chafaSymbols;
68 uint32_t chafaCanvasMode;
69 uint32_t chafaColorSpace;
70 uint32_t chafaDitherMode;
71#endif
72} FFOptionsLogo;
73
74const char* ffLogoPositionToString(FFLogoPosition position);
75void ffOptionsInitLogo(FFOptionsLogo* options);
76bool ffOptionsParseLogoCommandLine(FFOptionsLogo* options, const char* key, const char* value);
77void ffOptionsDestroyLogo(FFOptionsLogo* options);
78const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* root, yyjson_val** pkey);
79void ffOptionsGenerateLogoJsonConfig(FFdata* data, FFOptionsLogo* options);