void TextEditorOverlay::addOverlaySelection(int begin, int end, const QColor &fg, const QColor &bg, uint overlaySelectionFlags) { if (end < begin) return; QTextDocument *document = m_editor->document(); OverlaySelection selection; selection.m_fg = fg; selection.m_bg = bg; selection.m_cursor_begin = QTextCursor(document->docHandle(), begin); selection.m_cursor_end = QTextCursor(document->docHandle(), end); if (overlaySelectionFlags & ExpandBegin) selection.m_cursor_begin.setKeepPositionOnInsert(true); if (overlaySelectionFlags & LockSize) selection.m_fixedLength = (end - begin); selection.m_dropShadow = (overlaySelectionFlags & DropShadow); if (m_selections.isEmpty()) m_firstSelectionOriginalBegin = begin; else if (begin < m_firstSelectionOriginalBegin) qWarning() << "overlay selections not in order"; m_selections.append(selection); update(); }