diff --git a/src/controller.cpp b/src/controller.cpp index a7af92e..375ad35 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -1184,7 +1184,7 @@ void RcxController::showContextMenu(RcxEditor* editor, int line, int nodeIdx, menu.addSeparator(); menu.addAction(icon("clippy.svg"), "Copy All as Text", [editor]() { - QApplication::clipboard()->setText(editor->scintilla()->text()); + QApplication::clipboard()->setText(editor->textWithMargins()); }); menu.exec(globalPos); diff --git a/src/editor.cpp b/src/editor.cpp index 1f3821c..9b04cd0 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -2154,4 +2154,18 @@ void RcxEditor::setGlobalFontName(const QString& fontName) { g_fontName = fontName; } +QString RcxEditor::textWithMargins() const { + int lineCount = (int)m_sci->SendScintilla(QsciScintillaBase::SCI_GETLINECOUNT); + QStringList lines; + lines.reserve(lineCount); + for (int i = 0; i < lineCount; i++) { + QString margin; + if (i < m_meta.size()) + margin = m_meta[i].offsetText; + QString lineText = getLineText(m_sci, i); + lines.append(margin + lineText); + } + return lines.join('\n'); +} + } // namespace rcx diff --git a/src/editor.h b/src/editor.h index 75f9757..f9cb5ed 100644 --- a/src/editor.h +++ b/src/editor.h @@ -49,6 +49,7 @@ public: static void setGlobalFontName(const QString& fontName); // Custom type names (struct types from the tree) shown in type picker + lexer GlobalClass coloring + QString textWithMargins() const; void setCustomTypeNames(const QStringList& names); // Saved sources for quick-switch in source picker