Normalize line endings in already existing files
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "MessageContainer.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
MessageContainer::MessageContainer()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
#include "MessageContainer.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
MessageContainer::MessageContainer()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class MessageContainer
|
||||
{
|
||||
public:
|
||||
MessageContainer();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class MessageContainer
|
||||
{
|
||||
public:
|
||||
MessageContainer();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
+90
-90
@@ -1,90 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
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
|
||||
{
|
||||
return std::tie(this->messageIndex, this->charIndex) <
|
||||
std::tie(b.messageIndex, b.charIndex);
|
||||
}
|
||||
|
||||
bool operator>(const SelectionItem &b) const
|
||||
{
|
||||
return !this->operator==(b) && b.operator<(*this);
|
||||
}
|
||||
|
||||
bool operator==(const SelectionItem &b) const
|
||||
{
|
||||
return this->messageIndex == b.messageIndex &&
|
||||
this->charIndex == b.charIndex;
|
||||
}
|
||||
|
||||
bool operator!=(const SelectionItem &b) const
|
||||
{
|
||||
return this->operator==(b);
|
||||
}
|
||||
};
|
||||
|
||||
struct Selection {
|
||||
SelectionItem start;
|
||||
SelectionItem end;
|
||||
SelectionItem selectionMin;
|
||||
SelectionItem selectionMax;
|
||||
|
||||
Selection() = default;
|
||||
|
||||
Selection(const SelectionItem &start, const SelectionItem &end)
|
||||
: start(start)
|
||||
, end(end)
|
||||
, selectionMin(start)
|
||||
, selectionMax(end)
|
||||
{
|
||||
if (selectionMin > selectionMax)
|
||||
{
|
||||
std::swap(this->selectionMin, this->selectionMax);
|
||||
}
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
return this->start == this->end;
|
||||
}
|
||||
|
||||
bool isSingleMessage() const
|
||||
{
|
||||
return this->selectionMin.messageIndex ==
|
||||
this->selectionMax.messageIndex;
|
||||
}
|
||||
};
|
||||
|
||||
struct DoubleClickSelection {
|
||||
int originalStart = 0;
|
||||
int originalEnd = 0;
|
||||
int origMessageIndex;
|
||||
bool selectingLeft = false;
|
||||
bool selectingRight = false;
|
||||
SelectionItem origStartItem;
|
||||
SelectionItem origEndItem;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
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
|
||||
{
|
||||
return std::tie(this->messageIndex, this->charIndex) <
|
||||
std::tie(b.messageIndex, b.charIndex);
|
||||
}
|
||||
|
||||
bool operator>(const SelectionItem &b) const
|
||||
{
|
||||
return !this->operator==(b) && b.operator<(*this);
|
||||
}
|
||||
|
||||
bool operator==(const SelectionItem &b) const
|
||||
{
|
||||
return this->messageIndex == b.messageIndex &&
|
||||
this->charIndex == b.charIndex;
|
||||
}
|
||||
|
||||
bool operator!=(const SelectionItem &b) const
|
||||
{
|
||||
return this->operator==(b);
|
||||
}
|
||||
};
|
||||
|
||||
struct Selection {
|
||||
SelectionItem start;
|
||||
SelectionItem end;
|
||||
SelectionItem selectionMin;
|
||||
SelectionItem selectionMax;
|
||||
|
||||
Selection() = default;
|
||||
|
||||
Selection(const SelectionItem &start, const SelectionItem &end)
|
||||
: start(start)
|
||||
, end(end)
|
||||
, selectionMin(start)
|
||||
, selectionMax(end)
|
||||
{
|
||||
if (selectionMin > selectionMax)
|
||||
{
|
||||
std::swap(this->selectionMin, this->selectionMax);
|
||||
}
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
return this->start == this->end;
|
||||
}
|
||||
|
||||
bool isSingleMessage() const
|
||||
{
|
||||
return this->selectionMin.messageIndex ==
|
||||
this->selectionMax.messageIndex;
|
||||
}
|
||||
};
|
||||
|
||||
struct DoubleClickSelection {
|
||||
int originalStart = 0;
|
||||
int originalEnd = 0;
|
||||
int origMessageIndex;
|
||||
bool selectingLeft = false;
|
||||
bool selectingRight = false;
|
||||
SelectionItem origStartItem;
|
||||
SelectionItem origEndItem;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,117 +1,117 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "common/Common.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/Selection.hpp"
|
||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||
|
||||
class QPainter;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
enum class MessageFlag : uint32_t;
|
||||
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||
|
||||
struct Margin {
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
int left;
|
||||
|
||||
Margin()
|
||||
: Margin(0)
|
||||
{
|
||||
}
|
||||
|
||||
Margin(int value)
|
||||
: Margin(value, value, value, value)
|
||||
{
|
||||
}
|
||||
|
||||
Margin(int _top, int _right, int _bottom, int _left)
|
||||
: top(_top)
|
||||
, right(_right)
|
||||
, bottom(_bottom)
|
||||
, left(_left)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct MessageLayoutContainer {
|
||||
MessageLayoutContainer() = default;
|
||||
|
||||
Margin margin = {4, 8, 4, 8};
|
||||
bool centered = false;
|
||||
bool enableCompactEmotes = false;
|
||||
|
||||
int getHeight() const;
|
||||
int getWidth() const;
|
||||
float getScale() const;
|
||||
|
||||
// methods
|
||||
void begin(int width_, float scale_, MessageFlags flags_);
|
||||
void end();
|
||||
|
||||
void clear();
|
||||
bool canAddElements();
|
||||
void addElement(MessageLayoutElement *element);
|
||||
void addElementNoLineBreak(MessageLayoutElement *element);
|
||||
void breakLine();
|
||||
bool atStartOfLine();
|
||||
bool fitsInLine(int width_);
|
||||
MessageLayoutElement *getElementAt(QPoint point);
|
||||
|
||||
// painting
|
||||
void paintElements(QPainter &painter);
|
||||
void paintAnimatedElements(QPainter &painter, int yOffset);
|
||||
void paintSelection(QPainter &painter, int messageIndex,
|
||||
Selection &selection, int yOffset);
|
||||
|
||||
// selection
|
||||
int getSelectionIndex(QPoint point);
|
||||
int getLastCharacterIndex() const;
|
||||
int getFirstMessageCharacterIndex() const;
|
||||
void addSelectionText(QString &str, int from, int to, CopyMode copymode);
|
||||
|
||||
bool isCollapsed();
|
||||
|
||||
private:
|
||||
struct Line {
|
||||
int startIndex;
|
||||
int endIndex;
|
||||
int startCharIndex;
|
||||
int endCharIndex;
|
||||
QRect rect;
|
||||
};
|
||||
|
||||
// helpers
|
||||
void _addElement(MessageLayoutElement *element, bool forceAdd = false);
|
||||
bool canCollapse();
|
||||
|
||||
// variables
|
||||
float scale_ = 1.f;
|
||||
int width_ = 0;
|
||||
MessageFlags flags_{};
|
||||
int line_ = 0;
|
||||
int height_ = 0;
|
||||
int currentX_ = 0;
|
||||
int currentY_ = 0;
|
||||
int charIndex_ = 0;
|
||||
size_t lineStart_ = 0;
|
||||
int lineHeight_ = 0;
|
||||
int spaceWidth_ = 4;
|
||||
int textLineHeight_ = 0;
|
||||
int dotdotdotWidth_ = 0;
|
||||
bool canAddMessages_ = true;
|
||||
bool isCollapsed_ = false;
|
||||
|
||||
std::vector<std::unique_ptr<MessageLayoutElement>> elements_;
|
||||
std::vector<Line> lines_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
#pragma once
|
||||
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "common/Common.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/Selection.hpp"
|
||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||
|
||||
class QPainter;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
enum class MessageFlag : uint32_t;
|
||||
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||
|
||||
struct Margin {
|
||||
int top;
|
||||
int right;
|
||||
int bottom;
|
||||
int left;
|
||||
|
||||
Margin()
|
||||
: Margin(0)
|
||||
{
|
||||
}
|
||||
|
||||
Margin(int value)
|
||||
: Margin(value, value, value, value)
|
||||
{
|
||||
}
|
||||
|
||||
Margin(int _top, int _right, int _bottom, int _left)
|
||||
: top(_top)
|
||||
, right(_right)
|
||||
, bottom(_bottom)
|
||||
, left(_left)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct MessageLayoutContainer {
|
||||
MessageLayoutContainer() = default;
|
||||
|
||||
Margin margin = {4, 8, 4, 8};
|
||||
bool centered = false;
|
||||
bool enableCompactEmotes = false;
|
||||
|
||||
int getHeight() const;
|
||||
int getWidth() const;
|
||||
float getScale() const;
|
||||
|
||||
// methods
|
||||
void begin(int width_, float scale_, MessageFlags flags_);
|
||||
void end();
|
||||
|
||||
void clear();
|
||||
bool canAddElements();
|
||||
void addElement(MessageLayoutElement *element);
|
||||
void addElementNoLineBreak(MessageLayoutElement *element);
|
||||
void breakLine();
|
||||
bool atStartOfLine();
|
||||
bool fitsInLine(int width_);
|
||||
MessageLayoutElement *getElementAt(QPoint point);
|
||||
|
||||
// painting
|
||||
void paintElements(QPainter &painter);
|
||||
void paintAnimatedElements(QPainter &painter, int yOffset);
|
||||
void paintSelection(QPainter &painter, int messageIndex,
|
||||
Selection &selection, int yOffset);
|
||||
|
||||
// selection
|
||||
int getSelectionIndex(QPoint point);
|
||||
int getLastCharacterIndex() const;
|
||||
int getFirstMessageCharacterIndex() const;
|
||||
void addSelectionText(QString &str, int from, int to, CopyMode copymode);
|
||||
|
||||
bool isCollapsed();
|
||||
|
||||
private:
|
||||
struct Line {
|
||||
int startIndex;
|
||||
int endIndex;
|
||||
int startCharIndex;
|
||||
int endCharIndex;
|
||||
QRect rect;
|
||||
};
|
||||
|
||||
// helpers
|
||||
void _addElement(MessageLayoutElement *element, bool forceAdd = false);
|
||||
bool canCollapse();
|
||||
|
||||
// variables
|
||||
float scale_ = 1.f;
|
||||
int width_ = 0;
|
||||
MessageFlags flags_{};
|
||||
int line_ = 0;
|
||||
int height_ = 0;
|
||||
int currentX_ = 0;
|
||||
int currentY_ = 0;
|
||||
int charIndex_ = 0;
|
||||
size_t lineStart_ = 0;
|
||||
int lineHeight_ = 0;
|
||||
int spaceWidth_ = 4;
|
||||
int textLineHeight_ = 0;
|
||||
int dotdotdotWidth_ = 0;
|
||||
bool canAddMessages_ = true;
|
||||
bool isCollapsed_ = false;
|
||||
|
||||
std::vector<std::unique_ptr<MessageLayoutElement>> elements_;
|
||||
std::vector<Line> lines_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user