mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Logo: add kitty-direct protocol
This commit is contained in:
@@ -32,6 +32,11 @@ Bugfixes:
|
||||
* Fix false errors when built without libnm support (Wifi, Linux)
|
||||
* Properly detect CPU on POWER (CPU, Linux)
|
||||
|
||||
Logo:
|
||||
* Change the special handling of `kitty` protocol with `.png` image file to a new image protocol `kitty-direct`. This is the fastest image protocol because fastfetch doesn't need to pre-encode the image to base64 or something and the image content doesn't need to be transmitted via tty. Note:
|
||||
1. Although konsole was said to support `kitty` image protocol, it doesn't support `kitty-direct`
|
||||
2. wezterm support more image formats other than `.png` (tested with `.jpg` and `.webp`)
|
||||
|
||||
# 1.12.2
|
||||
|
||||
Features:
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
"data-raw",
|
||||
"sixel",
|
||||
"kitty",
|
||||
"kitty-direct",
|
||||
"iterm",
|
||||
"chafa",
|
||||
"raw",
|
||||
|
||||
@@ -68,9 +68,14 @@ static bool printImageIterm(void)
|
||||
|
||||
static bool printImageKittyDirect(void)
|
||||
{
|
||||
if (!instance.config.logo.width || !instance.config.logo.height)
|
||||
{
|
||||
fputs("Logo: `kitty-direct` protocol only works when both `--logo-width` and `--logo-height` being specified\n", stderr);
|
||||
return false;
|
||||
}
|
||||
ffPrintCharTimes(' ', instance.config.logo.paddingLeft);
|
||||
ffPrintCharTimes('\n', instance.config.logo.paddingTop);
|
||||
FFstrbuf base64 = base64Encode(&instance.config.logo.source);
|
||||
FF_STRBUF_AUTO_DESTROY base64 = base64Encode(&instance.config.logo.source);
|
||||
printf("\033_Ga=T,f=100,t=f,c=%u,r=%u,C=1;%s\033\\\033[9999999D",
|
||||
(unsigned) instance.config.logo.width,
|
||||
(unsigned) instance.config.logo.height,
|
||||
@@ -80,8 +85,6 @@ static bool printImageKittyDirect(void)
|
||||
instance.state.logoWidth = instance.config.logo.width + instance.config.logo.paddingLeft + instance.config.logo.paddingRight;
|
||||
instance.state.logoHeight = instance.config.logo.paddingTop + instance.config.logo.height;
|
||||
|
||||
ffStrbufDestroy(&base64);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -741,12 +744,7 @@ bool ffLogoPrintImageIfExists(FFLogoType type, bool printError)
|
||||
if(type == FF_LOGO_TYPE_IMAGE_ITERM)
|
||||
return printImageIterm();
|
||||
|
||||
if(
|
||||
type == FF_LOGO_TYPE_IMAGE_KITTY &&
|
||||
ffStrbufEndsWithIgnCaseS(&instance.config.logo.source, ".png") &&
|
||||
instance.config.logo.width &&
|
||||
instance.config.logo.height
|
||||
)
|
||||
if(type == FF_LOGO_TYPE_IMAGE_KITTY_DIRECT)
|
||||
return printImageKittyDirect();
|
||||
|
||||
#if !defined(FF_HAVE_CHAFA)
|
||||
|
||||
@@ -67,6 +67,7 @@ logoType:
|
||||
{ "data-raw", FF_LOGO_TYPE_DATA_RAW },
|
||||
{ "sixel", FF_LOGO_TYPE_IMAGE_SIXEL },
|
||||
{ "kitty", FF_LOGO_TYPE_IMAGE_KITTY },
|
||||
{ "kitty-direct", FF_LOGO_TYPE_IMAGE_KITTY_DIRECT },
|
||||
{ "iterm", FF_LOGO_TYPE_IMAGE_ITERM },
|
||||
{ "chafa", FF_LOGO_TYPE_IMAGE_CHAFA },
|
||||
{ "raw", FF_LOGO_TYPE_IMAGE_RAW },
|
||||
@@ -155,6 +156,11 @@ logoType:
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
options->type = FF_LOGO_TYPE_IMAGE_KITTY;
|
||||
}
|
||||
else if(strcasecmp(key, "--kitty-direct") == 0)
|
||||
{
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
options->type = FF_LOGO_TYPE_IMAGE_KITTY_DIRECT;
|
||||
}
|
||||
else if(strcasecmp(key, "--iterm") == 0)
|
||||
{
|
||||
ffOptionParseString(key, value, &options->source);
|
||||
@@ -248,6 +254,7 @@ const char* ffParseLogoJsonConfig(void)
|
||||
{ "data-raw", FF_LOGO_TYPE_DATA_RAW },
|
||||
{ "sixel", FF_LOGO_TYPE_IMAGE_SIXEL },
|
||||
{ "kitty", FF_LOGO_TYPE_IMAGE_KITTY },
|
||||
{ "kitty-direct", FF_LOGO_TYPE_IMAGE_KITTY_DIRECT },
|
||||
{ "iterm", FF_LOGO_TYPE_IMAGE_ITERM },
|
||||
{ "chafa", FF_LOGO_TYPE_IMAGE_CHAFA },
|
||||
{ "raw", FF_LOGO_TYPE_IMAGE_RAW },
|
||||
|
||||
@@ -15,6 +15,7 @@ typedef enum FFLogoType
|
||||
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_KITTY_DIRECT, //image file, tell the terminal emulator to read image data from the specified file (Supported by kitty and wezterm)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user