Skip to content

Commit

Permalink
parse: make GUI only hexcolor options accept the hashtag #
Browse files Browse the repository at this point in the history
why? well if you are using neovim or other IDEs and have preview hex color builtin, then you can directly do it as if you are doing normally
  • Loading branch information
Toni500github committed Nov 2, 2024
1 parent e3f4c61 commit d5e3526
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions cufetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ layout = [
* \fBb\fR for background color. * \fBo\fR for overline
* \fBu\fR to underline the text * \fBa(value)\fR for fg alpha (either a percentage value like `50%` or a plain integer between 1 and 65536)
* \fB!\fR for bold text * \fBL(value)\fR for choosing an underline style (`none`, `single`, `double`, `low`, `error`)
* \fBi\fR for italic text * \fBU(value)\fR for choosing the underline color (hexcode without #)
* \fBB(value)\fR for choosing the bg color text (hexcode without #)
\fBTerminal Only\fR * \fBS(value)\fR for choosing the strikethrough color (hexcode without #)
* \fBl\fR for blinking text * \fBO(value)\fR for choosing the overline color (hexcode without #)
* \fBi\fR for italic text * \fBU(value)\fR for choosing the underline color (hexcode color)
* \fBB(value)\fR for choosing the bg color text (hexcode color)
\fBTerminal Only\fR * \fBS(value)\fR for choosing the strikethrough color (hexcode color)
* \fBl\fR for blinking text * \fBO(value)\fR for choosing the overline color (hexcode color)
* \fBA(value)\fR for choosing the bg text alpha (either a percentage value like `50%` or a plain integer between 1 and 65536)
* \fBw(value)\fR for choosing the font weight (`ultralight`, `light`, `normal`, `bold`, `ultrabold`, `heavy`, or a numeric weight)
.fi
Expand Down
10 changes: 5 additions & 5 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ inline constexpr std::string_view AUTOCONFIG = R"#([config]
# * b - for background color. * o - for overline
# * u - to underline the text * a(value) - for fg alpha (either a plain integer between 1 and 65536 or a percentage value like `50%`)
# * ! - for bold text * L(value) - to underline the text with a style (`none`, `single`, `double`, `low`, `error`)
# * i - for italic text * U(value) - for choosing the underline color (hexcode without #)
# * s - for strikethrough text * B(value) - for bg color text (same value as above)
# * S(value) - for strikethrough color (same value as above)
# Terminal Only * O(value) - for overline color (same value as above)
# * l - for blinking text * A(value) - for bg alpha (same value as a(value))
# * i - for italic text * U(value) - for choosing the underline color (hexcode color)
# * s - for strikethrough text * B(value) - for bg color text (hexcode color)
# * S(value) - for strikethrough color (hexcode color)
# Terminal Only * O(value) - for overline color (hexcode color)
# * l - for blinking text * A(value) - for bg alpha (either a plain integer between 1 and 65536 or a percentage value like `50%`)
# * w(value) - for specify font weight (`ultralight`, `light`, `normal`, `bold`, `ultrabold`, `heavy`, or a numeric weight)
#
# Alternatively, ANSI escape codes can be used, e.g ${\e[1;32m} or ${\e[38;2;34;255;11m}.
Expand Down
16 changes: 8 additions & 8 deletions src/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ std::optional<std::string> parse_color_tag(Parser& parser, parse_args_t& parse_a
default: str_clr = color; break;
}

const size_t pos = str_clr.find('#');
const size_t pos = str_clr.rfind('#');
if (pos != std::string::npos)
{
std::string tagfmt = "span ";
Expand All @@ -390,7 +390,7 @@ std::optional<std::string> parse_color_tag(Parser& parser, parse_args_t& parse_a
};

bool bgcolor = false;
for (uint i = 0; i < opt_clr.length(); ++i)
for (size_t i = 0; i < opt_clr.length(); ++i)
{
switch (opt_clr.at(i))
{
Expand Down Expand Up @@ -421,12 +421,12 @@ std::optional<std::string> parse_color_tag(Parser& parser, parse_args_t& parse_a

case 'U':
argmode_pos = i;
i += append_argmode("underline_color='#", "colored underline");
i += append_argmode("underline_color='", "colored underline");
break;

case 'B':
argmode_pos = i;
i += append_argmode("bgcolor='#", "bgcolor");
i += append_argmode("bgcolor='", "bgcolor");
break;

case 'w':
Expand All @@ -436,12 +436,12 @@ std::optional<std::string> parse_color_tag(Parser& parser, parse_args_t& parse_a

case 'O':
argmode_pos = i;
i += append_argmode("overline_color='#", "overline color");
i += append_argmode("overline_color='", "overline color");
break;

case 'S':
argmode_pos = i;
i += append_argmode("strikethrough_color='#", "color of strikethrough line");
i += append_argmode("strikethrough_color='", "color of strikethrough line");
break;
}
}
Expand Down Expand Up @@ -498,7 +498,7 @@ std::optional<std::string> parse_color_tag(Parser& parser, parse_args_t& parse_a
default: str_clr = color; break;
}

const size_t pos = str_clr.find('#');
const size_t pos = str_clr.rfind('#');
if (pos != std::string::npos)
{
const std::string& opt_clr = str_clr.substr(0, pos);
Expand All @@ -518,7 +518,7 @@ std::optional<std::string> parse_color_tag(Parser& parser, parse_args_t& parse_a
};

bool bgcolor = false;
for (uint i = 0; i < opt_clr.length(); ++i)
for (size_t i = 0; i < opt_clr.length(); ++i)
{
switch (opt_clr.at(i))
{
Expand Down

0 comments on commit d5e3526

Please sign in to comment.