aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2024-07-27 12:35:18 +1000
committerNeil <nyamatongwe@gmail.com>2024-07-27 12:35:18 +1000
commit76ef74bc44e201562320906ca18d3add7084ff8b (patch)
tree6f8ea39c723a28fb9d355eb7894833689a05c68e /src
parent12edbfc7840bc4c56d1a7933e587694e9c774aee (diff)
downloadscintilla-mirror-76ef74bc44e201562320906ca18d3add7084ff8b.tar.gz
Feature [feature-requests:#1530]. SCI_SETCOPYSEPARATOR sets string to separate
parts of multiple selection when copied.
Diffstat (limited to 'src')
-rw-r--r--src/EditModel.h1
-rw-r--r--src/Editor.cxx17
2 files changed, 14 insertions, 4 deletions
diff --git a/src/EditModel.h b/src/EditModel.h
index 025c54389..e36d26fb1 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -36,6 +36,7 @@ public:
bool hasFocus;
Selection sel;
bool primarySelection;
+ std::string copySeparator;
Scintilla::IMEInteraction imeInteraction;
Scintilla::Bidirectional bidirectional;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 681c0914a..390c83898 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -4361,10 +4361,12 @@ void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) {
std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();
if (sel.selType == Selection::SelTypes::rectangle)
std::sort(rangesInOrder.begin(), rangesInOrder.end());
- for (const SelectionRange &current : rangesInOrder) {
- text.append(RangeText(current.Start().Position(), current.End().Position()));
- if (sel.selType == Selection::SelTypes::rectangle) {
- text.append(pdoc->EOLString());
+ const std::string_view separator = (sel.selType == Selection::SelTypes::rectangle) ? pdoc->EOLString() : copySeparator;
+ for (size_t part = 0; part < rangesInOrder.size(); part++) {
+ text.append(RangeText(rangesInOrder[part].Start().Position(), rangesInOrder[part].End().Position()));
+ if ((sel.selType == Selection::SelTypes::rectangle) || (part < rangesInOrder.size() - 1)) {
+ // Append unless simple selection or last part of multiple selection
+ text.append(separator);
}
}
ss->Copy(text, pdoc->dbcsCodePage,
@@ -6215,6 +6217,13 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
SetLastXChosen();
break;
+ case Message::GetCopySeparator:
+ return StringResult(lParam, copySeparator.c_str());
+
+ case Message::SetCopySeparator:
+ copySeparator = ConstCharPtrFromSPtr(lParam);
+ break;
+
case Message::VerticalCentreCaret:
VerticalCentreCaret();
break;