Fix selection rendering (#4830)

The rendering of selections was not aligned to the actual selection that took place for newlines at the end of messages, if they were the only part that was selected of that message.

In addition to that fix, we've already refactored the MessageLayoutContainer to try to make it a little bit more sane to work with in the future.

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-09-23 17:09:56 +02:00
committed by GitHub
parent c71e91200a
commit 6860c7007e
9 changed files with 886 additions and 657 deletions
+17 -3
View File
@@ -62,9 +62,23 @@ public:
// Elements
const MessageLayoutElement *getElementAt(QPoint point);
int getLastCharacterIndex() const;
int getFirstMessageCharacterIndex() const;
int getSelectionIndex(QPoint position);
/**
* Get the index of the last character in this message's container
* This is the sum of all the characters in `elements_`
*/
size_t getLastCharacterIndex() const;
/**
* Get the index of the first visible character in this message's container
* This is not always 0 in case there elements that are skipped
*/
size_t getFirstMessageCharacterIndex() const;
/**
* Get the character index at the given position, in the context of selections
*/
size_t getSelectionIndex(QPoint position) const;
void addSelectionText(QString &str, uint32_t from = 0,
uint32_t to = UINT32_MAX,
CopyMode copymode = CopyMode::Everything);