aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2013-01-04 19:40:02 +1100
committernyamatongwe <devnull@localhost>2013-01-04 19:40:02 +1100
commitbe25bdf8fc94b62915cab45694af7661041ca88c (patch)
treecede74889dd06b59a88047b454025f0f6f2f5184
parent47eb10237c8500ea2ff7c416cb33f14b28dbfe65 (diff)
downloadscintilla-mirror-be25bdf8fc94b62915cab45694af7661041ca88c.tar.gz
Implement a delegate for Scintilla notifications.
From Mike Lischke at Oracle.
-rw-r--r--cocoa/ScintillaView.h7
-rw-r--r--cocoa/ScintillaView.mm14
2 files changed, 20 insertions, 1 deletions
diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h
index b55591e80..8a028e2c4 100644
--- a/cocoa/ScintillaView.h
+++ b/cocoa/ScintillaView.h
@@ -22,6 +22,10 @@
extern NSString *SCIUpdateUINotification;
+@protocol ScintillaNotificationProtocol
+- (void)notification: (Scintilla::SCNotification*)notification;
+@end
+
/**
* InnerView is the Cocoa interface to the Scintilla backend. It handles text input and
* provides a canvas for painting the output.
@@ -70,10 +74,13 @@ extern NSString *SCIUpdateUINotification;
NSView <InfoBarCommunicator>* mInfoBar;
BOOL mInfoBarAtTop;
int mInitialInfoBarWidth;
+
+ id<ScintillaNotificationProtocol> mDelegate;
}
@property (nonatomic, assign) Scintilla::ScintillaCocoa* backend;
@property (nonatomic, assign) NSObject* owner;
+@property (nonatomic, assign) id<ScintillaNotificationProtocol> delegate;
- (void) dealloc;
- (void) positionSubViews;
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index b2bee0baa..a22e07a96 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -4,7 +4,8 @@
*
* Created by Mike Lischke.
*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2009, 2011 Sun Microsystems, Inc. All rights reserved.
* This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt).
*/
@@ -609,6 +610,7 @@ NSString *SCIUpdateUINotification = @"SCIUpdateUI";
@synthesize backend = mBackend;
@synthesize owner = mOwner;
+@synthesize delegate = mDelegate;
/**
* ScintiallView is a composite control made from an NSView and an embedded NSView that is
@@ -725,6 +727,8 @@ NSString *SCIUpdateUINotification = @"SCIUpdateUI";
/**
* Notification function used by Scintilla to call us back (e.g. for handling clicks on the
* folder margin or changes in the editor).
+ * A delegate can be set to receive all notifications. If set no handling takes place here, except
+ * for action pertaining to internal stuff (like the info bar).
*/
static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wParam, uintptr_t lParam)
{
@@ -739,6 +743,14 @@ static void notification(intptr_t windowid, unsigned int iMessage, uintptr_t wPa
SCNotification* scn = reinterpret_cast<SCNotification*>(lParam);
ScintillaCocoa *psc = reinterpret_cast<ScintillaCocoa*>(scn->nmhdr.hwndFrom);
editor = reinterpret_cast<InnerView*>(psc->ContentView()).owner;
+
+ if (editor.delegate != nil)
+ {
+ [editor.delegate notification: scn];
+ if (scn->nmhdr.code != SCN_ZOOM && scn->nmhdr.code != SCN_UPDATEUI)
+ return;
+ }
+
switch (scn->nmhdr.code)
{
case SCN_MARGINCLICK: