2010-07-14 09:47:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Declaration of the native Cocoa View that serves as container for the scintilla parts.
|
2021-02-21 04:53:09 +00:00
|
|
|
* @file ScintillaView.h
|
2010-07-14 09:47:17 +00:00
|
|
|
*
|
|
|
|
* Created by Mike Lischke.
|
|
|
|
*
|
2013-08-28 00:44:27 +00:00
|
|
|
* Copyright 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
* Copyright 2009, 2011 Sun Microsystems, Inc. All rights reserved.
|
2010-07-14 09:47:17 +00:00
|
|
|
* This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#import "Scintilla.h"
|
|
|
|
#import "SciLexer.h"
|
|
|
|
|
|
|
|
#import "InfoBarCommunicator.h"
|
2015-06-07 21:19:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scintilla sends these two messages to the notify handler. Please refer
|
|
|
|
* to the Windows API doc for details about the message format.
|
|
|
|
*/
|
|
|
|
#define WM_COMMAND 1001
|
|
|
|
#define WM_NOTIFY 1002
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On the Mac, there is no WM_COMMAND or WM_NOTIFY message that can be sent
|
|
|
|
* back to the parent. Therefore, there must be a callback handler that acts
|
|
|
|
* like a Windows WndProc, where Scintilla can send notifications to. Use
|
|
|
|
* ScintillaView registerNotifyCallback() to register such a handler.
|
|
|
|
* Message format is:
|
|
|
|
* <br>
|
|
|
|
* WM_COMMAND: HIWORD (wParam) = notification code, LOWORD (wParam) = control ID, lParam = ScintillaCocoa*
|
|
|
|
* <br>
|
|
|
|
* WM_NOTIFY: wParam = control ID, lParam = ptr to SCNotification structure, with hwndFrom set to ScintillaCocoa*
|
|
|
|
*/
|
2019-05-04 18:14:48 +00:00
|
|
|
typedef void(*SciNotifyFunc)(intptr_t windowid, unsigned int iMessage, uintptr_t wParam, uintptr_t lParam);
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
extern NSString *const SCIUpdateUINotification;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
@protocol ScintillaNotificationProtocol
|
2019-05-04 18:14:48 +00:00
|
|
|
- (void) notification: (SCNotification *) notification;
|
2013-08-28 00:44:27 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
/**
|
2019-05-04 18:14:48 +00:00
|
|
|
* SCIScrollView provides pre-macOS 10.14 tiling behavior.
|
2013-08-28 00:44:27 +00:00
|
|
|
*/
|
2019-05-04 18:14:48 +00:00
|
|
|
@interface SCIScrollView : NSScrollView;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
@end
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
/**
|
|
|
|
* SCIMarginView draws line numbers and other margins next to the text view.
|
|
|
|
*/
|
|
|
|
@interface SCIMarginView : NSRulerView;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
/**
|
2015-06-07 21:19:26 +00:00
|
|
|
* SCIContentView is the Cocoa interface to the Scintilla backend. It handles text input and
|
2010-07-14 09:47:17 +00:00
|
|
|
* provides a canvas for painting the output.
|
|
|
|
*/
|
2015-06-07 21:19:26 +00:00
|
|
|
@interface SCIContentView : NSView <
|
2019-05-04 18:14:48 +00:00
|
|
|
NSTextInputClient,
|
|
|
|
NSUserInterfaceValidations,
|
|
|
|
NSDraggingSource,
|
|
|
|
NSDraggingDestination,
|
|
|
|
NSAccessibilityStaticText>;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
- (void) setCursor: (int) cursor; // Needed by ScintillaCocoa
|
2011-03-22 00:16:49 +00:00
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
@end
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
/**
|
|
|
|
* ScintillaView is the class instantiated by client code.
|
|
|
|
* It contains an NSScrollView which contains a SCIMarginView and a SCIContentView.
|
|
|
|
* It is responsible for providing an API and communicating to a delegate.
|
|
|
|
*/
|
|
|
|
@interface ScintillaView : NSView <InfoBarCommunicator, ScintillaNotificationProtocol>;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
@property(nonatomic, unsafe_unretained) id<ScintillaNotificationProtocol> delegate;
|
|
|
|
@property(nonatomic, readonly) NSScrollView *scrollView;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
+ (Class) contentViewClass;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
- (void) notify: (NotificationType) type message: (NSString *) message location: (NSPoint) location
|
|
|
|
value: (float) value;
|
2010-07-14 09:47:17 +00:00
|
|
|
- (void) setCallback: (id <InfoBarCommunicator>) callback;
|
|
|
|
|
2011-03-22 00:16:49 +00:00
|
|
|
- (void) suspendDrawing: (BOOL) suspend;
|
2019-05-04 18:14:48 +00:00
|
|
|
- (void) notification: (SCNotification *) notification;
|
|
|
|
|
|
|
|
- (void) updateIndicatorIME;
|
2011-03-22 00:16:49 +00:00
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
// Scroller handling
|
2013-08-28 00:44:27 +00:00
|
|
|
- (void) setMarginWidth: (int) width;
|
2019-05-04 18:14:48 +00:00
|
|
|
- (SCIContentView *) content;
|
2015-06-07 21:19:26 +00:00
|
|
|
- (void) updateMarginCursors;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
|
|
|
// NSTextView compatibility layer.
|
2019-05-04 18:14:48 +00:00
|
|
|
- (NSString *) string;
|
|
|
|
- (void) setString: (NSString *) aString;
|
2015-06-07 21:19:26 +00:00
|
|
|
- (void) insertText: (id) aString;
|
2010-07-14 09:47:17 +00:00
|
|
|
- (void) setEditable: (BOOL) editable;
|
|
|
|
- (BOOL) isEditable;
|
|
|
|
- (NSRange) selectedRange;
|
2019-05-04 18:14:48 +00:00
|
|
|
- (NSRange) selectedRangePositions;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
- (NSString *) selectedString;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
- (void) deleteRange: (NSRange) range;
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
- (void) setFontName: (NSString *) font
|
|
|
|
size: (int) size
|
|
|
|
bold: (BOOL) bold
|
|
|
|
italic: (BOOL) italic;
|
2010-08-21 23:59:56 +00:00
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
// Native call through to the backend.
|
2019-05-04 18:14:48 +00:00
|
|
|
+ (sptr_t) directCall: (ScintillaView *) sender message: (unsigned int) message wParam: (uptr_t) wParam
|
|
|
|
lParam: (sptr_t) lParam;
|
2013-08-28 00:44:27 +00:00
|
|
|
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam lParam: (sptr_t) lParam;
|
|
|
|
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam;
|
|
|
|
- (sptr_t) message: (unsigned int) message;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
|
|
|
// Back end properties getters and setters.
|
|
|
|
- (void) setGeneralProperty: (int) property parameter: (long) parameter value: (long) value;
|
2011-03-22 00:16:49 +00:00
|
|
|
- (void) setGeneralProperty: (int) property value: (long) value;
|
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
- (long) getGeneralProperty: (int) property;
|
|
|
|
- (long) getGeneralProperty: (int) property parameter: (long) parameter;
|
|
|
|
- (long) getGeneralProperty: (int) property parameter: (long) parameter extra: (long) extra;
|
2019-05-04 18:14:48 +00:00
|
|
|
- (long) getGeneralProperty: (int) property ref: (const void *) ref;
|
|
|
|
- (void) setColorProperty: (int) property parameter: (long) parameter value: (NSColor *) value;
|
|
|
|
- (void) setColorProperty: (int) property parameter: (long) parameter fromHTML: (NSString *) fromHTML;
|
|
|
|
- (NSColor *) getColorProperty: (int) property parameter: (long) parameter;
|
|
|
|
- (void) setReferenceProperty: (int) property parameter: (long) parameter value: (const void *) value;
|
|
|
|
- (const void *) getReferenceProperty: (int) property parameter: (long) parameter;
|
|
|
|
- (void) setStringProperty: (int) property parameter: (long) parameter value: (NSString *) value;
|
|
|
|
- (NSString *) getStringProperty: (int) property parameter: (long) parameter;
|
|
|
|
- (void) setLexerProperty: (NSString *) name value: (NSString *) value;
|
|
|
|
- (NSString *) getLexerProperty: (NSString *) name;
|
2010-07-14 09:47:17 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
// The delegate property should be used instead of registerNotifyCallback which is deprecated.
|
2019-05-04 18:14:48 +00:00
|
|
|
- (void) registerNotifyCallback: (intptr_t) windowid value: (SciNotifyFunc) callback __attribute__ ( (deprecated)) ;
|
|
|
|
|
|
|
|
- (void) setInfoBar: (NSView <InfoBarCommunicator> *) aView top: (BOOL) top;
|
|
|
|
- (void) setStatusText: (NSString *) text;
|
|
|
|
|
|
|
|
- (BOOL) findAndHighlightText: (NSString *) searchText
|
|
|
|
matchCase: (BOOL) matchCase
|
|
|
|
wholeWord: (BOOL) wholeWord
|
|
|
|
scrollTo: (BOOL) scrollTo
|
|
|
|
wrap: (BOOL) wrap;
|
|
|
|
|
|
|
|
- (BOOL) findAndHighlightText: (NSString *) searchText
|
|
|
|
matchCase: (BOOL) matchCase
|
|
|
|
wholeWord: (BOOL) wholeWord
|
|
|
|
scrollTo: (BOOL) scrollTo
|
|
|
|
wrap: (BOOL) wrap
|
|
|
|
backwards: (BOOL) backwards;
|
|
|
|
|
|
|
|
- (int) findAndReplaceText: (NSString *) searchText
|
|
|
|
byText: (NSString *) newText
|
|
|
|
matchCase: (BOOL) matchCase
|
|
|
|
wholeWord: (BOOL) wholeWord
|
|
|
|
doAll: (BOOL) doAll;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
@end
|