fix(renderer): Do not escape parsed action cmds #444

This commit is contained in:
Michael Carlberg 2017-03-21 16:03:34 +01:00
parent f3089e88f2
commit 5c86842083
2 changed files with 8 additions and 5 deletions

View File

@ -511,7 +511,11 @@ void builder::underline_close() {
*/ */
void builder::cmd(mousebtn index, string action, bool condition) { void builder::cmd(mousebtn index, string action, bool condition) {
if (condition && !action.empty()) { if (condition && !action.empty()) {
action = string_util::replace_all(action, ":", "\\:"); size_t p{0};
while ((p = action.find(':', p)) != string::npos && action[p - 1] != '\\') {
action.insert(p, 1, '\\');
p++;
}
tag_open(syntaxtag::A, to_string(static_cast<int>(index)) + ":" + action + ":"); tag_open(syntaxtag::A, to_string(static_cast<int>(index)) + ":" + action + ":");
} }
} }
@ -520,9 +524,8 @@ void builder::cmd(mousebtn index, string action, bool condition) {
* Wrap label in command block * Wrap label in command block
*/ */
void builder::cmd(mousebtn index, string action, const label_t& label) { void builder::cmd(mousebtn index, string action, const label_t& label) {
if (!action.empty() && label && *label) { if (label && *label) {
action = string_util::replace_all(action, ":", "\\:"); cmd(index, action, true);
tag_open(syntaxtag::A, to_string(static_cast<int>(index)) + ":" + action + ":");
node(label); node(label);
tag_close(syntaxtag::A); tag_close(syntaxtag::A);
} }

View File

@ -731,7 +731,7 @@ bool renderer::on(const signals::parser::action_begin& evt) {
action.button = a.button == mousebtn::NONE ? mousebtn::LEFT : a.button; action.button = a.button == mousebtn::NONE ? mousebtn::LEFT : a.button;
action.align = m_align; action.align = m_align;
action.start_x = m_blocks.at(m_align).x; action.start_x = m_blocks.at(m_align).x;
action.command = string_util::replace_all(a.command, ":", "\\:"); action.command = string_util::replace_all(a.command, "\\:", ":");
action.active = true; action.active = true;
m_actions.emplace_back(action); m_actions.emplace_back(action);
return true; return true;