mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-28 07:44:06 +01:00
Logo: treat a "$" ending a line or the logo as a plain dollar (#2667)
Fixes #2666
This commit is contained in:
+5
-2
@@ -143,10 +143,13 @@ static void logoLineCacheBuild(FFLogoLineCacheState* cache, const char* data, bo
|
||||
if (doColorReplacement && *data == '$') {
|
||||
++data;
|
||||
|
||||
if (*data == '$' || *data == '\0') {
|
||||
// `$$` is an escaped dollar; a `$` ending a line or the logo is a plain one
|
||||
if (*data == '$' || *data == '\0' || *data == '\n' || *data == '\r') {
|
||||
ffStrbufAppendC(&line, '$');
|
||||
++lineWidth;
|
||||
++data;
|
||||
if (*data == '$') {
|
||||
++data;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "logo/logo.h"
|
||||
#include "common/textModifier.h"
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -55,6 +56,15 @@ int main(void) {
|
||||
VERIFY(strcmp(ffLogoPositionToString(FF_LOGO_POSITION_TOP), "top") == 0);
|
||||
VERIFY(strcmp(ffLogoPositionToString(FF_LOGO_POSITION_RIGHT), "right") == 0);
|
||||
|
||||
// A `$` ending a line or the logo is a plain dollar: it keeps the line break and the terminator.
|
||||
instance.config.display.pipe = true;
|
||||
ffLogoPrintChars("ab$\ncd", true);
|
||||
VERIFY(instance.state.logoHeight == 1 && instance.state.logoWidth == 3);
|
||||
ffLogoPrintChars("ab$", true);
|
||||
VERIFY(instance.state.logoHeight == 0 && instance.state.logoWidth == 3);
|
||||
ffLogoPrintChars("a$1b$$c", true);
|
||||
VERIFY(instance.state.logoWidth == 4);
|
||||
|
||||
puts("\033[32mAll tests passed!" FASTFETCH_TEXT_MODIFIER_RESET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user