Skip to content

Commit

Permalink
use magic_close
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntRanch committed Jun 23, 2024
1 parent 952e83d commit 54fe3e3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <fstream>
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <magic.h>
#include <memory>

std::string Display::detect_distro(Config& config) {
Expand Down Expand Up @@ -38,6 +39,7 @@ std::vector<std::string>& Display::render(Config& config, colors_t& colors) {
std::string file_type = magic_file(myt, config.source_path.c_str());
if ((file_type.find("text") == std::string::npos) && !config.m_disable_source)
die("The source file '{}' is a binary file. Please currently use the GUI mode for rendering the image (use -h for more details)", config.source_path);
magic_close(myt);
}

for (std::string& include : config.includes) {
Expand Down Expand Up @@ -94,15 +96,15 @@ std::vector<std::string>& Display::render(Config& config, colors_t& colors) {
size_t origin = 0;

if (i < asciiArt.size()) {
config.layouts.at(i).insert(0, asciiArt.at(i));
origin = asciiArt.at(i).length();
config.layouts[i].insert(0, asciiArt[i]);
origin = asciiArt[i].length();
}

size_t spaces = (maxLineLength + (config.m_disable_source ? 1 : config.offset)) - (i < asciiArt.size() ? pureAsciiArt.at(i)->length() : 0);
size_t spaces = (maxLineLength + (config.m_disable_source ? 1 : config.offset)) - (i < asciiArt.size() ? pureAsciiArt[i]->length() : 0);
for (size_t j = 0; j < spaces; j++)
config.layouts.at(i).insert(origin, " ");
config.layouts[i].insert(origin, " ");

config.layouts.at(i) += config.gui ? "" : NOCOLOR;
config.layouts[i] += config.gui ? "" : NOCOLOR;
}

if (i < asciiArt.size())
Expand Down

0 comments on commit 54fe3e3

Please sign in to comment.