mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
6ea3a1df08
cstdint) Make MessageElement to a class to fit better with the derived classes. Make MessageLayoutElement to a class to fit better with the derived classes. Remove virtual from override functions Replace all instances of boost::signals2 with pajlada::Signals. This lets us properly use clang code model to check for issues. Add missing virtual destructor to AbstractIrcServer Add missing virtual destructor to MessageLayoutElement Remove unused "connectedConnection" connection in TwitchChannel Fix typo in TrimChannelName function Fix typo in MessageParseArgs Replace some raw pointers with unique pointers where it made more sense. This allowed us to remove some manually written destructors whose only purpose was to delete that raw pointer. Reformat: Add namespace comments Reformat: Add empty empty lines between main namespace beginning and end Reformat: Re-order includes Reformat: Fix some includes that used quotes where they should use angle brackets Reformat: Replace some typedef's with using's Filter out more useless warnings
79 lines
1.6 KiB
C++
79 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <utility>
|
|
|
|
namespace chatterino {
|
|
namespace messages {
|
|
|
|
struct SelectionItem {
|
|
int messageIndex;
|
|
int charIndex;
|
|
|
|
SelectionItem()
|
|
{
|
|
this->messageIndex = 0;
|
|
this->charIndex = 0;
|
|
}
|
|
|
|
SelectionItem(int _messageIndex, int _charIndex)
|
|
{
|
|
this->messageIndex = _messageIndex;
|
|
|
|
this->charIndex = _charIndex;
|
|
}
|
|
|
|
bool operator<(const SelectionItem &b) const
|
|
{
|
|
if (this->messageIndex < b.messageIndex) {
|
|
return true;
|
|
}
|
|
if (this->messageIndex == b.messageIndex && this->charIndex < b.charIndex) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool operator>(const SelectionItem &b) const
|
|
{
|
|
return b.operator<(*this);
|
|
}
|
|
|
|
bool operator==(const SelectionItem &b) const
|
|
{
|
|
return this->messageIndex == b.messageIndex && this->charIndex == b.charIndex;
|
|
}
|
|
};
|
|
|
|
struct Selection {
|
|
SelectionItem start;
|
|
SelectionItem end;
|
|
SelectionItem min;
|
|
SelectionItem max;
|
|
|
|
Selection() = default;
|
|
|
|
Selection(const SelectionItem &start, const SelectionItem &end)
|
|
: start(start)
|
|
, end(end)
|
|
, min(start)
|
|
, max(end)
|
|
{
|
|
if (min > max) {
|
|
std::swap(this->min, this->max);
|
|
}
|
|
}
|
|
|
|
bool isEmpty() const
|
|
{
|
|
return this->start == this->end;
|
|
}
|
|
|
|
bool isSingleMessage() const
|
|
{
|
|
return this->min.messageIndex == this->max.messageIndex;
|
|
}
|
|
};
|
|
|
|
} // namespace messages
|
|
} // namespace chatterino
|