aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2001-02-06 02:16:11 +0000
committernyamatongwe <unknown>2001-02-06 02:16:11 +0000
commitc274332afa3c5d28ae43fa280d60fa7c52d5666b (patch)
treed776419273883b6292745c8ce829638f827d7766
parenta90a236a6fe722717bdecb89d98dde6e961a5ddb (diff)
downloadscintilla-mirror-c274332afa3c5d28ae43fa280d60fa7c52d5666b.tar.gz
Made SCI_CANPASTE and EM_CANPASTE work correctly using
IsClipboardFormatAvailable on Windows.
-rw-r--r--src/Editor.cxx6
-rw-r--r--src/Editor.h1
-rw-r--r--win32/ScintillaWin.cxx23
3 files changed, 18 insertions, 12 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index c638ca5b3..67d8ea856 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1643,6 +1643,10 @@ void Editor::PasteRectangular(int pos, const char *ptr, int len) {
SetEmptySelection(insertPos);
}
+bool Editor::CanPaste() {
+ return !pdoc->IsReadOnly();
+}
+
void Editor::Clear() {
if (currentPos == anchor) {
DelChar();
@@ -3525,7 +3529,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {
case EM_CANPASTE:
case SCI_CANPASTE:
- return !pdoc->IsReadOnly();
+ return CanPaste();
case EM_CHARFROMPOS: {
if (lParam == 0)
diff --git a/src/Editor.h b/src/Editor.h
index 0a37c8b8f..4e1ffc782 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -221,6 +221,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void Cut();
void PasteRectangular(int pos, const char *ptr, int len);
virtual void Copy() = 0;
+ virtual bool CanPaste();
virtual void Paste() = 0;
void Clear();
void SelectAll();
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index b10193d4c..120df13eb 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -141,6 +141,7 @@ class ScintillaWin :
virtual void NotifyParent(SCNotification scn);
virtual void NotifyDoubleClick(Point pt, bool shift);
virtual void Copy();
+ virtual bool CanPaste();
virtual void Paste();
virtual void CreateCallTipWindow(PRectangle rc);
virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
@@ -553,7 +554,7 @@ LRESULT ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long
return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
case WM_IME_CHAR: {
- AddCharBytes(HIBYTE(wParam), LOBYTE(wParam));
+ AddCharBytes(HIBYTE(wParam), LOBYTE(wParam));
return 0;
}
@@ -565,16 +566,8 @@ LRESULT ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long
#endif
break;
- case EM_CANPASTE: {
- ::OpenClipboard(wMain.GetID());
- HGLOBAL hmemSelection = ::GetClipboardData(CF_TEXT);
- if (!hmemSelection && IsUnicodeMode())
- hmemSelection = ::GetClipboardData(CF_UNICODETEXT);
- if (hmemSelection)
- ::GlobalUnlock(hmemSelection);
- ::CloseClipboard();
- return hmemSelection != 0;
- }
+ case EM_CANPASTE:
+ return CanPaste();
case EM_SCROLL: {
int topStart = topLine;
@@ -753,6 +746,14 @@ void ScintillaWin::Copy() {
}
}
+bool ScintillaWin::CanPaste() {
+ if (::IsClipboardFormatAvailable(CF_TEXT))
+ return true;
+ if (IsUnicodeMode())
+ return ::IsClipboardFormatAvailable(CF_UNICODETEXT);
+ return false;
+}
+
void ScintillaWin::Paste() {
pdoc->BeginUndoAction();
int selStart = SelectionStart();