refactor(parser): Naming of parse methods
This commit is contained in:
parent
31ba2f38bd
commit
24b2de5534
@ -30,9 +30,9 @@ class parser {
|
|||||||
void codeblock(string&& data, const bar_settings& bar);
|
void codeblock(string&& data, const bar_settings& bar);
|
||||||
size_t text(string&& data);
|
size_t text(string&& data);
|
||||||
|
|
||||||
unsigned int color(std::stack<unsigned int>& color_stack, string& value, unsigned int fallback);
|
unsigned int parse_color(std::stack<unsigned int>& color_stack, string& value, unsigned int fallback);
|
||||||
unsigned int parse_color(const string& s, unsigned int fallback = 0);
|
unsigned int parse_color_string(const string& s, unsigned int fallback = 0);
|
||||||
int parse_fontindex(const string& s);
|
int parse_fontindex(const string& value);
|
||||||
attribute parse_attr(const char attr);
|
attribute parse_attr(const char attr);
|
||||||
mousebtn parse_action_btn(const string& data);
|
mousebtn parse_action_btn(const string& data);
|
||||||
string parse_action_cmd(string&& data);
|
string parse_action_cmd(string&& data);
|
||||||
|
@ -82,12 +82,12 @@ void parser::codeblock(string&& data, const bar_settings& bar) {
|
|||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case 'B': {
|
case 'B': {
|
||||||
m_sig.emit(change_background{color(m_bg, value, 0UL)});
|
m_sig.emit(change_background{parse_color(m_bg, value, 0UL)});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'F': {
|
case 'F': {
|
||||||
m_sig.emit(change_foreground{color(m_fg, value, bar.foreground)});
|
m_sig.emit(change_foreground{parse_color(m_fg, value, bar.foreground)});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,21 +96,21 @@ void parser::codeblock(string&& data, const bar_settings& bar) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
m_sig.emit(change_underline{color(m_ul, value, bar.underline.color)});
|
m_sig.emit(change_underline{parse_color(m_ul, value, bar.underline.color)});
|
||||||
m_sig.emit(change_overline{color(m_ol, value, bar.overline.color)});
|
m_sig.emit(change_overline{parse_color(m_ol, value, bar.overline.color)});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
m_sig.emit(change_underline{color(m_ul, value, bar.underline.color)});
|
m_sig.emit(change_underline{parse_color(m_ul, value, bar.underline.color)});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
m_sig.emit(change_overline{color(m_ol, value, bar.overline.color)});
|
m_sig.emit(change_overline{parse_color(m_ol, value, bar.overline.color)});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
m_sig.emit(change_background{parse_color(value, bar.foreground)});
|
m_sig.emit(change_background{parse_color_string(value, bar.foreground)});
|
||||||
m_sig.emit(change_foreground{parse_color(value, bar.background)});
|
m_sig.emit(change_foreground{parse_color_string(value, bar.background)});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'O':
|
case 'O':
|
||||||
@ -187,11 +187,11 @@ size_t parser::text(string&& data) {
|
|||||||
/**
|
/**
|
||||||
* Determine color using passed stack and input value
|
* Determine color using passed stack and input value
|
||||||
*/
|
*/
|
||||||
unsigned int parser::color(std::stack<unsigned int>& color_stack, string& value, unsigned int fallback) {
|
unsigned int parser::parse_color(std::stack<unsigned int>& color_stack, string& value, unsigned int fallback) {
|
||||||
if (!color_stack.empty() && !value.empty() && value[0] == '-') {
|
if (!color_stack.empty() && !value.empty() && value[0] == '-') {
|
||||||
color_stack.pop();
|
color_stack.pop();
|
||||||
}
|
}
|
||||||
auto parsed_value = parse_color(value, !color_stack.empty() ? color_stack.top() : fallback);
|
auto parsed_value = parse_color_string(value, !color_stack.empty() ? color_stack.top() : fallback);
|
||||||
if (!value.empty() && value[0] != '-') {
|
if (!value.empty() && value[0] != '-') {
|
||||||
color_stack.push(parsed_value);
|
color_stack.push(parsed_value);
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ unsigned int parser::color(std::stack<unsigned int>& color_stack, string& value,
|
|||||||
/**
|
/**
|
||||||
* Process color hex string and convert it to the correct value
|
* Process color hex string and convert it to the correct value
|
||||||
*/
|
*/
|
||||||
unsigned int parser::parse_color(const string& s, unsigned int fallback) {
|
unsigned int parser::parse_color_string(const string& s, unsigned int fallback) {
|
||||||
if (!s.empty() && s[0] != '-') {
|
if (!s.empty() && s[0] != '-') {
|
||||||
return color_util::parse(s, fallback);
|
return color_util::parse(s, fallback);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user