[irc] Partially fix IRC colors (#1594)

Doesn't fix #1379 but it is a big step forward.

Needs some "real life" testing, but should be good.
This commit is contained in:
pajlada
2020-07-04 09:15:59 -04:00
committed by GitHub
parent 0f9a612c55
commit e4af009fda
16 changed files with 1033 additions and 403 deletions
+30
View File
@@ -291,4 +291,34 @@ public:
MessageElementFlags flags) override;
};
// contains a full message string that's split into words on space and parses irc colors that are then put into segments
// these segments are later passed to "MultiColorTextLayoutElement" elements to be rendered :)
class IrcTextElement : public MessageElement
{
public:
IrcTextElement(const QString &text, MessageElementFlags flags,
FontStyle style = FontStyle::ChatMedium);
~IrcTextElement() override = default;
void addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags) override;
private:
FontStyle style_;
struct Segment {
QString text;
int fg = -1;
int bg = -1;
};
struct Word {
QString text;
int width = -1;
std::vector<Segment> segments;
};
std::vector<Word> words_;
};
} // namespace chatterino