Skip to content

Commit f3c8d00

Browse files
committed
parse: fix regression when the source logo is an image
right now that I released customfetch v0.8.6 officially. BRUH
1 parent 238da91 commit f3c8d00

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ $(TARGET): fmt toml $(OBJ)
6464
mkdir -p $(BUILDDIR)
6565
$(CXX) $(OBJ) $(BUILDDIR)/toml++/toml.o -o $(BUILDDIR)/$(TARGET) $(LDFLAGS)
6666

67-
dist: $(TARGET)
67+
dist:
6868
bsdtar -zcf $(NAME)-v$(VERSION).tar.gz LICENSE cufetch.1 assets/ascii/ -C $(BUILDDIR) $(TARGET)
6969

7070
clean:

include/parse.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Documentation on formatting is in the default config.toml file.
99
// pureOutput is set to the string, but without the brackets.
1010
std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::string& pureOutput, const Config& config,
11-
colors_t& colors, bool parsingLaoyut);
11+
const colors_t& colors, const bool parsingLaoyut, const bool is_image = false);
1212

1313
// Set module values to a systemInfo_t map.
1414
// If the name of said module matches any module name, it will be added

src/gui.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ static std::vector<std::string>& render_with_image(Config& config, colors_t& col
4444
stbi_image_free(img);
4545
else
4646
die("Unable to load image '{}'", config.source_path);
47-
47+
48+
std::string _;
4849
for (std::string& layout : config.layouts)
4950
{
50-
std::string _;
51-
layout = parse(layout, systemInfo, _, config, colors, true);
51+
layout = parse(layout, systemInfo, _, config, colors, true, true);
5252
}
5353

5454
// erase each element for each instance of MAGIC_LINE
@@ -61,7 +61,6 @@ static std::vector<std::string>& render_with_image(Config& config, colors_t& col
6161
for (size_t _ = 0; _ < config.offset; _++) // I use _ because we don't need it
6262
config.layouts.at(i).insert(0, " ");
6363
}
64-
config.offset = 0;
6564

6665
return config.layouts;
6766
}

src/parse.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ std::string getInfoFromName(const systemInfo_t& systemInfo, const std::string_vi
115115
}
116116

117117
std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::string& pureOutput, const Config& config,
118-
colors_t& colors, bool parsingLaoyut)
118+
const colors_t& colors, const bool parsingLaoyut, const bool is_image)
119119
{
120120
std::string output = input.data();
121121
pureOutput = output;
@@ -229,12 +229,12 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
229229
// "ehhmmm why goto and double code? that's ugly and unconvienient :nerd:"
230230
// I don't care, it does the work and well
231231
if (command == *it_name)
232-
command = config.m_arg_colors_value[it_value];
232+
command = config.m_arg_colors_value.at(it_value);
233233
goto jump;
234234
}
235235

236236
if (command == *it_name)
237-
command = config.m_arg_colors_value[it_value];
237+
command = config.m_arg_colors_value.at(it_value);
238238
}
239239
}
240240

@@ -245,7 +245,12 @@ std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::s
245245
ver = 0;
246246

247247
if (auto_colors.empty())
248-
auto_colors.push_back(config.gui ? "</span><span weight='bold'>" : "\033[0m\033[1m");
248+
{
249+
if (is_image)
250+
auto_colors.push_back(config.gui ? "white" : "\033[0m\033[1m");
251+
else
252+
auto_colors.push_back(config.gui ? "</span><span weight='bold'>" : "\033[0m\033[1m");
253+
}
249254

250255
command = auto_colors.at(ver);
251256
}

0 commit comments

Comments
 (0)