- Make sure that when adding characters before/after a link that it doesn't take the link style

- Make sure that when double clicking a link with a space the whole text is selected
- Make sure that shift selection with arrows works
- Make sure that ctrl left right (word jump) moves across the whole link even if multiple words
This commit is contained in:
James Graham
2026-02-22 19:17:42 +00:00
parent 0a99e90591
commit d1acb97fe2
8 changed files with 313 additions and 92 deletions

View File

@@ -182,6 +182,16 @@ public:
*/
QRect cursorRectangle() const;
/**
* @brief The start position of any text selection in the underlying text item.
*/
int selectionStart() const;
/**
* @brief The end position of any text selection in the underlying text item.
*/
int selectionEnd() const;
/**
* @brief Set the cursor position of the underlying text item to the given value.
*/
@@ -190,7 +200,7 @@ public:
/**
* @brief Set the selection of the underlying text item to the given cursor.
*/
void setSelection(const QTextCursor &cursor);
void setSelection(int selectionStart, int selectionEnd);
/**
* @brief Set the cursor visibility of the underlying text item to the given value.
@@ -312,11 +322,17 @@ Q_SIGNALS:
*/
void cursorPositionChanged(bool fromContentsChange);
/**
* @brief Emitted when the selected text of the underlying text item is changed.
*/
void selectedTextChanged();
private:
QPointer<QQuickItem> m_textItem;
QPointer<ChatBarSyntaxHighlighter> m_highlighter;
bool m_contentsJustChanged = false;
bool m_selectionJustChanged = false;
QString m_fixedStartChars = {};
QString m_fixedEndChars = {};
@@ -326,9 +342,6 @@ private:
std::optional<int> lineLength(int lineNumber) const;
int selectionStart() const;
int selectionEnd() const;
void mergeTextFormatOnCursor(RichFormat::Format format, QTextCursor cursor);
void mergeStyleFormatOnCursor(RichFormat::Format format, QTextCursor cursor);
void mergeListFormatOnCursor(RichFormat::Format format, const QTextCursor &cursor);
@@ -339,4 +352,5 @@ private:
private Q_SLOTS:
void itemTextFormatChanged();
void itemCursorPositionChanged();
void itemSelectedTextChanged();
};