Skip to content

Commit

Permalink
parse: fix regression when the source logo is an image
Browse files Browse the repository at this point in the history
right now that I released customfetch v0.8.6 officially. BRUH
  • Loading branch information
Toni500github committed Aug 22, 2024
1 parent 238da91 commit f3c8d00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $(TARGET): fmt toml $(OBJ)
mkdir -p $(BUILDDIR)
$(CXX) $(OBJ) $(BUILDDIR)/toml++/toml.o -o $(BUILDDIR)/$(TARGET) $(LDFLAGS)

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

clean:
Expand Down
2 changes: 1 addition & 1 deletion include/parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Documentation on formatting is in the default config.toml file.
// pureOutput is set to the string, but without the brackets.
std::string parse(const std::string_view input, systemInfo_t& systemInfo, std::string& pureOutput, const Config& config,
colors_t& colors, bool parsingLaoyut);
const colors_t& colors, const bool parsingLaoyut, const bool is_image = false);

// Set module values to a systemInfo_t map.
// If the name of said module matches any module name, it will be added
Expand Down
7 changes: 3 additions & 4 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ static std::vector<std::string>& render_with_image(Config& config, colors_t& col
stbi_image_free(img);
else
die("Unable to load image '{}'", config.source_path);


std::string _;
for (std::string& layout : config.layouts)
{
std::string _;
layout = parse(layout, systemInfo, _, config, colors, true);
layout = parse(layout, systemInfo, _, config, colors, true, true);
}

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

return config.layouts;
}
Expand Down
13 changes: 9 additions & 4 deletions src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ std::string getInfoFromName(const systemInfo_t& systemInfo, const std::string_vi
}

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

if (command == *it_name)
command = config.m_arg_colors_value[it_value];
command = config.m_arg_colors_value.at(it_value);
}
}

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

if (auto_colors.empty())
auto_colors.push_back(config.gui ? "</span><span weight='bold'>" : "\033[0m\033[1m");
{
if (is_image)
auto_colors.push_back(config.gui ? "white" : "\033[0m\033[1m");
else
auto_colors.push_back(config.gui ? "</span><span weight='bold'>" : "\033[0m\033[1m");
}

command = auto_colors.at(ver);
}
Expand Down

0 comments on commit f3c8d00

Please sign in to comment.