Neil Hodgson
2013-09-06 03:21:37 UTC
Currently, code that wants to use ScintillaView is exposed to the implementation of the class ScintillaCocoa which causes it to see and be dependent on almost all of Scintilla's implementation. The additional 30 or so headers included slows down building and running analysis tools and can cause client code to break when changes are made to private Scintilla headers.
To fix this, I'd like to remove the #import of ScintillaCocoa.h from ScintillaView.h and add to ScintillaView.h just the few definitions needed by clients. Essentially:
#define WM_COMMAND 1001
#define WM_NOTIFY 1002
namespace Scintilla {
typedef void(*SciNotifyFunc) (intptr_t windowid, unsigned int iMessage, uintptr_t wParam, uintptr_t lParam);
class ScintillaCocoa; // ScintillaView has a property of this type so empty definition allows header to compile
}
Platform.h should also be removed as its for internal communication between Scintilla and platform layers. Scintilla.h and SciLexer.h could also be removed but some may see these as a necessary part of the interface to ScintillaView so want them to remain bundled.
Some implementors may want to write their applications in pure Objective C instead of Objective C++ and there are C++ features exposed through Scintilla's headers that currently make this impossible. On other platforms, Scintilla is accessible from C.
If we could depend on the modern (64-bit) runtime, the @private implementation details in the ScintillaView.h classes could be hidden inside ScintillaView.mm. Probably still too early to drop 32-bit builds, though.
ScintillaView contains an NSScrollView to handle scrolling and InnerView and MarginView objects to implement the text and margins. Sometimes client code would like to change ScintillaView behaviour. This can be done in some cases by subclassing ScintillaView. For example, SciTE uses a subclass of ScintillaView to handle some mouse click events. However, much of the functionality is provided by the InnerView class and to a lesser extent MarginView and neither of these can be subclassed.
A bug report today, https://sourceforge.net/p/scintilla/bugs/1522/ , reports that scrolling with a wheel mouse is too slow and provides a patch to InnerView. While it would be best if this can be fixed well within Scintilla, if that is not possible, some application authors may want to include their own fix and not have it overwritten whenever Scintilla is updated.
This could be achieved through a few different mechanisms. One is to have a method on ScintillaView to create the InnerView object. Applications can subclass ScintillaView and return a subclass of InnerView with their changes. For example,
@interface WheelScrollInnerView : InnerView
@end
@interface EditView : ScintillaView;
@end
@implementation WheelScrollInnerView
// Override wheel scrolling as too slow with real wheel mouse.
- (void) scrollWheel: (NSEvent *) theEvent {
if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) {
[super scrollWheel:theEvent];
} else {
int deltaX = theEvent.deltaX < 0. ? -floorf(theEvent.deltaX) : -ceilf(theEvent.deltaX);
int deltaY = theEvent.deltaY < 0. ? -floorf(theEvent.deltaY) : -ceilf(theEvent.deltaY);
[self.owner message: SCI_LINESCROLL wParam: deltaX lParam: deltaY];
}
}
@end
@implementation EditView;
- (InnerView *)allocateInner {
return [[WheelScrollInnerView alloc] init];
}
@end
Neil
To fix this, I'd like to remove the #import of ScintillaCocoa.h from ScintillaView.h and add to ScintillaView.h just the few definitions needed by clients. Essentially:
#define WM_COMMAND 1001
#define WM_NOTIFY 1002
namespace Scintilla {
typedef void(*SciNotifyFunc) (intptr_t windowid, unsigned int iMessage, uintptr_t wParam, uintptr_t lParam);
class ScintillaCocoa; // ScintillaView has a property of this type so empty definition allows header to compile
}
Platform.h should also be removed as its for internal communication between Scintilla and platform layers. Scintilla.h and SciLexer.h could also be removed but some may see these as a necessary part of the interface to ScintillaView so want them to remain bundled.
Some implementors may want to write their applications in pure Objective C instead of Objective C++ and there are C++ features exposed through Scintilla's headers that currently make this impossible. On other platforms, Scintilla is accessible from C.
If we could depend on the modern (64-bit) runtime, the @private implementation details in the ScintillaView.h classes could be hidden inside ScintillaView.mm. Probably still too early to drop 32-bit builds, though.
ScintillaView contains an NSScrollView to handle scrolling and InnerView and MarginView objects to implement the text and margins. Sometimes client code would like to change ScintillaView behaviour. This can be done in some cases by subclassing ScintillaView. For example, SciTE uses a subclass of ScintillaView to handle some mouse click events. However, much of the functionality is provided by the InnerView class and to a lesser extent MarginView and neither of these can be subclassed.
A bug report today, https://sourceforge.net/p/scintilla/bugs/1522/ , reports that scrolling with a wheel mouse is too slow and provides a patch to InnerView. While it would be best if this can be fixed well within Scintilla, if that is not possible, some application authors may want to include their own fix and not have it overwritten whenever Scintilla is updated.
This could be achieved through a few different mechanisms. One is to have a method on ScintillaView to create the InnerView object. Applications can subclass ScintillaView and return a subclass of InnerView with their changes. For example,
@interface WheelScrollInnerView : InnerView
@end
@interface EditView : ScintillaView;
@end
@implementation WheelScrollInnerView
// Override wheel scrolling as too slow with real wheel mouse.
- (void) scrollWheel: (NSEvent *) theEvent {
if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) {
[super scrollWheel:theEvent];
} else {
int deltaX = theEvent.deltaX < 0. ? -floorf(theEvent.deltaX) : -ceilf(theEvent.deltaX);
int deltaY = theEvent.deltaY < 0. ? -floorf(theEvent.deltaY) : -ceilf(theEvent.deltaY);
[self.owner message: SCI_LINESCROLL wParam: deltaX lParam: deltaY];
}
}
@end
@implementation EditView;
- (InnerView *)allocateInner {
return [[WheelScrollInnerView alloc] init];
}
@end
Neil
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scintilla-interest+***@googlegroups.com.
To post to this group, send email to scintilla-***@googlegroups.com.
Visit this group at http://groups.google.com/group/scintilla-interest.
For more options, visit https://groups.google.com/groups/opt_out.