diff options
author | George Hazan <george.hazan@gmail.com> | 2023-10-31 13:09:10 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-10-31 13:09:10 +0300 |
commit | 5b2fa6f292b910409066b2ca748b3f7b8ff020b1 (patch) | |
tree | 97408436343ad0144a9b76e4dea1897ee1942d3e /plugins/NewStory/src/templates.cpp | |
parent | 6a495da1906284b770f1aceee892d7e60fe1582e (diff) |
NewStory:
- fixes #3755 (NewStory: неработающий тэг color парсится криво);
- fixes bug with template preview in the options dialog
Diffstat (limited to 'plugins/NewStory/src/templates.cpp')
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index b6ab2d727f..6721ee39cc 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -47,38 +47,40 @@ static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *p) buf.AppendChar((char)*p); } else if (*p == '[') { - if (p[1] == 'c' && p[3] == ']') { - buf.AppendFormat("\\cf%c ", p[2]); - p += 3; + p++; + if (*p == 'c' && p[2] == ']') { + buf.AppendFormat("\\cf%c ", p[1]); + p += 2; continue; } char *pEnd = ""; - if (p[1] == '/') { + if (*p == '/') { pEnd = "0"; p++; } - if (p[1] == 'b' && p[2] == ']') { + if (*p == 'b' && p[1] == ']') { buf.AppendFormat("\\b%s ", pEnd); - p += 2; + p++; } - else if (p[1] == 'i' && p[2] == ']') { + else if (*p == 'i' && p[1] == ']') { buf.AppendFormat("\\i%s ", pEnd); - p += 2; + p++; } - else if (p[1] == 'u' && p[2] == ']') { + else if (*p == 'u' && p[1] == ']') { buf.AppendFormat("\\ul%s ", pEnd); - p += 2; + p++; } - else if (p[1] == 's' && p[2] == ']') { + else if (*p == 's' && p[1] == ']') { buf.AppendFormat("\\strike%s ", pEnd); - p += 2; + p++; } - else if (p[1] == 'c' && p[2] == ']') { - buf.Append("\\cf1 "); - p += 2; + else { + buf.AppendChar('['); + if (*pEnd == '0') + p--; + p--; } - else buf.AppendChar('['); } else if (*p < 128) { buf.AppendChar((char)*p); @@ -153,9 +155,10 @@ CMStringW TplFormatString(int tpl, MCONTACT hContact, ItemData *item) /////////////////////////////////////////////////////////////////////////////// // Template formatting for options dialog -CMStringW ItemData::formatStringEx(int tpl, wchar_t *sztpl) +CMStringW ItemData::formatStringEx(wchar_t *sztpl) { CMStringW buf; + int tpl = getTemplate(); if (tpl < 0 || tpl >= TPL_COUNT || !sztpl) return buf; |