mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Logo: rename --logo-separate to --logo-position
This commit is contained in:
@@ -219,10 +219,15 @@
|
||||
"description": "If true, regenerate image logo cache",
|
||||
"default": false
|
||||
},
|
||||
"separate": {
|
||||
"type": "boolean",
|
||||
"description": "If true, print modules at bottom of the logo",
|
||||
"default": false
|
||||
"position": {
|
||||
"type": "string",
|
||||
"description": "Set the position of the logo should be displayed",
|
||||
"enum": [
|
||||
"left",
|
||||
"top",
|
||||
"right"
|
||||
],
|
||||
"default": "left"
|
||||
},
|
||||
"chafa": {
|
||||
"type": "object",
|
||||
|
||||
+8
-5
@@ -257,12 +257,15 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"long": "logo-separate",
|
||||
"desc": "If true, print modules at bottom of the logo",
|
||||
"long": "logo-position",
|
||||
"desc": "Set the position of the logo should be displayed",
|
||||
"arg": {
|
||||
"type": "bool",
|
||||
"optional": true,
|
||||
"default": false
|
||||
"type": "enum",
|
||||
"enum": {
|
||||
"left": "Left",
|
||||
"top": "Top",
|
||||
"right": "Right"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+12
-12
@@ -72,14 +72,14 @@ static bool printImageIterm(bool printError)
|
||||
|
||||
if (!options->width || !options->height)
|
||||
{
|
||||
if (!options->separate)
|
||||
if (options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
ffStrbufAppendF(&buf, "\e[2J\e[3J\e[%u;%uH",
|
||||
(unsigned) options->paddingTop,
|
||||
(unsigned) options->paddingLeft
|
||||
);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
ffStrbufAppendNC(&buf, options->paddingTop, '\n');
|
||||
ffStrbufAppendNC(&buf, options->paddingLeft, ' ');
|
||||
@@ -90,7 +90,7 @@ static bool printImageIterm(bool printError)
|
||||
ffStrbufAppendF(&buf, "\e]1337;File=inline=1:%s\a", base64.chars);
|
||||
ffWriteFDBuffer(FFUnixFD2NativeFD(STDOUT_FILENO), &buf);
|
||||
|
||||
if (!options->separate)
|
||||
if (options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
uint16_t X = 0, Y = 0;
|
||||
const char* error = ffGetTerminalResponse("\e[6n", "\e[%hu;%huR", &Y, &X);
|
||||
@@ -103,7 +103,7 @@ static bool printImageIterm(bool printError)
|
||||
instance.state.logoHeight = Y;
|
||||
fputs("\e[H", stdout);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
instance.state.logoWidth = instance.state.logoHeight = 0;
|
||||
ffPrintCharTimes('\n', options->paddingRight);
|
||||
@@ -120,13 +120,13 @@ static bool printImageIterm(bool printError)
|
||||
base64.chars
|
||||
);
|
||||
|
||||
if (!options->separate)
|
||||
if (options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
instance.state.logoWidth = options->width + options->paddingLeft + options->paddingRight;
|
||||
instance.state.logoHeight = options->paddingTop + options->height;
|
||||
ffStrbufAppendF(&buf, "\e[%uA", (unsigned) instance.state.logoHeight);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
instance.state.logoWidth = instance.state.logoHeight = 0;
|
||||
ffStrbufAppendNC(&buf, options->paddingRight, '\n');
|
||||
@@ -152,7 +152,7 @@ static bool printImageKittyDirect(bool printError)
|
||||
|
||||
if (!options->width || !options->height)
|
||||
{
|
||||
if (!options->separate)
|
||||
if (options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
// We must clear the entre screen to make sure that terminal buffer won't scroll up
|
||||
printf("\e[2J\e[3J\e[%u;%uH",
|
||||
@@ -160,7 +160,7 @@ static bool printImageKittyDirect(bool printError)
|
||||
(unsigned) options->paddingLeft
|
||||
);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
ffPrintCharTimes('\n', options->paddingTop);
|
||||
ffPrintCharTimes(' ', options->paddingLeft);
|
||||
@@ -171,7 +171,7 @@ static bool printImageKittyDirect(bool printError)
|
||||
else
|
||||
printf("\e_Ga=T,f=100,t=f;%s\e\\", base64.chars);
|
||||
fflush(stdout);
|
||||
if (!options->separate)
|
||||
if (options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
uint16_t X = 0, Y = 0;
|
||||
const char* error = ffGetTerminalResponse("\e[6n", "\e[%hu;%huR", &Y, &X);
|
||||
@@ -184,7 +184,7 @@ static bool printImageKittyDirect(bool printError)
|
||||
instance.state.logoHeight = Y;
|
||||
fputs("\e[H", stdout);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
instance.state.logoWidth = instance.state.logoHeight = 0;
|
||||
ffPrintCharTimes('\n', options->paddingRight);
|
||||
@@ -200,13 +200,13 @@ static bool printImageKittyDirect(bool printError)
|
||||
(unsigned) options->height,
|
||||
base64.chars
|
||||
);
|
||||
if (!options->separate)
|
||||
if (options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
instance.state.logoWidth = options->width + options->paddingLeft + options->paddingRight;
|
||||
instance.state.logoHeight = options->paddingTop + options->height;
|
||||
printf("\e[%uA", (unsigned) instance.state.logoHeight);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
instance.state.logoWidth = instance.state.logoHeight = 0;
|
||||
ffPrintCharTimes('\n', options->paddingRight);
|
||||
|
||||
+2
-2
@@ -199,7 +199,7 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement)
|
||||
if(!instance.config.display.pipe)
|
||||
ffStrbufAppendS(&result, FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
|
||||
if(!options->separate)
|
||||
if(options->position == FF_LOGO_POSITION_LEFT)
|
||||
{
|
||||
//Happens if the last line is the longest
|
||||
if(currentlineLength > instance.state.logoWidth)
|
||||
@@ -210,7 +210,7 @@ void ffLogoPrintChars(const char* data, bool doColorReplacement)
|
||||
//Go to the leftmost position and go up the height
|
||||
ffStrbufAppendF(&result, "\e[1G\e[%uA", instance.state.logoHeight);
|
||||
}
|
||||
else
|
||||
else if (options->position == FF_LOGO_POSITION_TOP)
|
||||
{
|
||||
instance.state.logoWidth = instance.state.logoHeight = 0;
|
||||
ffStrbufAppendNC(&result, options->paddingRight, '\n');
|
||||
|
||||
+30
-7
@@ -17,7 +17,7 @@ void ffOptionsInitLogo(FFOptionsLogo* options)
|
||||
options->printRemaining = true;
|
||||
options->preserveAspectRatio = false;
|
||||
options->recache = false;
|
||||
options->separate = false;
|
||||
options->position = FF_LOGO_POSITION_LEFT;
|
||||
|
||||
options->chafaFgOnly = false;
|
||||
ffStrbufInitStatic(&options->chafaSymbols, "block+border+space-wide-inverted"); // Chafa default
|
||||
@@ -110,8 +110,15 @@ logoType:
|
||||
options->preserveAspectRatio = ffOptionParseBoolean(value);
|
||||
else if(ffStrEqualsIgnCase(subKey, "recache"))
|
||||
options->recache = ffOptionParseBoolean(value);
|
||||
else if(ffStrEqualsIgnCase(subKey, "separate"))
|
||||
options->separate = ffOptionParseBoolean(value);
|
||||
else if(ffStrEqualsIgnCase(subKey, "position"))
|
||||
{
|
||||
options->position = (FFLogoPosition) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
|
||||
{ "left", FF_LOGO_POSITION_LEFT },
|
||||
{ "right", FF_LOGO_POSITION_RIGHT },
|
||||
{ "top", FF_LOGO_POSITION_TOP },
|
||||
{},
|
||||
});
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -355,9 +362,19 @@ const char* ffOptionsParseLogoJsonConfig(FFOptionsLogo* options, yyjson_val* roo
|
||||
options->recache = yyjson_get_bool(val);
|
||||
continue;
|
||||
}
|
||||
else if (ffStrEqualsIgnCase(key, "separate"))
|
||||
else if (ffStrEqualsIgnCase(key, "position"))
|
||||
{
|
||||
options->separate = yyjson_get_bool(val);
|
||||
int value;
|
||||
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
|
||||
{ "left", FF_LOGO_POSITION_LEFT },
|
||||
{ "top", FF_LOGO_POSITION_TOP },
|
||||
{ "right", FF_LOGO_POSITION_RIGHT },
|
||||
{},
|
||||
});
|
||||
|
||||
if (error) return error;
|
||||
options->chafaCanvasMode = (uint32_t) value;
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (ffStrEqualsIgnCase(key, "chafa"))
|
||||
@@ -528,8 +545,14 @@ void ffOptionsGenerateLogoJsonConfig(FFOptionsLogo* options, yyjson_mut_doc* doc
|
||||
if (options->recache != defaultOptions.recache)
|
||||
yyjson_mut_obj_add_bool(doc, obj, "recache", options->recache);
|
||||
|
||||
if (options->separate != defaultOptions.separate)
|
||||
yyjson_mut_obj_add_bool(doc, obj, "separate", options->separate);
|
||||
if (options->position != defaultOptions.position)
|
||||
{
|
||||
yyjson_mut_obj_add_str(doc, obj, "position", ((const char* []) {
|
||||
"left",
|
||||
"top",
|
||||
"right",
|
||||
})[options->position]);
|
||||
}
|
||||
|
||||
{
|
||||
yyjson_mut_val* chafa = yyjson_mut_obj(doc);
|
||||
|
||||
+8
-1
@@ -23,10 +23,18 @@ typedef enum FFLogoType
|
||||
FF_LOGO_TYPE_NONE, //--logo none
|
||||
} FFLogoType;
|
||||
|
||||
typedef enum FFLogoPosition
|
||||
{
|
||||
FF_LOGO_POSITION_LEFT,
|
||||
FF_LOGO_POSITION_TOP,
|
||||
FF_LOGO_POSITION_RIGHT,
|
||||
} FFLogoPosition;
|
||||
|
||||
typedef struct FFOptionsLogo
|
||||
{
|
||||
FFstrbuf source;
|
||||
FFLogoType type;
|
||||
FFLogoPosition position;
|
||||
FFstrbuf colors[FASTFETCH_LOGO_MAX_COLORS];
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
@@ -36,7 +44,6 @@ typedef struct FFOptionsLogo
|
||||
bool printRemaining;
|
||||
bool preserveAspectRatio;
|
||||
bool recache;
|
||||
bool separate;
|
||||
|
||||
bool chafaFgOnly;
|
||||
FFstrbuf chafaSymbols;
|
||||
|
||||
Reference in New Issue
Block a user