Skip to content

Commit

Permalink
config: Add pre-logo-offset to customize the space from behind the AS…
Browse files Browse the repository at this point in the history
…CII art
  • Loading branch information
BurntRanch committed Aug 24, 2024
1 parent 3016062 commit 4de3742
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
3 changes: 3 additions & 0 deletions assets/config-examples/nitch_like_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ sep-reset = ":"
# Offset between the ascii art and the system infos
offset = 5

# Offset between the start and the ascii art
pre-logo-offset = 5

# Padding of the logo from the top
logo-padding-top = 0

Expand Down
5 changes: 5 additions & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class Config
std::string sep_reset;
std::string gui_bg_image;
std::uint16_t offset = 0;
std::uint16_t pre_logo_offset = 0;
std::uint16_t logo_padding_top = 0;

bool gui = false;
std::vector<std::string> layouts;
std::vector<std::string> pkgs_managers;
Expand Down Expand Up @@ -150,6 +152,9 @@ sep-reset = ":"
# Offset between the ascii art and the system infos
offset = 5
# Offset between the start and the ascii art
pre-logo-offset = 5
# Padding of the logo from the top
logo-padding-top = 0
Expand Down
3 changes: 2 additions & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void Config::loadConfigFile(const std::string_view filename, colors_t& colors)
this->source_path = this->getConfigValue<std::string>("config.source-path", "os");
this->data_dir = this->getConfigValue<std::string>("config.data-dir", "/usr/share/customfetch");
this->sep_reset = this->getConfigValue<std::string>("config.sep-reset", ":");
this->offset = this->getConfigValue<std::uint8_t>("config.offset", 5);
this->offset = this->getConfigValue<std::uint16_t>("config.offset", 5);
this->pre_logo_offset = this->getConfigValue<std::uint16_t>("config.pre-logo-offset", 5);
this->font = this->getConfigValue<std::string>("gui.font", "Liberation Mono Normal 12");
this->gui_bg_image = this->getConfigValue<std::string>("gui.bg-image", "disable");
this->logo_padding_top = this->getConfigValue<std::uint16_t>("config.logo-padding-top", 0);
Expand Down
24 changes: 19 additions & 5 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,17 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
size_t i;
for (i = 0; i < layouts.size(); i++)
{
size_t origin = 0;
size_t origin = config.pre_logo_offset;

// The user-specified offset to be put before the logo
for (size_t j = 0; j < config.pre_logo_offset; j++) {
layouts.at(i).insert(0, " ");
}

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

size_t spaces = (maxLineLength + (config.m_disable_source ? 1 : config.offset)) -
Expand All @@ -165,8 +170,17 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
layouts.at(i) += config.gui ? "" : "\033[0m";
}

if (i < asciiArt.size())
layouts.insert(layouts.end(), asciiArt.begin() + i, asciiArt.end());
for (; i < asciiArt.size(); i++) {
std::string line;

for (size_t j = 0; j < config.pre_logo_offset; j++) {
line += " ";
}

line += asciiArt[i];

layouts.push_back(line);
}

return layouts;
}
Expand Down

0 comments on commit 4de3742

Please sign in to comment.