aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/ScintillaWin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'win32/ScintillaWin.cxx')
-rw-r--r--win32/ScintillaWin.cxx49
1 files changed, 38 insertions, 11 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 1ee30d444..fda84759d 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -157,6 +157,7 @@ class ScintillaWin :
bool hasOKText;
CLIPFORMAT cfColumnSelect;
+ CLIPFORMAT cfLineSelect;
HRESULT hrOle;
DropSource ds;
@@ -205,6 +206,7 @@ class ScintillaWin :
virtual void NotifyParent(SCNotification scn);
virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
virtual void Copy();
+ virtual void CopyAllowLine();
virtual bool CanPaste();
virtual void Paste();
virtual void CreateCallTipWindow(PRectangle rc);
@@ -231,7 +233,7 @@ class ScintillaWin :
virtual bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi);
void ChangeScrollPos(int barType, int pos);
- void InsertPasteText(const char *text, int len, int selStart, bool isRectangular);
+ void InsertPasteText(const char *text, int len, int selStart, bool isRectangular, bool isLine);
public:
// Public for benefit of Scintilla_DirectFunction
@@ -298,6 +300,10 @@ ScintillaWin::ScintillaWin(HWND hwnd) {
cfColumnSelect = static_cast<CLIPFORMAT>(
::RegisterClipboardFormat(TEXT("MSDEVColumnSelect")));
+ // Likewise for line-copy (copies a full line when no text is selected)
+ cfLineSelect = static_cast<CLIPFORMAT>(
+ ::RegisterClipboardFormat(TEXT("MSDEVLineSelect")));
+
hrOle = E_FAIL;
wMain = hwnd;
@@ -1234,6 +1240,12 @@ void ScintillaWin::Copy() {
}
}
+void ScintillaWin::CopyAllowLine() {
+ SelectionText selectedText;
+ CopySelectionRange(&selectedText, true);
+ CopyToClipboard(selectedText);
+}
+
bool ScintillaWin::CanPaste() {
if (!Editor::CanPaste())
return false;
@@ -1283,22 +1295,32 @@ public:
}
};
-void ScintillaWin::InsertPasteText(const char *text, int len, int selStart, bool isRectangular) {
+void ScintillaWin::InsertPasteText(const char *text, int len, int selStart, bool isRectangular, bool isLine) {
if (isRectangular) {
PasteRectangular(selStart, text, len);
} else {
+ char *convertedText = 0;
if (convertPastes) {
// Convert line endings of the paste into our local line-endings mode
- char *convertedString = Document::TransformLineEnds(&len, text, len, pdoc->eolMode);
- if (pdoc->InsertString(currentPos, convertedString, len)) {
- SetEmptySelection(currentPos + len);
+ convertedText = Document::TransformLineEnds(&len, text, len, pdoc->eolMode);
+ text = convertedText;
+ }
+ if (isLine) {
+ int insertPos = pdoc->LineStart(pdoc->LineFromPosition(currentPos));
+ pdoc->InsertString(insertPos, text, len);
+ // add the newline if necessary
+ if ((len > 0) && (text[len-1] != '\n' && text[len-1] != '\r')) {
+ const char *endline = StringFromEOLMode(pdoc->eolMode);
+ pdoc->InsertString(insertPos + len, endline, strlen(endline));
+ len += strlen(endline);
}
- delete []convertedString;
- } else {
- if (pdoc->InsertString(currentPos, text, len)) {
+ if (currentPos == insertPos) {
SetEmptySelection(currentPos + len);
}
+ } else if (pdoc->InsertString(currentPos, text, len)) {
+ SetEmptySelection(currentPos + len);
}
+ delete []convertedText;
}
}
@@ -1306,6 +1328,7 @@ void ScintillaWin::Paste() {
if (!::OpenClipboard(MainHWND()))
return;
pdoc->BeginUndoAction();
+ bool isLine = SelectionEmpty() && (::IsClipboardFormatAvailable(cfLineSelect) != 0);
ClearSelection();
int selStart = SelectionStart();
bool isRectangular = ::IsClipboardFormatAvailable(cfColumnSelect) != 0;
@@ -1340,7 +1363,7 @@ void ScintillaWin::Paste() {
}
if (putf) {
- InsertPasteText(putf, len, selStart, isRectangular);
+ InsertPasteText(putf, len, selStart, isRectangular, isLine);
delete []putf;
}
}
@@ -1375,11 +1398,11 @@ void ScintillaWin::Paste() {
delete []uptr;
if (putf) {
- InsertPasteText(putf, mlen, selStart, isRectangular);
+ InsertPasteText(putf, mlen, selStart, isRectangular, isLine);
delete []putf;
}
} else {
- InsertPasteText(ptr, len, selStart, isRectangular);
+ InsertPasteText(ptr, len, selStart, isRectangular, isLine);
}
}
memSelection.Unlock();
@@ -1871,6 +1894,10 @@ void ScintillaWin::CopyToClipboard(const SelectionText &selectedText) {
::SetClipboardData(cfColumnSelect, 0);
}
+ if (selectedText.lineCopy) {
+ ::SetClipboardData(cfLineSelect, 0);
+ }
+
::CloseClipboard();
}