diff options
author | George Hazan <george.hazan@gmail.com> | 2024-10-24 15:44:14 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-10-24 15:44:14 +0300 |
commit | 6927078455e017dac4b274e5aaee99ed9ce93109 (patch) | |
tree | 92788bfb7c0de5f61c3dc572efaf5bcaf06690c8 /src | |
parent | b34095bdc8c849f7670e47c148a3b685d9881906 (diff) |
fixes #4754 (IRC: bb-теги в чате с обрезанными стилями)
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/chat_loginfo.cpp | 80 |
1 files changed, 28 insertions, 52 deletions
diff --git a/src/mir_app/src/chat_loginfo.cpp b/src/mir_app/src/chat_loginfo.cpp index 1c05f5ecb8..e46c2eedc7 100644 --- a/src/mir_app/src/chat_loginfo.cpp +++ b/src/mir_app/src/chat_loginfo.cpp @@ -84,7 +84,7 @@ int LOGINFO::getIcon() const return 0; } -void LOGINFO::write(RtfChatLogStreamData *streamData, bool /*simpleMode*/, CMStringA &str, const wchar_t *line) const +void LOGINFO::write(RtfChatLogStreamData *streamData, bool simpleMode, CMStringA &str, const wchar_t *line) const { CMStringA buf; @@ -96,62 +96,38 @@ void LOGINFO::write(RtfChatLogStreamData *streamData, bool /*simpleMode*/, CMStr else if (*line == '\n') { buf.Append("\\line "); } - /* - else if (*line == '%' && !simpleMode) { - switch (*++line) { - case 'c': - case 'f': - if (g_Settings->bStripFormat || streamData->bStripFormat) - line += 2; - - else if (line[1] != '\0' && line[2] != '\0') { - wchar_t szTemp3[3], c = *line; - int col; - szTemp3[0] = line[1]; - szTemp3[1] = line[2]; - szTemp3[2] = '\0'; - line += 2; - - col = _wtoi(szTemp3); - col += (OPTIONS_FONTCOUNT + 1); - buf.AppendFormat((c == 'c') ? "\\cf%u " : "\\highlight%u ", col); - } - break; - case 'C': - case 'F': - if (!g_Settings->bStripFormat && !streamData->bStripFormat) { - int j = bIsHighlighted ? 16 : getIndex(); - if (*line == 'C') - buf.AppendFormat("\\cf%u ", j + 1); - else - buf.AppendFormat("\\highlight0 "); - } - break; - case 'b': - case 'u': - case 'i': + else if (*line == '[' && !simpleMode) { + line++; + bool bEnable = true; + if (*line == '/') { + line++; + bEnable = false; + } + + if (!wcsncmp(line, L"color", 5) || !wcsncmp(line, L"bkcolor", 7)) + line = wcschr(line, ']'); + else if (!wcsncmp(line, L"b]", 2)) { + line++; if (!streamData->bStripFormat) - buf.AppendFormat((*line == 'u') ? "\\%cl " : "\\%c ", *line); - break; - - case 'B': - case 'U': - case 'I': + buf.Append(bEnable ? "\\b" : "\\b0"); + } + else if (!wcsncmp(line, L"i]", 2)) { + line++; if (!streamData->bStripFormat) - buf.AppendFormat((*line == 'U') ? "\\%cl0 " : "\\%c0 ", tolower(*line)); - break; - - case 'r': + buf.Append(bEnable ? "\\i" : "\\i0"); + } + else if (!wcsncmp(line, L"s]", 2)) { + line++; if (!streamData->bStripFormat) - buf.AppendFormat("%s ", Log_SetStyle(getIndex())); - break; - - default: - buf.AppendChar('%'); - break; + buf.Append(bEnable ? "\\s" : "\\s0"); + } + else if (!wcsncmp(line, L"u]", 2)) { + line++; + if (!streamData->bStripFormat) + buf.Append(bEnable ? "\\ul" : "\\ul0"); } + else buf.AppendChar('['); } - */ else if (*line == '\t' && !streamData->bStripFormat) { buf.Append("\\tab "); } |