Merge branch 'dev' into dev

This commit is contained in:
kojq
2022-12-21 15:20:20 -05:00
committed by GitHub
8 changed files with 106 additions and 8 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR BSD OR APPLE" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR BSD OR APPLE OR WIN32" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR BSD OR APPLE" OFF)
cmake_dependent_option(ENABLE_CHAFA "Enable chafa" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
cmake_dependent_option(ENABLE_ZLIB "Enable zlib" ON "ENABLE_IMAGEMAGICK6 OR ENABLE_IMAGEMAGICK7" OFF)
+4
View File
@@ -138,6 +138,9 @@ static void defaultConfig(FFinstance* instance)
instance->config.logo.paddingRight = 4;
instance->config.logo.printRemaining = true;
instance->config.logo.chafaFgOnly = false;
ffStrbufInitS(&instance->config.logo.chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
ffStrbufInit(&instance->config.colorKeys);
ffStrbufInit(&instance->config.colorTitle);
@@ -381,6 +384,7 @@ static void destroyModuleArg(FFModuleArgs* args)
static void destroyConfig(FFinstance* instance)
{
ffStrbufDestroy(&instance->config.logo.source);
ffStrbufDestroy(&instance->config.logo.chafaSymbols);
for(uint8_t i = 0; i < (uint8_t) FASTFETCH_LOGO_MAX_COLORS; ++i)
ffStrbufDestroy(&instance->config.logo.colors[i]);
ffStrbufDestroy(&instance->config.colorKeys);
+2
View File
@@ -38,6 +38,8 @@ Logo options:
--sixel <file>: Short for --logo-type sixel --logo <file>
--kitty <file>: Short for --logo-type kitty --logo <file>
--chafa <file>: Short for --logo-type chafa --logo <file>
--chafa-symbols <str>: Specify character symbols to employ in final output. See chafa document for detail
--chafa-fg-only <?value>: Produce character-cell output using foreground colors only. See chafa document for detail
Display options:
-s,--structure <structure>: Set the structure of the fetch. Must be a colon separated list of keys. Use "fastfetch --list-modules" to see the ones available.
+8
View File
@@ -1017,6 +1017,14 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
optionParseString(key, value, &instance->config.logo.source);
instance->config.logo.type = FF_LOGO_TYPE_IMAGE_CHAFA;
}
else if(strcasecmp(key, "--chafa-fg-only") == 0)
{
instance->config.logo.chafaFgOnly = optionParseBoolean(value);
}
else if(strcasecmp(key, "--chafa-symbols") == 0)
{
optionParseString(key, value, &instance->config.logo.chafaSymbols);
}
///////////////////
//Display options//
+3 -1
View File
@@ -75,6 +75,9 @@ typedef struct FFconfig
uint32_t paddingLeft;
uint32_t paddingRight;
bool printRemaining;
bool chafaFgOnly;
FFstrbuf chafaSymbols;
} logo;
//If one of those is empty, ffLogoPrint will set them
@@ -207,7 +210,6 @@ typedef struct FFstate
#endif
FFlist configDirs;
FFstrbuf cacheDir;
} FFstate;
typedef struct FFinstance
+40
View File
@@ -1726,6 +1726,45 @@ static const FFlogo* getLogoOpenSuseTumbleweed()
FF_LOGO_RETURN
}
static const FFlogo* getLogoOpenMandriva()
{
FF_LOGO_INIT
FF_LOGO_NAMES("openmandriva", "open-mandriva", "open_mandriva")
FF_LOGO_LINES(
" ``````\n"
" `-:/+++++++//:-.`\n"
" .:+++oooo+/:.`` ``\n"
" `:+ooooooo+:. `-:/++++++/:.`\n"
" -+oooooooo:` `-++o+/::::://+o+/-\n"
" `/ooooooooo- -+oo/.` `-/oo+.\n"
" `+ooooooooo. :os/` .+so:\n"
" +sssssssss/ :ss/ `+ss-\n"
" :ssssssssss` sss` .sso\n"
" ossssssssss `yyo sys\n"
"`sssssssssss` `yys `yys\n"
"`sssssssssss: +yy/ +yy:\n"
" oyyyyyyyyyys. `oyy/` `+yy+\n"
" :yyyyyyyyyyyo. `+yhs:. `./shy/\n"
" oyyyyyyyyyyys:` .oyhys+:----/+syhy+. `\n"
" `syyyyyyyyyyyyo-` .:osyhhhhhyys+:``.:`\n"
" `oyyyyyyyyyyyyys+-`` `.----.```./oo.\n"
" /yhhhhhhhhhhhhhhyso+//://+osyhy/`\n"
" `/yhhhhhhhhhhhhhhhhhhhhhhhhy/`\n"
" `:oyhhhhhhhhhhhhhhhhhhyo:`\n"
" .:+syhhhhhhhhys+:-`\n"
" ``....``"
)
FF_LOGO_COLORS(
"34" //blue
)
FF_LOGO_COLOR_KEYS("34"); //blue
FF_LOGO_COLOR_TITLE("34"); //blue
FF_LOGO_RETURN
}
static const FFlogo* getLogoPop()
{
FF_LOGO_INIT
@@ -2353,6 +2392,7 @@ GetLogoMethod* ffLogoBuiltinGetAll()
getLogoOpenSuseSmall,
getLogoOpenSuseLeap,
getLogoOpenSuseTumbleweed,
getLogoOpenMandriva,
getLogoPop,
getLogoPopSmall,
getLogoParabola,
+5 -1
View File
@@ -14,7 +14,11 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex
FFLogoImageResult ffLogoPrintImageIM7(FFinstance* instance, FFLogoRequestData* requestData)
{
FF_LIBRARY_LOAD(imageMagick, &instance->config.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-7.Q16HDRI" FF_LIBRARY_EXTENSION, 11, "libMagickCore-7.Q16" FF_LIBRARY_EXTENSION, 11)
FF_LIBRARY_LOAD(imageMagick, &instance->config.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR,
"libMagickCore-7.Q16HDRI" FF_LIBRARY_EXTENSION, 11,
"libMagickCore-7.Q16" FF_LIBRARY_EXTENSION, 11,
"libMagickCore-7.Q16HDRI-10" FF_LIBRARY_EXTENSION, -1 // Required for Windows
)
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(imageMagick, ffResizeImage, ResizeImage, FF_LOGO_IMAGE_RESULT_INIT_ERROR);
FFIMData imData;
+43 -5
View File
@@ -24,7 +24,12 @@
static inline char* realpath(const char* restrict file_name, char* restrict resolved_name)
{
return _fullpath(resolved_name, file_name, _MAX_PATH);
char* result = _fullpath(resolved_name, file_name, _MAX_PATH);
if(result)
{
resolved_name[1] = resolved_name[0]; // Drive Name
resolved_name[0] = '/';
}
}
#endif
@@ -226,19 +231,30 @@ static bool printImageKitty(FFinstance* instance, FFLogoRequestData* requestData
#include <chafa.h>
static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData, const ImageData* imageData)
{
FF_LIBRARY_LOAD(chafa, &instance->config.libChafa, false, "libchafa" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD(chafa, &instance->config.libChafa, false,
"libchafa" FF_LIBRARY_EXTENSION, 1,
"libchafa-0" FF_LIBRARY_EXTENSION, -1 // Required for Windows
)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_symbol_map_new, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_symbol_map_add_by_tags, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_symbol_map_apply_selectors, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_new, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_set_geometry, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_set_symbol_map, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_set_color_space, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_set_canvas_mode, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_set_fg_only_enabled, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_new, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_draw_all_pixels, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_print, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_unref, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_canvas_config_unref, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, chafa_symbol_map_unref, false)
#ifndef _WIN32
// FIXME: These functions must be imported from `libglib` dlls. Leak them for now
FF_LIBRARY_LOAD_SYMBOL(chafa, g_string_free, false)
FF_LIBRARY_LOAD_SYMBOL(chafa, g_error_free, false)
#endif
imageData->ffCopyMagickString(imageData->imageInfo->magick, "RGBA", 5);
size_t length;
@@ -250,11 +266,17 @@ static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData
}
ChafaSymbolMap* symbolMap = ffchafa_symbol_map_new();
ffchafa_symbol_map_add_by_tags(symbolMap, CHAFA_SYMBOL_TAG_ALL);
GError* error = NULL;
if(!ffchafa_symbol_map_apply_selectors(symbolMap, instance->config.logo.chafaSymbols.chars, &error))
fputs(error->message, stderr);
ChafaCanvasConfig* canvasConfig = ffchafa_canvas_config_new();
ffchafa_canvas_config_set_geometry(canvasConfig, (gint) requestData->logoCharacterWidth, (gint) requestData->logoCharacterHeight);
ffchafa_canvas_config_set_symbol_map(canvasConfig, symbolMap);
ffchafa_canvas_config_set_color_space(canvasConfig, CHAFA_COLOR_SPACE_DIN99D);
ffchafa_canvas_config_set_canvas_mode(canvasConfig, CHAFA_CANVAS_MODE_TRUECOLOR);
// ffchafa_canvas_config_set_fg_only_enabled(canvasConfig, instance->config.logo.chafaFgOnly);
// TODO: expose more chafa configs to fastfetch flags
ChafaCanvas* canvas = ffchafa_canvas_new(canvasConfig);
ffchafa_canvas_draw_all_pixels(
@@ -275,7 +297,11 @@ static bool printImageChafa(FFinstance* instance, FFLogoRequestData* requestData
ffLogoPrintChars(instance, result.chars, false);
writeCacheStrbuf(requestData, &result, FF_CACHE_FILE_CHAFA);
#ifndef _WIN32
ffg_string_free(str, TRUE);
ffg_error_free(error);
#endif
ffchafa_canvas_unref(canvas);
ffchafa_canvas_config_unref(canvasConfig);
ffchafa_symbol_map_unref(symbolMap);
@@ -566,7 +592,19 @@ bool ffLogoPrintImageIfExists(FFinstance* instance, FFLogoType type)
requestData.logoPixelHeight = simpleCeil((double) instance->config.logo.height * requestData.characterPixelHeight);
ffStrbufInitA(&requestData.cacheDir, PATH_MAX * 2);
ffStrbufAppend(&requestData.cacheDir, &instance->state.cacheDir);
#if !(defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__))
ffStrbufAppendS(&requestData.cacheDir, getenv("XDG_CACHE_HOME"));
#endif
if(requestData.cacheDir.length == 0)
{
ffStrbufAppendS(&requestData.cacheDir, instance->state.passwd->pw_dir);
ffStrbufAppendS(&requestData.cacheDir, "/.cache/");
}
else
ffStrbufEnsureEndsWithC(&requestData.cacheDir, '/');
ffStrbufAppendS(&requestData.cacheDir, "images");
ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX);