Merge remote-tracking branch 'upstream/master' into CPTableView-enumerateRows

Conflicts:
	AppKit/CPTableView.j
This commit is contained in:
cacaodev
2014-10-01 14:11:57 +02:00
30 changed files with 3522 additions and 1114 deletions
+2 -2
View File
@@ -448,7 +448,7 @@ var CPMainCibFile = @"CPMainCibFile",
[CPPlatform activateIgnoringOtherApps:shouldIgnoreOtherApps];
_isActive = YES;
[self _willResignActive];
[self _didBecomeActive];
}
- (void)deactivate
@@ -1173,7 +1173,7 @@ var CPMainCibFile = @"CPMainCibFile",
[[self keyWindow] orderFront:self];
else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self];
else
else if ([self mainMenu])
[[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil;
+38 -12
View File
@@ -47,18 +47,7 @@
if (_documentView)
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:CPViewFrameDidChangeNotification
object:_documentView];
[defaultCenter
removeObserver:self
name:CPViewBoundsDidChangeNotification
object:_documentView];
[self _removeObserverDocumentView:_documentView];
[_documentView removeFromSuperview];
}
@@ -91,6 +80,43 @@
object:_documentView];
}
- (void)_removeObserverDocumentView:(CPView)aDocumentView
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:CPViewFrameDidChangeNotification
object:_documentView];
[defaultCenter
removeObserver:self
name:CPViewBoundsDidChangeNotification
object:_documentView];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
if (_documentView)
[self _observeDocumentView];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
if (_documentView)
[self _removeObserverDocumentView:_documentView];
}
/*!
Returns the document view.
*/
+39 -5
View File
@@ -86,14 +86,12 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
_active = NO;
_color = [CPColor whiteColor];
[self setBordered:YES];
[self _registerForNotifications];
}
return self;
}
- (void)_registerForNotifications
- (void)_registerNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
@@ -110,6 +108,22 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
object:[CPColorPanel sharedColorPanel]];
}
- (void)_removeNotifications
{
var defaultCenter = [CPNotificationCenter defaultCenter];
[defaultCenter
removeObserver:self
name:_CPColorWellDidBecomeExclusiveNotification
object:nil];
[defaultCenter
removeObserver:self
name:CPWindowWillCloseNotification
object:[CPColorPanel sharedColorPanel]];
}
/*!
Sets whether the color well is bordered.
*/
@@ -312,6 +326,28 @@ var _CPColorWellDidBecomeExclusiveNotification = @"_CPColorWellDidBecomeExclusiv
[contentBorderView setBackgroundColor:[self currentValueForThemeAttribute:@"content-border-color"]];
}
#pragma mark -
#pragma mark Observers method
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _registerNotifications];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _removeNotifications];
}
@end
@implementation CPColorWellValueBinder : CPBinder
@@ -363,8 +399,6 @@ var CPColorWellColorKey = "CPColorWellColorKey",
_active = NO;
_color = [aCoder decodeObjectForKey:CPColorWellColorKey];
[self setBordered:[aCoder decodeBoolForKey:CPColorWellBorderedKey]];
[self _registerForNotifications];
}
return self;
+4 -1
View File
@@ -75,6 +75,7 @@ CPEraDatePickerElementFlag = 0x0100;
CPInteger _datePickerStyle @accessors(property=datePickerStyle);
CPInteger _timeInterval @accessors(property=timeInterval);
BOOL _invokedByUserEvent;
_CPDatePickerTextField _datePickerTextfield;
_CPDatePickerCalendar _datePickerCalendar;
unsigned _implementedCDatePickerDelegateMethods;
@@ -312,6 +313,7 @@ CPEraDatePickerElementFlag = 0x0100;
if (aDateValue == nil)
return;
_invokedByUserEvent = NO;
[self _setDateValue:aDateValue timeInterval:_timeInterval];
}
@@ -359,7 +361,8 @@ CPEraDatePickerElementFlag = 0x0100;
_timeInterval = (_datePickerMode == CPSingleDateMode)? 0 : aTimeInterval;
[self didChangeValueForKey:@"timeInterval"];
[self sendAction:[self action] to:[self target]];
if (_invokedByUserEvent)
[self sendAction:[self action] to:[self target]];
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
[_datePickerTextfield setDateValue:_dateValue];
@@ -896,6 +896,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_indexDayTile = -1;
_eventDragged = nil
_datePicker._invokedByUserEvent = YES;
// Check if we have to change or not the month of the component
if ([dayTile date].getMonth() == _date.getMonth())
{
@@ -948,6 +950,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
else
[_delegate _displayNextMonth];
}
_datePicker._invokedByUserEvent = NO;
}
/*! Mouse dragged event
@@ -965,6 +969,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
_indexDayTile = [self indexOfTileForEvent:anEvent];
_eventDragged = anEvent;
_datePicker._invokedByUserEvent = YES;
if ([_datePicker datePickerMode] == CPSingleDateMode)
{
// Check if we have to change or not the month of the component
@@ -1006,6 +1012,8 @@ var CPShortWeekDayNameArrayEn = [@"Mo", @"Tu", @"We", @"Th", @"Fr", @"Sa", @"Su"
[_datePicker _setDateValue:[self _hoursMinutesSecondsFromDatePickerForDate:_clickDate] timeInterval:[dateTile timeIntervalSinceDate:dateValueAtMidnight]];
}
}
_datePicker._invokedByUserEvent = NO;
}
- (void)mouseUp:(CPEvent)anEvent
+71 -8
View File
@@ -92,8 +92,6 @@ var CPZeroKeyCode = 48,
[_stepper setAction:@selector(_clickStepper:)];
[self addSubview:_stepper];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldBecomeFirstResponder:) name:CPDatePickerElementTextFieldBecomeFirstResponder object:self];
[self setNeedsLayout];
[self setNeedsDisplay:YES];
}
@@ -414,6 +412,30 @@ var CPZeroKeyCode = 48,
[_datePickerElementView setNeedsLayout];
}
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPDatePickerElementTextFieldBecomeFirstResponder object:self];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldBecomeFirstResponder:) name:CPDatePickerElementTextFieldBecomeFirstResponder object:self];
}
@end
@@ -524,8 +546,6 @@ var CPZeroKeyCode = 48,
[self addSubview: _textFieldSeparatorThree];
[self addSubview: _textFieldSeparatorFour];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldAMPMChangedNotification:) name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
[self setNeedsLayout];
}
@@ -533,9 +553,37 @@ var CPZeroKeyCode = 48,
#pragma mark -
#pragma mark Responder methods
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
return NO;
// This is needed to accept to be firstResponder when nothing is selected.
// This element needs to be first responder when the CPDatePicker is in the CPTableView
// When clicking on a row of a CPTableView where there isn't a date element, the CPTableView will ask this element to know if it can becomes or not a firstResponder.
return [_datePicker isEnabled] && ![self superview]._currentTextField;
}
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_datePickerElementTextFieldAMPMChangedNotification:) name:CPDatePickerElementTextFieldAMPMChangedNotification object:_textFieldPMAM];
}
@@ -679,7 +727,9 @@ var CPZeroKeyCode = 48,
dateValue.setHours(dateValue.getHours() - 12);
}
[_datePicker setDateValue:dateValue];
_datePicker._invokedByUserEvent = YES;
[_datePicker _setDateValue:dateValue timeInterval:[_datePicker timeInterval]];
_datePicker._invokedByUserEvent = NO;
}
@@ -1282,6 +1332,12 @@ var CPMonthDateType = 0,
return self;
}
/*! @ignore */
- (BOOL)acceptsFirstResponder
{
return [_datePicker isEnabled];
}
/*! Set the dateType of the textField
*/
- (void)setDateType:(int)aDateType
@@ -1636,7 +1692,9 @@ var CPMonthDateType = 0,
newDateValue.setSeconds(newDateValue.getSeconds() + secondsFromGMT - secondsFromGMTTimeZone);
}
[_datePicker setDateValue:newDateValue];
_datePicker._invokedByUserEvent = YES;
[_datePicker _setDateValue:newDateValue timeInterval:[_datePicker timeInterval]];
_datePicker._invokedByUserEvent = NO;
}
@@ -1734,4 +1792,9 @@ var CPMonthDateType = 0,
return frameSize;
}
@end
- (CGRect)bezelRectForBounds:(CGRect)bounds
{
return CGRectMakeCopy(bounds);
}
@end
+1
View File
@@ -178,6 +178,7 @@ var CPImageViewEmptyPlaceholderImage = nil;
- (void)imageDidLoad:(CPNotification)aNotification
{
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPImageDidLoadNotification object:[self objectValue]];
[self hideOrDisplayContents];
[self setNeedsLayout];
+43 -1
View File
@@ -70,6 +70,20 @@ var CPBindingOperationAnd = 0,
return [[bindingsMap objectForKey:[anObject UID]] objectForKey:aBinding];
}
+ (void)_reverseSetValueFromExclusiveBinderForObject:(id)anObject
{
var bindersByBindingName = [bindingsMap objectForKey:[anObject UID]];
[bindersByBindingName enumerateKeysAndObjectsUsingBlock:function(binding, binder, stop)
{
if ([binder isKindOfClass:[self class]])
{
[binder reverseSetValueFor:binding];
stop(YES);
}
}];
}
+ (CPDictionary)infoForBinding:(CPString)aBinding forObject:(id)anObject
{
var theBinding = [self getBinding:aBinding forObject:anObject];
@@ -116,7 +130,7 @@ var CPBindingOperationAnd = 0,
count = allKeys.length;
while (count--)
[anObject unbind:[bindings objectForKey:allKeys[count]]];
[anObject unbind:allKeys[count]];
[bindingsMap removeObjectForKey:[anObject UID]];
}
@@ -159,6 +173,24 @@ var CPBindingOperationAnd = 0,
return self;
}
+ (BOOL)isBindingAllowed:(CPString)aBinding forObject:(id)anObject
{
if ([[anObject class] isBindingExclusive:aBinding])
{
var bindingsForObject = [bindingsMap objectForKey:[anObject UID]],
allBindings = [bindingsForObject allKeys],
count = [allBindings count];
while(count--)
{
if ([[anObject class] isBindingExclusive:allBindings[count]])
return NO;
}
}
return YES;
}
- (void)raiseIfNotApplicable:(id)aValue forKeyPath:(CPString)keyPath options:(CPDictionary)options
{
if (aValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
@@ -387,6 +419,11 @@ var CPBindingOperationAnd = 0,
return [CPBinder class];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return NO;
}
- (CPArray)exposedBindings
{
var exposedBindings = [],
@@ -415,6 +452,11 @@ var CPBindingOperationAnd = 0,
if (!anObject || !aKeyPath)
return CPLog.error("Invalid object or path on " + self + " for " + aBinding);
if (![CPBinder isBindingAllowed:aBinding forObject:self])
{
CPLog.warn([self description] + " : cannot bind " + aBinding + " because another binding with the same functionality is already in use.");
return;
}
//if (![[self exposedBindings] containsObject:aBinding])
// CPLog.warn("No binding exposed on " + self + " for " + aBinding);
+14 -29
View File
@@ -771,13 +771,6 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
[[self selectedItem] setState:CPOffState];
}
- (void)_reverseSetBinding
{
[_CPPopUpButtonSelectionBinder reverseSetValueForObject:self];
[super _reverseSetBinding];
}
@end
@implementation CPPopUpButton (BindingSupport)
@@ -800,6 +793,20 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectedIndexBinding ||
aBinding == CPSelectedTagBinding ||
aBinding == CPSelectedValueBinding);
}
- (void)_reverseSetBinding
{
[_CPPopUpButtonSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
[super _reverseSetBinding];
}
@end
@implementation _CPPopUpButtonContentBinder : CPBinder
@@ -929,30 +936,8 @@ CPPopUpButtonStatePullsDown = CPThemeState("pulls-down");
@end
var binderForObject = {};
@implementation _CPPopUpButtonSelectionBinder : CPBinder
{
CPString _selectionBinding @accessors;
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
binderForObject[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = binderForObject[[aSource UID]];
[binder reverseSetValueFor:[binder _selectionBinding]];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
+8 -23
View File
@@ -356,7 +356,7 @@ var CPRadioRadioGroupKey = @"CPRadioRadioGroupKey";
[_selectedRadio setState:CPOffState];
_selectedRadio = aRadio;
[_CPRadioGroupSelectionBinder reverseSetValueForObject:self];
[_CPRadioGroupSelectionBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
@@ -407,32 +407,17 @@ var CPRadioGroupRadiosKey = @"CPRadioGroupRadiosKey",
return [super _binderClassForBinding:aBinding];
}
@end
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return (aBinding == CPSelectedIndexBinding ||
aBinding == CPSelectedTagBinding ||
aBinding == CPSelectedValueBinding);
}
var binderForObject = {};
@end
@implementation _CPRadioGroupSelectionBinder : CPBinder
{
CPString _selectionBinding @accessors;
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
binderForObject[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = binderForObject[[aSource UID]];
[binder reverseSetValueFor:[binder _selectionBinding]];
}
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
@@ -65,8 +65,6 @@
[self addSubview:_subtractButton];
[self setAutoresizingMask:CPViewWidthSizable];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_textDidChange:) name:CPControlTextDidChangeNotification object:nil];
}
- (CPButton)_createRowButton
@@ -491,6 +489,26 @@
[self layoutSubviews];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_textDidChange:) name:CPControlTextDidChangeNotification object:nil];
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:nil];
}
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
@@ -516,4 +534,4 @@
[self _sendRuleAction:nil];
}
@end
@end
+18 -6
View File
@@ -119,16 +119,28 @@ var RECENT_SEARCH_PREFIX = @" ";
_canResignFirstResponder = YES;
}
- (void)viewWillMoveToSuperview:(CPView)aView
#pragma mark -
#pragma mark Override observers
- (void)_removeObservers
{
[super viewWillMoveToSuperview:aView];
if (!_isObserving)
return;
[super _removeObservers];
// First we remove any observer that may have been in place to avoid memory leakage.
[[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:self];
}
// Register the observe here if we need to.
if (aView)
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
}
// Managing Buttons
+39 -48
View File
@@ -74,19 +74,6 @@ CPSegmentSwitchTrackingMomentary = 2;
};
}
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([self _isSelectionBinding:aBinding])
return [_CPSegmentedControlBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)_isSelectionBinding:(CPString)aBinding
{
return (aBinding === CPSelectedIndexBinding || aBinding === CPSelectedLabelBinding || aBinding === CPSelectedTagBinding);
}
- (id)initWithFrame:(CGRect)aRect
{
_segments = [];
@@ -104,19 +91,6 @@ CPSegmentSwitchTrackingMomentary = 2;
return self;
}
- (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
{
if ([[self class] _isSelectionBinding:aBinding] && _trackingMode !== CPSegmentSwitchTrackingSelectOne)
CPLog.warn("Binding " + aBinding + " needs CPSegmentSwitchTrackingSelectOne tracking mode");
else
[super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
}
- (void)_reverseSetBinding
{
[_CPSegmentedControlBinder reverseSetValueForObject:self];
}
/*!
Returns the tag of the selected segment.
*/
@@ -948,31 +922,48 @@ var CPSegmentedControlSegmentsKey = "CPSegmentedControlSegmentsKey",
@end
var CPSegmentedControlBindersMap = {},
CPSegmentedControlNoSelectionPlaceholder = "CPSegmentedControlNoSelectionPlaceholder";
@implementation CPSegmentedControl (BindingSupport)
+ (Class)_binderClassForBinding:(CPString)aBinding
{
if ([self _isSelectionBinding:aBinding])
return [_CPSegmentedControlBinder class];
return [super _binderClassForBinding:aBinding];
}
+ (BOOL)_isSelectionBinding:(CPString)aBinding
{
return (aBinding === CPSelectedIndexBinding || aBinding === CPSelectedLabelBinding || aBinding === CPSelectedTagBinding);
}
+ (BOOL)isBindingExclusive:(CPString)aBinding
{
return [self _isSelectionBinding:aBinding];
}
- (void)bind:(CPString)aBinding toObject:(id)anObject withKeyPath:(CPString)aKeyPath options:(CPDictionary)options
{
if ([[self class] _isSelectionBinding:aBinding] && _trackingMode !== CPSegmentSwitchTrackingSelectOne)
{
CPLog.warn("Binding " + aBinding + " needs CPSegmentSwitchTrackingSelectOne tracking mode");
return;
}
[super bind:aBinding toObject:anObject withKeyPath:aKeyPath options:options];
}
- (void)_reverseSetBinding
{
[_CPSegmentedControlBinder _reverseSetValueFromExclusiveBinderForObject:self];
}
@end
var CPSegmentedControlNoSelectionPlaceholder = "CPSegmentedControlNoSelectionPlaceholder";
@implementation _CPSegmentedControlBinder : CPBinder
{
CPString _selectionBinding @accessors(readonly, getter=selectionBinding);
}
+ (void)reverseSetValueForObject:(id)aSource
{
var binder = CPSegmentedControlBindersMap[[aSource UID]];
[binder reverseSetValueFor:[binder selectionBinding]];
}
- (id)initWithBinding:(CPString)aBinding name:(CPString)aName to:(id)aDestination keyPath:(CPString)aKeyPath options:(CPDictionary)options from:(id)aSource
{
self = [super initWithBinding:aBinding name:aName to:aDestination keyPath:aKeyPath options:options from:aSource];
if (self)
{
CPSegmentedControlBindersMap[[aSource UID]] = self;
_selectionBinding = aName;
}
return self;
}
- (void)_updatePlaceholdersWithOptions:(CPDictionary)options
+120 -92
View File
@@ -279,49 +279,49 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
CPTableHeaderView _headerView;
_CPCornerView _cornerView;
CPIndexSet _selectedColumnIndexes;
CPIndexSet _selectedRowIndexes;
CPInteger _selectionAnchorRow;
CPInteger _lastSelectedRow;
CPIndexSet _previouslySelectedRowIndexes;
CGPoint _startTrackingPoint;
CPDate _startTrackingTimestamp;
BOOL _trackingPointMovedOutOfClickSlop;
CPInteger _editingRow;
CPInteger _editingColumn;
CPIndexSet _selectedColumnIndexes;
CPIndexSet _selectedRowIndexes;
CPInteger _selectionAnchorRow;
CPInteger _lastSelectedRow;
CPIndexSet _previouslySelectedRowIndexes;
CGPoint _startTrackingPoint;
CPDate _startTrackingTimestamp;
BOOL _trackingPointMovedOutOfClickSlop;
CPInteger _editingRow;
CPInteger _editingColumn;
_CPTableDrawView _tableDrawView;
_CPTableDrawView _tableDrawView;
SEL _doubleAction;
CPInteger _clickedRow;
CPInteger _clickedColumn;
unsigned _columnAutoResizingStyle;
SEL _doubleAction;
CPInteger _clickedRow;
CPInteger _clickedColumn;
unsigned _columnAutoResizingStyle;
int _lastTrackedRowIndex;
CGPoint _originalMouseDownPoint;
BOOL _verticalMotionCanDrag;
unsigned _destinationDragStyle;
BOOL _isSelectingSession;
CPIndexSet _draggedRowIndexes;
BOOL _wasSelectionBroken;
int _lastTrackedRowIndex;
CGPoint _originalMouseDownPoint;
BOOL _verticalMotionCanDrag;
unsigned _destinationDragStyle;
BOOL _isSelectingSession;
CPIndexSet _draggedRowIndexes;
BOOL _wasSelectionBroken;
_CPDropOperationDrawingView _dropOperationFeedbackView;
CPDragOperation _dragOperationDefaultMask;
int _retargetedDropRow;
CPDragOperation _retargetedDropOperation;
CPDragOperation _dragOperationDefaultMask;
int _retargetedDropRow;
CPDragOperation _retargetedDropOperation;
BOOL _disableAutomaticResizing @accessors(property=disableAutomaticResizing);
BOOL _lastColumnShouldSnap;
BOOL _implementsCustomDrawRow;
BOOL _isViewBased;
BOOL _contentBindingExplicitlySet;
BOOL _disableAutomaticResizing @accessors(property=disableAutomaticResizing);
BOOL _lastColumnShouldSnap;
BOOL _implementsCustomDrawRow;
BOOL _isViewBased;
BOOL _contentBindingExplicitlySet;
SEL _viewForTableColumnRowSelector;
SEL _viewForTableColumnRowSelector;
CPInteger _draggedColumnIndex;
BOOL _draggedColumnIsSelected;
BOOL _needsDifferedTableColumnRemove;
CPArray _differedColumnDataToRemove;
CPArray _differedColumnDataToRemove;
Function _BlockDeselectView;
Function _BlockSelectView;
@@ -1431,7 +1431,7 @@ NOT YET IMPLEMENTED
if (_selectionHighlightStyle !== CPTableViewSelectionHighlightStyleNone)
[self _enumerateViewsInRows:newRows columns:_exposedColumns usingBlock:_BlockSelectView];
}
}
/*!
@ignore
@@ -1439,7 +1439,7 @@ NOT YET IMPLEMENTED
- (void)_updateHighlightWithOldColumns:(CPIndexSet)oldColumns newColumns:(CPIndexSet)newColumns
{
var blockDeselectHeader = function(column, stop)
{
{
var headerView = [_tableColumns[column] headerView];
[headerView unsetThemeState:CPThemeStateSelected];
};
@@ -1450,15 +1450,15 @@ NOT YET IMPLEMENTED
[oldColumns enumerateIndexesUsingBlock:blockDeselectHeader];
if (_selectionHighlightStyle !== CPTableViewSelectionHighlightStyleNone)
{
{
[self _enumerateViewsInRows:_exposedRows columns:newColumns usingBlock:_BlockSelectView];
[newColumns enumerateIndexesUsingBlock:function(column, stop)
{
{
var headerView = [_tableColumns[column] headerView];
[headerView setThemeState:CPThemeStateSelected];
}];
}
}
}
}
/*!
Returns the index of the last selected column.
@@ -1608,7 +1608,7 @@ NOT YET IMPLEMENTED
*/
- (int)numberOfRows
{
return _numberOfRows;
return _numberOfRows;
}
- (int)_numberOfRows
@@ -1628,9 +1628,9 @@ NOT YET IMPLEMENTED
else
{
if (_dataSource)
CPLog(@"no content binding established and data source " + [_dataSource description] + " does not implement numberOfRowsInTableView:");
CPLog(@"no content binding established and data source " + [_dataSource description] + " does not implement numberOfRowsInTableView:");
numberOfRows = 0;
}
}
return numberOfRows;
}
@@ -2081,45 +2081,45 @@ NOT YET IMPLEMENTED
if (aView && [aView isKindOfClass:[CPView class]] && ![aView isKindOfClass:[CPTableView class]])
{
var cellView = aView,
contentView = [[self window] contentView],
var cellView = aView,
contentView = [[self window] contentView],
found = NO,
max_rec = 100;
max_rec = 100;
while (max_rec--)
while (max_rec--)
{
if (!cellView || cellView === contentView)
{
if (!cellView || cellView === contentView)
{
found = NO;
break;
}
else
{
var superview = [cellView superview];
if ([superview isKindOfClass:[CPTableView class]])
{
found = YES;
break;
}
cellView = superview;
}
}
else
{
var superview = [cellView superview];
if ([superview isKindOfClass:[CPTableView class]])
{
found = YES;
break;
}
cellView = superview;
}
}
if (found)
{
{
[self _enumerateViewsInRows:_exposedRows columns:_exposedColumns usingBlock:function(view, row, column, stop)
{
if (view === cellView)
{
{
columnResult = column;
rowResult = row;
stop(YES);
}
}];
}
}];
}
}
if (columnRef)
@@ -3496,7 +3496,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if (columnIdx !== CPNotFound)
[removeIndexes addIndex:columnIdx];
}
}
var rowIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self numberOfRows])];
[self _unloadDataViewsInRows:rowIndexes columns:removeIndexes];
@@ -3542,9 +3542,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
delete (dataViewsForRows[tableColumnUID]);
[self _enqueueReusableDataView:dataView];
[self _enqueueReusableDataView:dataView];
}];
}
}
/*!
@ignore
@@ -3586,7 +3586,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
}
- (CPView)preparedViewAtColumn:(CPInteger)column row:(CPInteger)row
{
{
return [self _preparedViewAtColumn:column row:row isRowSelected:[self isRowSelected:row]];
}
@@ -3596,43 +3596,43 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
tableColumnUID = [tableColumn UID],
dataView = [self _newDataViewForRow:row tableColumn:tableColumn];
[dataView setFrame:[self frameOfDataViewAtColumn:column row:row]];
[dataView setFrame:[self frameOfDataViewAtColumn:column row:row]];
[self _setObjectValueForTableColumn:tableColumn row:row forView:dataView];
[self _setObjectValueForTableColumn:tableColumn row:row forView:dataView];
if (_selectionHighlightStyle !== CPTableViewSelectionHighlightStyleNone &&
(isRowSelected || [self isColumnSelected:column]))
_BlockSelectView(dataView, row, column);
else
else
_BlockDeselectView(dataView, row, column);
// FIX ME: for performance reasons we might consider diverging from cocoa and moving this to the reloadData method
// FIX ME: for performance reasons we might consider diverging from cocoa and moving this to the reloadData method
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_isGroupRow_)
{
{
if ([_delegate tableView:self isGroupRow:row])
{
[_groupRows addIndex:row];
[dataView setThemeState:CPThemeStateGroupRow];
}
else
{
[_groupRows removeIndexesInRange:CPMakeRange(row, 1)];
[dataView unsetThemeState:CPThemeStateGroupRow];
}
[_groupRows addIndex:row];
[dataView setThemeState:CPThemeStateGroupRow];
}
else
{
[_groupRows removeIndexesInRange:CPMakeRange(row, 1)];
[dataView unsetThemeState:CPThemeStateGroupRow];
}
[self setNeedsDisplay:YES];
[self setNeedsDisplay:YES];
}
if (_implementedDelegateMethods & CPTableViewDelegate_tableView_willDisplayView_forTableColumn_row_)
[_delegate tableView:self willDisplayView:dataView forTableColumn:tableColumn row:row];
return dataView;
}
}
- (void)_setObjectValueForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow forView:(CPView)aDataView
{
{
[self _setObjectValueForTableColumn:aTableColumn row:aRow forView:aDataView useCache:!_invalidateObjectValuesCache];
}
}
- (void)_setObjectValueForTableColumn:(CPTableColumn)aTableColumn row:(CPInteger)aRow forView:(CPView)aDataView useCache:(BOOL)useCache
{
@@ -3667,7 +3667,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
{
[view setFrame:[self frameOfDataViewAtColumn:column row:row]];
}];
}
}
/*!
@ignore
@@ -3696,8 +3696,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
identifier = [[aTableColumn dataView] UID];
view = [self makeViewWithIdentifier:identifier owner:_delegate];
if (!view)
view = [aTableColumn _newDataView];
if (!view)
view = [aTableColumn _newDataView];
}
[view setIdentifier:identifier];
@@ -3875,6 +3875,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
// FIXME: yuck!
var identifier = [aDataView identifier];
if ([aDataView hasThemeState:CPThemeStateSelectedDataView])
[aDataView unsetThemeState:CPThemeStateSelectedDataView];
if (!_cachedDataViews[identifier])
_cachedDataViews[identifier] = [aDataView];
else
@@ -4376,6 +4379,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
*/
- (void)viewWillMoveToSuperview:(CPView)aView
{
[super viewWillMoveToSuperview:aView];
var superview = [self superview],
defaultCenter = [CPNotificationCenter defaultCenter];
@@ -5047,7 +5052,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
[self getColumn:@ref(column) row:@ref(row) forView:aView];
if (![self isRowSelected:row])
return self;
return self;
}
else if (!_isViewBased && [aView isKindOfClass:[CPControl class]] && ![aView isKindOfClass:[CPTextField class]])
{
@@ -5062,6 +5067,24 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
return aView;
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _stopObservingFirstResponder];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
[self _startObservingFirstResponder];
}
- (void)_startObservingFirstResponder
{
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_firstResponderDidChange:) name:_CPWindowDidChangeFirstResponderNotification object:[self window]];
@@ -5081,7 +5104,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
[self getColumn:@ref(column) row:@ref(row) forView:responder];
if (row == CPNotFound && column == CPNotFound)
[self _notifyViewDidResignFirstResponder];
[self _notifyViewDidResignFirstResponder];
_editingRow = row;
_editingColumn = column;
@@ -5121,7 +5144,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
[self _commitDataViewObjectValue:textField];
}
else
[textField setBezeled:NO];
[textField setBezeled:NO];
[self _resignFirstResponderWithoutSendingAction:textField];
}
@@ -6058,6 +6081,11 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
{
[super encodeWithCoder:aCoder];
// We do this in order to avoid encoding the _tableDrawView, which
// should just automatically be created programmatically as needed.
if (_tableDrawView)
[_tableDrawView removeFromSuperview];
[aCoder encodeObject:_dataSource forKey:CPTableViewDataSourceKey];
[aCoder encodeObject:_delegate forKey:CPTableViewDelegateKey];
@@ -6238,7 +6266,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
//[tableView drawBackgroundInClipRect:bounds];
if (tableView._draggedColumnIsSelected)
{
{
CGContextSetFillColor(context, [tableView selectionHighlightColor]);
CGContextFillRect(context, bounds);
}
+20
View File
@@ -834,6 +834,26 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
}
}
- (void)_removeObservers
{
if (!_isObserving)
return;
[super _removeObservers];
[self _setObserveWindowKeyNotifications:NO];
}
- (void)_addObservers
{
if (_isObserving)
return;
[super _addObservers];
if ([self window] === self)
[self _setObserveWindowKeyNotifications:YES];
}
- (void)_windowDidResignKey:(CPNotification)aNotification
{
if (![[self window] isKeyWindow])
+69 -21
View File
@@ -228,6 +228,8 @@ var CPViewFlags = { },
Function _toolTipFunctionIn;
Function _toolTipFunctionOut;
BOOL _toolTipInstalled;
BOOL _isObserving;
}
/*
@@ -508,8 +510,12 @@ var CPViewFlags = { },
[CPException raise:CPInvalidArgumentException reason:"can't insert a subview in duplicate (probably partially decoded)"];
#endif
// Notify the subview that it will be moving.
[aSubview viewWillMoveToSuperview:self];
// We will have to adjust the z-index of all views starting at this index.
var count = _subviews.length;
var count = _subviews.length,
lastWindow;
// Dirty the key view loop, in case the window wants to auto recalculate it
[[self window] _dirtyKeyViewLoop];
@@ -537,14 +543,12 @@ var CPViewFlags = { },
}
else
{
var superview = aSubview._superview;
lastWindow = [superview window];
// Remove the view from its previous superview.
[aSubview removeFromSuperview];
// Set the subview's window to our own.
[aSubview _setWindow:_window];
// Notify the subview that it will be moving.
[aSubview viewWillMoveToSuperview:self];
[aSubview _removeFromSuperview];
// Set ourselves as the superview.
aSubview._superview = self;
@@ -577,6 +581,15 @@ var CPViewFlags = { },
if (![aSubview isHidden] && [self isHiddenOrHasHiddenAncestor])
[aSubview _notifyViewDidHide];
[aSubview viewDidMoveToSuperview];
// Set the subview's window to our own.
if (_window)
[aSubview _setWindow:_window];
if (!_window && lastWindow)
[aSubview _setWindow:nil];
// This method might be called before we are fully unarchived, in which case the theme state isn't set up yet
// and none of the below matters anyhow.
if (_themeState)
@@ -592,8 +605,6 @@ var CPViewFlags = { },
[aSubview _notifyWindowDidResignKey];
}
[aSubview viewDidMoveToSuperview];
[self didAddSubview:aSubview];
}
@@ -610,6 +621,18 @@ var CPViewFlags = { },
Does nothing if there's no container view.
*/
- (void)removeFromSuperview
{
var superview = _superview;
[self viewWillMoveToSuperview:nil];
[self _removeFromSuperview];
[self viewDidMoveToSuperview];
if (superview)
[self _setWindow:nil];
}
- (void)_removeFromSuperview
{
if (!_superview)
return;
@@ -634,8 +657,6 @@ var CPViewFlags = { },
[self _notifyViewDidResignFirstResponder];
_superview = nil;
[self _setWindow:nil];
}
/*!
@@ -645,14 +666,14 @@ var CPViewFlags = { },
*/
- (void)replaceSubview:(CPView)aSubview with:(CPView)aView
{
if (aSubview._superview !== self)
if (aSubview._superview !== self || aSubview === aView)
return;
var index = [_subviews indexOfObjectIdenticalTo:aSubview];
[aSubview removeFromSuperview];
[self _insertSubview:aView atIndex:index];
[aSubview removeFromSuperview];
}
- (void)setSubviews:(CPArray)newSubviews
@@ -727,13 +748,10 @@ var CPViewFlags = { },
/* @ignore */
- (void)_setWindow:(CPWindow)aWindow
{
if (_window === aWindow)
return;
[[self window] _dirtyKeyViewLoop];
// Clear out first responder if we're the first responder and leaving.
if ([_window firstResponder] === self)
if ([_window firstResponder] === self && _window != aWindow)
[_window makeFirstResponder:nil];
// Notify the view and its subviews
@@ -803,6 +821,10 @@ var CPViewFlags = { },
*/
- (void)viewWillMoveToSuperview:(CPView)aView
{
[self _removeObservers];
if (aView)
[self _addObservers];
}
/*!
@@ -821,6 +843,32 @@ var CPViewFlags = { },
{
}
- (void)_removeObservers
{
if (!_isObserving)
return;
var count = [_subviews count];
while (count--)
[_subviews[count] _removeObservers];
_isObserving = NO;
}
- (void)_addObservers
{
if (_isObserving)
return;
var count = [_subviews count];
while (count--)
[_subviews[count] _addObservers];
_isObserving = YES;
}
/*!
Returns the menu item containing the receiver or one of its ancestor views.
@return a menu item, or \c nil if the view or one of its ancestors wasn't found
@@ -2964,10 +3012,10 @@ setBoundsOrigin:
- (BOOL)unsetThemeState:(ThemeState)aState
{
if (aState && aState.isa && [aState isKindOfClass:CPArray])
if (aState && aState.isa && [aState isKindOfClass:CPArray])
aState = CPThemeState.apply(null, aState);
var oldThemeState = _themeState
var oldThemeState = _themeState;
_themeState = _themeState.without(aState);
if (oldThemeState === _themeState)
+4
View File
@@ -901,6 +901,8 @@ CPTexturedBackgroundWindowMask
- (void)_orderFront
{
[[self contentView] _addObservers];
#if PLATFORM(DOM)
// -dw- if a sheet is clicked, the parent window should come up too
if (_isSheet)
@@ -960,6 +962,8 @@ CPTexturedBackgroundWindowMask
if (!_isVisible)
return;
[[self contentView] _removeObservers];
if ([self isSheet])
{
// -dw- as in Cocoa, orderOut: detaches the sheet and animates out
+1 -1
View File
@@ -1280,7 +1280,7 @@ var PreventScroll = true;
insertionIndex = _windowLevels[middle] > aLevel ? middle : middle + 1
[_windowLevels insertObject:aLevel atIndex:insertionIndex];
layer._DOMElement.style.zIndex = aLevel;
layer._DOMElement.style.zIndex = aLevel + 1; // adding one avoids negative zIndices. These have been causing issues in Chrome
_DOMBodyElement.appendChild(layer._DOMElement);
}
+18 -3
View File
@@ -345,6 +345,7 @@ var CPStringUIDs = new CFMutableDictionary(),
specified mask which can be a combination of:
<pre>
CPCaseInsensitiveSearch
CPDiacriticInsensitiveSearch
CPLiteralSearch
CPBackwardsSearch
CPAnchoredSearch
@@ -366,6 +367,7 @@ var CPStringUIDs = new CFMutableDictionary(),
options specified in the specified mask which can be a combination of:
<pre>
CPCaseInsensitiveSearch
CPDiacriticInsensitiveSearch
CPLiteralSearch
CPBackwardsSearch
CPAnchoredSearch
@@ -393,6 +395,11 @@ var CPStringUIDs = new CFMutableDictionary(),
string = string.toLowerCase();
aString = aString.toLowerCase();
}
if (aMask & CPDiacriticInsensitiveSearch)
{
string = string.stripDiacritics();
aString = aString.stripDiacritics();
}
if (aMask & CPBackwardsSearch)
{
@@ -682,6 +689,14 @@ var CPStringNull = [CPNull null];
return self.toUpperCase();
}
/*!
Returns a copy of the string stripped of diacritical marks.
*/
- (CPString)stripDiacritics
{
return self.stripDiacritics();
}
/*!
Returns the text as a floating point value.
*/
@@ -948,9 +963,9 @@ var CPStringNull = [CPNull null];
@end
var diacritics = [[192,198],[224,230],[231,231],[232,235],[236,239],[242,246],[249,252]], // Basic Latin ; Latin-1 Supplement.
normalized = [65,97,99,101,105,111,117];
var diacritics = [[192,198],[200,203],[204,207],[210,214],[217,220],[224,230],
[231,231],[232,235],[236,239],[242,246],[249,252]], // Basic Latin ; Latin-1 Supplement.
normalized = [65,69,73,79,85,97,99,101,105,111,117];
String.prototype.stripDiacritics = function()
{
+12 -4
View File
@@ -383,7 +383,7 @@ var ObjJAcornCompiler = function(/*String*/ aString, /*CFURL*/ aURL, /*unsigned*
this.tokens = exports.acorn.parse(aString);
}
catch (e) {
if (e.lineStart)
if (e.lineStart != null)
{
var message = this.prettifyMessage(e, "ERROR");
#ifdef BROWSER
@@ -1778,7 +1778,8 @@ ClassDeclarationStatement: function(node, st, c) {
var getterSetterBuffer = new StringBuffer();
// Add the class declaration to compile accessors correctly
getterSetterBuffer.concat(compiler.source.substring(node.start, node.endOfIvars));
// Remove all protocols from class declaration
getterSetterBuffer.concat(compiler.source.substring(node.start, node.endOfIvars).replace(/<.*>/g, ""));
getterSetterBuffer.concat("\n");
for (var i = 0; i < node.ivardeclarations.length; ++i)
@@ -1893,8 +1894,15 @@ ClassDeclarationStatement: function(node, st, c) {
// Lookup the protocolDefs for the protocols
var protocolDefs = [];
for (var i = 0, size = protocols.length; i < size; i++)
protocolDefs.push(compiler.getProtocolDef(protocols[i].name));
for (var i = 0, size = protocols.length; i < size; i++) {
var protocol = protocols[i],
protocolDef = compiler.getProtocolDef(protocol.name);
if (!protocolDef)
throw compiler.error_message("Cannot find protocol declaration for '" + protocol.name + "'", protocol);
protocolDefs.push(protocolDef);
}
var unimplementedMethods = classDef.listOfNotImplementedMethodsForProtocols(protocolDefs);
+18
View File
@@ -342,6 +342,24 @@
[self assert:@"brie" equals:[control2 objectValue] message:@"control2 objectValue is wrong"];
}
- (void)testExclusiveBindings
{
var segmented = [[CPSegmentedControl alloc] initWithFrame:CGRectMakeZero()];
[segmented setSegmentCount:3];
var model = [BindingTester testerWithCheese:2];
[segmented bind:CPSelectedIndexBinding toObject:model withKeyPath:@"cheese" options:nil];
// Try to bind another binding (mutually exclusive) to the same value.
[segmented bind:CPSelectedTagBinding toObject:model withKeyPath:@"cheese" options:nil];
[self assertNotNull:[segmented infoForBinding:CPSelectedIndexBinding]];
// Check that the source is not binded with the CPSelectedTagBinding
[self assertNull:[segmented infoForBinding:CPSelectedTagBinding]];
}
@end
@implementation TextField : CPTextField
+222
View File
@@ -4,14 +4,33 @@
[CPApplication sharedApplication]
var methodCalled;
@implementation CPViewTest : OJTestCase
{
CPView view;
CPView view1;
CPView view2;
CPView view3;
CPWindow window;
}
- (void)setUp
{
window = [[CPWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 1000.0, 1000.0) styleMask:CPWindowNotSizable];
view = [[CPView alloc] initWithFrame:CGRectMakeZero()];
view1 = [[CPResponderView alloc] initWithFrame:CGRectMakeZero()];
view2 = [[CPResponderView alloc] initWithFrame:CGRectMakeZero()];
view3 = [[CPResponderView alloc] initWithFrame:CGRectMakeZero()];
[view1 setIdentifier:@"view1"];
[view2 setIdentifier:@"view2"];
[view3 setIdentifier:@"view3"];
methodCalled = [];
[super setUp];
}
@@ -446,10 +465,213 @@
[self assertFalse:[subview hasThemeState:CPThemeStateFirstResponder]];
}
- (void)testWhenAddedSubviewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewWithoutWindowMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2"];
[view1 addSubview:view2];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewTwiceMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[[window contentView] addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenRemovedSubviewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1"];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewThenRemovedSubviewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
methodCalled = [];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedSubviewThenRemovedSubviewWithoutWindowMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1"];
[view1 addSubview:view2];
methodCalled = [];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2",@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", "viewDidMoveToWindow_view1"];
[view1 addSubview:view2];
[[window contentView] addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenRemovedMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", "viewDidMoveToWindow_view1"];
[view1 addSubview:view2];
[[window contentView] addSubview:view1];
methodCalled = [];
[view1 removeFromSuperview];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenAddedTheViewToAnotherViewWithoutWindowMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", @"viewWillMoveToWindow_view1", @"viewDidMoveToWindow_view1", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", @"viewWillMoveToWindow_view1", @"viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[view2 addSubview:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedOneSubviewsWithSetSubviewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] setSubviews:[view1]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsWithSetSubviewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1", @"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2"];
[[window contentView] setSubviews:[view1, view2]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenSetSubviewsWithOneViewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2"];
[[window contentView] setSubviews:[view1, view2]];
methodCalled = [];
[[window contentView] setSubviews:[view1]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenAddedTwoSubviewsThenSetSubviewsWithTwoViewsMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", @"viewWillMoveToSuperview_view3", @"viewDidMoveToSuperview_view3", "viewWillMoveToWindow_view3", "viewDidMoveToWindow_view3"];
[[window contentView] setSubviews:[view1, view2]];
methodCalled = [];
[[window contentView] setSubviews:[view1, view3]];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenReplacedViewWithSameViewMethodCalled
{
var expectedRestult = [];
[[window contentView] addSubview:view1];
methodCalled = [];
[[window contentView] replaceSubview:view1 with:view1];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenReplacedViewWithOtherViewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
methodCalled = [];
[[window contentView] replaceSubview:view1 with:view2];
[self assert:expectedRestult equals:methodCalled];
}
- (void)testWhenReplacedViewWithOtherAddedViewMethodCalled
{
var expectedRestult = [@"viewWillMoveToSuperview_view2", @"viewDidMoveToSuperview_view2", "viewWillMoveToWindow_view2", "viewDidMoveToWindow_view2", @"viewWillMoveToSuperview_view1", @"viewDidMoveToSuperview_view1", "viewWillMoveToWindow_view1", "viewDidMoveToWindow_view1"];
[[window contentView] addSubview:view1];
[[window contentView] addSubview:view2];
methodCalled = [];
[[window contentView] replaceSubview:view1 with:view2];
[self assert:expectedRestult equals:methodCalled];
}
@end
@implementation CPResponderView : CPView
- (void)viewDidMoveToSuperview
{
var string = @"viewDidMoveToSuperview_" + [self identifier];
[methodCalled addObject:string];
}
- (void)viewDidMoveToWindow
{
var string = @"viewDidMoveToWindow_" + [self identifier];
[methodCalled addObject:string];
}
- (void)viewWillMoveToSuperview:(CPView)newSuperview
{
var string = @"viewWillMoveToSuperview_" + [self identifier];
[methodCalled addObject:string];
}
- (void)viewWillMoveToWindow:(CPWindow)newWindow
{
var string = @"viewWillMoveToWindow_" + [self identifier];
[methodCalled addObject:string];
}
- (BOOL)acceptsFirstResponder
{
return YES;
+7
View File
@@ -572,4 +572,11 @@
[self assertThrows:function () { [@"Objective-J" compare:[CPNull null]] }];
}
- (void)testStripDiacritics
{
[self assert:[@"áa ée íi óo úu" stripDiacritics] equals:@"aa ee ii oo uu"];
[self assert:[@"ÁA ÉE ÍI ÓO ÚU" stripDiacritics] equals:@"AA EE II OO UU"];
[self assert:[@"Å Ã Ê í ö û" stripDiacritics] equals:@"A A E i o u"];
}
@end
@@ -6,6 +6,8 @@
* Copyright 2012, Your Company All rights reserved.
*/
CPLogRegister(CPLogConsole)
@import <Foundation/CPObject.j>
@implementation AppController : CPObject
@@ -30,10 +32,10 @@
- (id)newObject
{
var randIndex = FLOOR(RAND()*3),
randLabel = ["un", "deux", "trois", nil][FLOOR(RAND()*4)],
randTag = FLOOR(RAND()*3);
var randIndex = FLOOR(RAND() * 3),
randLabel = ["Label1", "Label2", "Label3", nil][FLOOR(RAND() * 4)],
randTag = FLOOR(RAND() * 3);
return [CPDictionary dictionaryWithObjectsAndKeys:randIndex, @"index", randLabel, @"label", randTag, @"tag"];
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+427
View File
@@ -0,0 +1,427 @@
" Vim syntax file
" Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2012 Jan 14
" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
finish
endif
let s:cpo_save = &cpo
set cpo&vim
" A bunch of useful C keywords
syn keyword cStatement goto break return continue asm
syn keyword cLabel case default
syn keyword cConditional if else switch
syn keyword cRepeat while for do
syn keyword cTodo contained TODO FIXME XXX
" It's easy to accidentally add a space after a backslash that was intended
" for line continuation. Some compilers allow it, which makes it
" unpredicatable and should be avoided.
syn match cBadContinuation contained "\\\s\+$"
" cCommentGroup allows adding matches for special things in comments
syn cluster cCommentGroup contains=cTodo,cBadContinuation
" String and Character constants
" Highlight special characters (those which have a backslash) differently
syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
if !exists("c_no_utf")
syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)"
endif
if exists("c_no_cformat")
syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell
" cCppString: same as cString, but ends at end of line
syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,@Spell
else
if !exists("c_no_c99") " ISO C99
syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
else
syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
endif
syn match cFormat display "%%" contained
syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell
" cCppString: same as cString, but ends at end of line
syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell
endif
syn match cCharacter "L\='[^\\]'"
syn match cCharacter "L'[^']*'" contains=cSpecial
if exists("c_gnu")
syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'"
syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'"
else
syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'"
syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'"
endif
syn match cSpecialCharacter display "L\='\\\o\{1,3}'"
syn match cSpecialCharacter display "'\\x\x\{1,2}'"
syn match cSpecialCharacter display "L'\\x\x\+'"
if !exists("c_no_c11") " ISO C11
if exists("c_no_cformat")
syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell
else
syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell
endif
syn match cCharacter "[Uu]'[^\\]'"
syn match cCharacter "[Uu]'[^']*'" contains=cSpecial
if exists("c_gnu")
syn match cSpecialError "[Uu]'\\[^'\"?\\abefnrtv]'"
syn match cSpecialCharacter "[Uu]'\\['\"?\\abefnrtv]'"
else
syn match cSpecialError "[Uu]'\\[^'\"?\\abfnrtv]'"
syn match cSpecialCharacter "[Uu]'\\['\"?\\abfnrtv]'"
endif
syn match cSpecialCharacter display "[Uu]'\\\o\{1,3}'"
syn match cSpecialCharacter display "[Uu]'\\x\x\+'"
endif
"when wanted, highlight trailing white space
if exists("c_space_errors")
if !exists("c_no_trail_space_error")
syn match cSpaceError display excludenl "\s\+$"
endif
if !exists("c_no_tab_space_error")
syn match cSpaceError display " \+\t"me=e-1
endif
endif
" This should be before cErrInParen to avoid problems with #define ({ xxx })
if exists("c_curly_error")
syntax match cCurlyError "}"
syntax region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold
else
syntax region cBlock start="{" end="}" transparent fold
endif
"catch errors caused by wrong parenthesis and brackets
" also accept <% for {, %> for }, <: for [ and :> for ] (C99)
" But avoid matching <::.
syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
if exists("c_no_curly_error")
syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
syn match cParenError display ")"
syn match cErrInParen display contained "^[{}]\|^<%\|^%>"
elseif exists("c_no_bracket_error")
syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell
syn match cParenError display ")"
syn match cErrInParen display contained "[{}]\|<%\|%>"
else
syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell
" cCppParen: same as cParen but ends at end-of-line; used in cDefine
syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell
syn match cParenError display "[\])]"
syn match cErrInParen display contained "[\]{}]\|<%\|%>"
syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell
" cCppBracket: same as cParen but ends at end-of-line; used in cDefine
syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell
syn match cErrInBracket display contained "[);{}]\|<%\|%>"
endif
syntax region cBadBlock keepend extend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold
"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal
" Same, but without octal error (for comments)
syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal
syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
"hex number
syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
" Flag the first zero of an octal number as something special
syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero
syn match cOctalZero display contained "\<0"
syn match cFloat display contained "\d\+f"
"floating point number, with dot, optional exponent
syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
"floating point number, starting with a dot, optional exponent
syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
if !exists("c_no_c99")
"hexadecimal floating point number, optional leading digits, with dot, with exponent
syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>"
"hexadecimal floating point number, with leading digits, optional dot, with exponent
syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>"
endif
" flag an octal number with wrong digits
syn match cOctalError display contained "0\o*[89]\d*"
syn case match
if exists("c_comment_strings")
" A comment can contain cString, cCharacter and cNumber.
" But a "*/" inside a cString in a cComment DOES end the comment! So we
" need to use a special type of cString: cCommentString, which also ends on
" "*/", and sees a "*" at the start of the line as comment again.
" Unfortunately this doesn't very well work for // type of comments :-(
syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)"
syntax region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
syntax region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell
if exists("c_no_comment_fold")
" Use "extend" here to have preprocessor lines not terminate halfway a
" comment.
syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend
else
syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend
endif
else
syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell
if exists("c_no_comment_fold")
syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend
else
syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold extend
endif
endif
" keep a // comment separately, it terminates a preproc. conditional
syntax match cCommentError display "\*/"
syntax match cCommentStartError display "/\*"me=e-1 contained
syn keyword cOperator sizeof
if exists("c_gnu")
syn keyword cStatement __asm__
syn keyword cOperator typeof __real__ __imag__
endif
syn keyword cType int long short char void
syn keyword cType signed unsigned float double
if !exists("c_no_ansi") || exists("c_ansi_typedefs")
syn keyword cType size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t
syn keyword cType clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t
syn keyword cType mbstate_t wctrans_t wint_t wctype_t
endif
if !exists("c_no_c99") " ISO C99
syn keyword cType _Bool bool _Complex complex _Imaginary imaginary
syn keyword cType int8_t int16_t int32_t int64_t
syn keyword cType uint8_t uint16_t uint32_t uint64_t
syn keyword cType int_least8_t int_least16_t int_least32_t int_least64_t
syn keyword cType uint_least8_t uint_least16_t uint_least32_t uint_least64_t
syn keyword cType int_fast8_t int_fast16_t int_fast32_t int_fast64_t
syn keyword cType uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t
syn keyword cType intptr_t uintptr_t
syn keyword cType intmax_t uintmax_t
endif
if exists("c_gnu")
syn keyword cType __label__ __complex__ __volatile__
endif
syn keyword cStructure struct union enum typedef
syn keyword cStorageClass static register auto volatile extern const
if exists("c_gnu")
syn keyword cStorageClass inline __attribute__
endif
if !exists("c_no_c99")
syn keyword cStorageClass inline restrict
endif
if !exists("c_no_c11")
syn keyword cStorageClass _Alignas alignas
syn keyword cOperator _Alignof alignof
syn keyword cStorageClass _Atomic
syn keyword cOperator _Generic
syn keyword cStorageClass _Noreturn noreturn
syn keyword cOperator _Static_assert static_assert
syn keyword cStorageClass _Thread_local thread_local
syn keyword cType char16_t char32_t
endif
if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu")
if exists("c_gnu")
syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__ __func__
endif
syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__
syn keyword cConstant __STDC_VERSION__
syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX
syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX
syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN
syn keyword cConstant CHAR_MAX INT_MAX LONG_MAX SHRT_MAX
syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN
syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX
if !exists("c_no_c99")
syn keyword cConstant __func__
syn keyword cConstant LLONG_MIN LLONG_MAX ULLONG_MAX
syn keyword cConstant INT8_MIN INT16_MIN INT32_MIN INT64_MIN
syn keyword cConstant INT8_MAX INT16_MAX INT32_MAX INT64_MAX
syn keyword cConstant UINT8_MAX UINT16_MAX UINT32_MAX UINT64_MAX
syn keyword cConstant INT_LEAST8_MIN INT_LEAST16_MIN INT_LEAST32_MIN INT_LEAST64_MIN
syn keyword cConstant INT_LEAST8_MAX INT_LEAST16_MAX INT_LEAST32_MAX INT_LEAST64_MAX
syn keyword cConstant UINT_LEAST8_MAX UINT_LEAST16_MAX UINT_LEAST32_MAX UINT_LEAST64_MAX
syn keyword cConstant INT_FAST8_MIN INT_FAST16_MIN INT_FAST32_MIN INT_FAST64_MIN
syn keyword cConstant INT_FAST8_MAX INT_FAST16_MAX INT_FAST32_MAX INT_FAST64_MAX
syn keyword cConstant UINT_FAST8_MAX UINT_FAST16_MAX UINT_FAST32_MAX UINT_FAST64_MAX
syn keyword cConstant INTPTR_MIN INTPTR_MAX UINTPTR_MAX
syn keyword cConstant INTMAX_MIN INTMAX_MAX UINTMAX_MAX
syn keyword cConstant PTRDIFF_MIN PTRDIFF_MAX SIG_ATOMIC_MIN SIG_ATOMIC_MAX
syn keyword cConstant SIZE_MAX WCHAR_MIN WCHAR_MAX WINT_MIN WINT_MAX
endif
syn keyword cConstant FLT_RADIX FLT_ROUNDS
syn keyword cConstant FLT_DIG FLT_MANT_DIG FLT_EPSILON
syn keyword cConstant DBL_DIG DBL_MANT_DIG DBL_EPSILON
syn keyword cConstant LDBL_DIG LDBL_MANT_DIG LDBL_EPSILON
syn keyword cConstant FLT_MIN FLT_MAX FLT_MIN_EXP FLT_MAX_EXP
syn keyword cConstant FLT_MIN_10_EXP FLT_MAX_10_EXP
syn keyword cConstant DBL_MIN DBL_MAX DBL_MIN_EXP DBL_MAX_EXP
syn keyword cConstant DBL_MIN_10_EXP DBL_MAX_10_EXP
syn keyword cConstant LDBL_MIN LDBL_MAX LDBL_MIN_EXP LDBL_MAX_EXP
syn keyword cConstant LDBL_MIN_10_EXP LDBL_MAX_10_EXP
syn keyword cConstant HUGE_VAL CLOCKS_PER_SEC NULL
syn keyword cConstant LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY
syn keyword cConstant LC_NUMERIC LC_TIME
syn keyword cConstant SIG_DFL SIG_ERR SIG_IGN
syn keyword cConstant SIGABRT SIGFPE SIGILL SIGHUP SIGINT SIGSEGV SIGTERM
" Add POSIX signals as well...
syn keyword cConstant SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP
syn keyword cConstant SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV
syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU
syn keyword cConstant SIGUSR1 SIGUSR2
syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF
syn keyword cConstant FOPEN_MAX FILENAME_MAX L_tmpnam
syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET
syn keyword cConstant TMP_MAX stderr stdin stdout
syn keyword cConstant EXIT_FAILURE EXIT_SUCCESS RAND_MAX
" Add POSIX errors as well
syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY
syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT
syn keyword cConstant EFBIG EILSEQ EINPROGRESS EINTR EINVAL EIO EISDIR
syn keyword cConstant EMFILE EMLINK EMSGSIZE ENAMETOOLONG ENFILE ENODEV
syn keyword cConstant ENOENT ENOEXEC ENOLCK ENOMEM ENOSPC ENOSYS
syn keyword cConstant ENOTDIR ENOTEMPTY ENOTSUP ENOTTY ENXIO EPERM
syn keyword cConstant EPIPE ERANGE EROFS ESPIPE ESRCH ETIMEDOUT EXDEV
" math.h
syn keyword cConstant M_E M_LOG2E M_LOG10E M_LN2 M_LN10 M_PI M_PI_2 M_PI_4
syn keyword cConstant M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2
endif
if !exists("c_no_c99") " ISO C99
syn keyword cConstant true false
endif
" Accept %: for # (C99)
syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
syn match cPreConditMatch display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
if !exists("c_no_if0")
syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
syn region cCppOutWrapper start="^\s*\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse fold
syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
if !exists("c_no_if0_fold")
syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip fold
else
syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip
endif
syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
syn region cCppInWrapper start="^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
if !exists("c_no_if0_fold")
syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
else
syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
endif
syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip
syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc
endif
syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match cIncluded display contained "<[^>]*>"
syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
"syn match cLineSkip "\\$"
syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti
syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
" Highlight User Labels
syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString
syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell
" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
syn cluster cLabelGroup contains=cUserLabel
syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup
syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup
syn match cUserCont display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
syn match cUserCont display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
syn match cUserLabel display "\I\i*" contained
" Avoid recognizing most bitfields as labels
syn match cBitField display "^\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType
syn match cBitField display ";\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType
if exists("c_minlines")
let b:c_minlines = c_minlines
else
if !exists("c_no_if0")
let b:c_minlines = 50 " #if 0 constructs can be long
else
let b:c_minlines = 15 " mostly for () constructs
endif
endif
if exists("c_curly_error")
syn sync fromstart
else
exec "syn sync ccomment cComment minlines=" . b:c_minlines
endif
" Define the default highlighting.
" Only used when an item doesn't have highlighting yet
hi def link cFormat cSpecial
hi def link cCppString cString
hi def link cCommentL cComment
hi def link cCommentStart cComment
hi def link cLabel Label
hi def link cUserLabel Label
hi def link cConditional Conditional
hi def link cRepeat Repeat
hi def link cCharacter Character
hi def link cSpecialCharacter cSpecial
hi def link cNumber Number
hi def link cOctal Number
hi def link cOctalZero PreProc " link this to Error if you want
hi def link cFloat Float
hi def link cOctalError cError
hi def link cParenError cError
hi def link cErrInParen cError
hi def link cErrInBracket cError
hi def link cCommentError cError
hi def link cCommentStartError cError
hi def link cSpaceError cError
hi def link cSpecialError cError
hi def link cCurlyError cError
hi def link cOperator Operator
hi def link cStructure Structure
hi def link cStorageClass StorageClass
hi def link cInclude Include
hi def link cPreProc PreProc
hi def link cDefine Macro
hi def link cIncluded cString
hi def link cError Error
hi def link cStatement Statement
hi def link cCppInWrapper cCppOutWrapper
hi def link cCppOutWrapper cPreCondit
hi def link cPreConditMatch cPreCondit
hi def link cPreCondit PreCondit
hi def link cType Type
hi def link cConstant Constant
hi def link cCommentString cString
hi def link cComment2String cString
hi def link cCommentSkip cComment
hi def link cString String
hi def link cComment Comment
hi def link cSpecial SpecialChar
hi def link cTodo Todo
hi def link cBadContinuation Error
hi def link cCppOutSkip cCppOutIf2
hi def link cCppInElse2 cCppOutIf2
hi def link cCppOutIf2 cCppOut2 " Old syntax group for #if 0 body
hi def link cCppOut2 cCppOut " Old syntax group for #if of #if 0
hi def link cCppOut Comment
let b:current_syntax = "c"
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: ts=8
+135
View File
@@ -0,0 +1,135 @@
" Vim syntax file
" Language: JavaScript
" Maintainer: Claudio Fleiner <claudio@fleiner.com>
" Updaters: Scott Shattuck (ss) <ss@technicalpursuit.com>
" URL: http://www.fleiner.com/vim/syntax/javascript.vim
" Changes: (ss) added keywords, reserved words, and other identifiers
" (ss) repaired several quoting and grouping glitches
" (ss) fixed regex parsing issue with multiple qualifiers [gi]
" (ss) additional factoring of keywords, globals, and members
" Last Change: 2010 Mar 25
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
" tuning parameters:
" unlet javaScript_fold
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'javascript'
endif
" Drop fold if it set but vim doesn't support it.
if version < 600 && exists("javaScript_fold")
unlet javaScript_fold
endif
syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
syn match javaScriptSpecial "\\\d\d\d\|\\."
syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
syn match javaScriptSpecialCharacter "'\\.'"
syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
syn keyword javaScriptConditional if else switch
syn keyword javaScriptRepeat while for do in
syn keyword javaScriptBranch break continue
syn keyword javaScriptOperator new delete instanceof typeof
syn keyword javaScriptType Array Boolean Date Function Number Object String RegExp
syn keyword javaScriptStatement return with
syn keyword javaScriptBoolean true false
syn keyword javaScriptNull null undefined
syn keyword javaScriptIdentifier arguments this var let
syn keyword javaScriptLabel case default
syn keyword javaScriptException try catch finally throw
syn keyword javaScriptMessage alert confirm prompt status
syn keyword javaScriptGlobal self window top parent
syn keyword javaScriptMember document event location
syn keyword javaScriptDeprecated escape unescape
syn keyword javaScriptReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
if exists("javaScript_fold")
syn match javaScriptFunction "\<function\>"
syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
syn sync match javaScriptSync grouphere javaScriptFunctionFold "\<function\>"
syn sync match javaScriptSync grouphere NONE "^}"
setlocal foldmethod=syntax
setlocal foldtext=getline(v:foldstart)
else
syn keyword javaScriptFunction function
syn match javaScriptBraces "[{}\[\]]"
syn match javaScriptParens "[()]"
endif
syn sync fromstart
syn sync maxlines=100
if main_syntax == "javascript"
syn sync ccomment javaScriptComment
endif
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_javascript_syn_inits")
if version < 508
let did_javascript_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink javaScriptComment Comment
HiLink javaScriptLineComment Comment
HiLink javaScriptCommentTodo Todo
HiLink javaScriptSpecial Special
HiLink javaScriptStringS String
HiLink javaScriptStringD String
HiLink javaScriptCharacter Character
HiLink javaScriptSpecialCharacter javaScriptSpecial
HiLink javaScriptNumber javaScriptValue
HiLink javaScriptConditional Conditional
HiLink javaScriptRepeat Repeat
HiLink javaScriptBranch Conditional
HiLink javaScriptOperator Operator
HiLink javaScriptType Type
HiLink javaScriptStatement Statement
HiLink javaScriptFunction Function
HiLink javaScriptBraces Function
HiLink javaScriptError Error
HiLink javaScrParenError javaScriptError
HiLink javaScriptNull Keyword
HiLink javaScriptBoolean Boolean
HiLink javaScriptRegexpString String
HiLink javaScriptIdentifier Identifier
HiLink javaScriptLabel Label
HiLink javaScriptException Exception
HiLink javaScriptMessage Keyword
HiLink javaScriptGlobal Keyword
HiLink javaScriptMember Keyword
HiLink javaScriptDeprecated Exception
HiLink javaScriptReserved Keyword
HiLink javaScriptDebug Debug
HiLink javaScriptConstant Label
delcommand HiLink
endif
let b:current_syntax = "javascript"
if main_syntax == 'javascript'
unlet main_syntax
endif
" vim: ts=8
+79 -132
View File
@@ -1,51 +1,86 @@
" Vim syntax file
" Language: Objective-J
" Maintainer: Shawn MacIntyre <sdm@openradical.com>
" Updaters:
" URL:
" Changes: (sm) merged javascript syntax Claudio Fleiner and Scott Shattuck and objc syntax by Kazunobu Kuriyama and Anthony Hodsdon
" Last Change: 2008 Sep 8
" Language: Objective-J
" Maintainer: Shawn MacIntyre <sdm@openradical.com>
" First Author: Shawn MacIntyre <sdm@openradical.com>
" Updaters: Kevin Xu <kevin.xu.1982.02.06@gmail.com>
" Changes: (sm) merged JavaScript syntax by
" Claudio Fleiner & Scott Shattuck and
" Objective-C syntax by
" Valentino Kyriakides, Anthony Hodsdon & Kazunobu Kuriyama
" (sm) modified 'objc.vim' to our 'objj.vim'
" which reads 'javascript.vim' in the beginning.
" Last Change: 2014 Sep 29
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
" tuning parameters:
" unlet objj_fold
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'objj'
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Drop fold if it set but vim doesn't support it.
if version < 600 && exists("objj_fold")
unlet objj_fold
" Read the JavaScript syntax to start with
if version < 600
source <sfile>:p:h/javascript.vim
else
runtime! syntax/javascript.vim
unlet b:current_syntax
endif
syn case ignore
" Modify some syntax from 'javascript.vim'.
syn clear javaScriptParens
syn clear javaScriptBraces
" objj keywords, types, type qualifiers etc.
" TODO: The '{}' & '[]' representing the JavaScript 'object' & 'array'
" should be highlighted.
" Read the C syntax to start with
if version < 600
source <sfile>:p:h/c.vim
else
runtime! syntax/c.vim
unlet b:current_syntax
endif
" FIXME: The highlighting the common special-notice 'TBD'
" for comments in JavaScript
" is broken by c.vim.
" Objective-J extentions follow below
"
" NOTE: Objective-J is abbreviated to ObjJ/objj
" and uses *.j as file extensions!
" ObjJ keywords, types, type qualifiers etc.
syn keyword objjStatement self super _cmd
syn keyword objjStatement property getter setter readwrite readonly copy
syn keyword objjType id Class SEL IMP BOOL
"syn keyword objjTypeModifier bycopy in out inout oneway
syn keyword objjConstant nil Nil
syn keyword objjTypeModifier bycopy in out inout oneway
syn keyword objjConstant nil Nil NULL NO YES
" Match the objj #import directive (like C's #include)
" Match the ObjJ @import directive
syn match objjDirective "@import"
" Match the ObjJ #import directive (like C's #include)
syn region objjImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match objjImported display contained "<[_0-9a-zA-Z.\/]*>"
syn match objjImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objjImported
syn match objjImported display contained "<[-_0-9a-zA-Z.\/]*>"
syn match objjImport display "^\s*\(%:\|#\|@\)\s*import\>\s*["<]" contains=objjImported
" Match the important objj directives
syn match objjScopeDecl "@public\|@private\|@protected"
syn match objjDirective "@interface\|@implementation"
syn match objjDirective "@class\|@end\|@defs"
syn match objjDirective "@encode\|@protocol\|@selector"
" Match the important ObjJ directives
syn match objjDirective "@interface\|@implementation\|@protocol\|@end"
syn match objjScopeDecl "@public\|@protected\|@private\|@package"
syn match objjScopeDecl "@required\|@optional"
syn match objjDirective "@property\|@synthesize\|@dynamic"
syn match objjDirective "@outlet\|@accessors"
syn match objjDirective "@action\|@selector"
syn match objjDirective "@defs"
syn match objjDirective "@global\|@class"
syn match objjDirective "@encode"
syn match objjDirective "@ref\|@deref"
syn match objjDirective "@try\|@catch\|@finally\|@throw\|@synchronized"
" Match the ObjC method types
" Match the ObjJ method types
"
" NOTE: here I match only the indicators, this looks
" much nicer and reduces cluttering color highlightings.
@@ -56,123 +91,38 @@ syn match objjInstMethod "^\s*-\s*"
syn match objjFactMethod "^\s*+\s*"
" To distinguish from a header inclusion from a protocol list.
"syn match objjProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objjType,cType,Type
syn match objjProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objjType,cType,Type
" To distinguish labels from the keyword for a method's parameter.
syn region objjKeyForMethodParam display
\ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*("
\ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*"
\ contains=objjType,Type
\ contains=objjType,objjTypeModifier,cType,cStructure,cStorageClass,Type
" Objective-C Constant Strings
" Objective-J Constant Strings
syn match objjSpecial display "%@" contained
syn region objjString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial
syn region objjString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objjSpecial
" Objective-C Message Expressions
syn region objjMessage display start="\[" end="\]" contains=objjMessage,objjStatement,objjType,objjTypeModifier,objjString,objjConstant,objjDirective
" Objective-J Message Expressions
syn region objjMessage display start="\[" end="\]" contains=objjMessage,objjStatement,objjType,objjTypeModifier,objjString,objjConstant,objjDirective,cType,cStructure,cStorageClass,cString,cCharacter,cSpecialCharacter,cNumbers,cConstant,cOperator,cComment,cCommentL,Type
syn cluster cParenGroup add=objjMessage
syn cluster cPreProcGroup add=objjMessage
syn keyword objjCommentTodo TODO FIXME XXX TBD contained
syn match objjLineComment "\/\/.*" contains=objjCommentTodo
syn match objjCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region objjComment start="/\*" end="\*/" contains=objjCommentTodo
syn match objjSpecial "\\\d\d\d\|\\."
syn region objjStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=objjSpecial,@htmlPreproc
syn region objjStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=objjSpecial,@htmlPreproc
syn match objjSpecialCharacter "'\\.'"
syn match objjNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syn region objjRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
syn keyword objjConditional if else switch
syn keyword objjRepeat while for do in
syn keyword objjBranch break continue
syn keyword objjOperator new delete instanceof typeof
syn keyword objjType Array Boolean Date Function Number Object String RegExp
syn keyword objjStatement return with
syn keyword objjBoolean true false
syn keyword objjNull null undefined
syn keyword objjIdentifier arguments this var
syn keyword objjLabel case default
syn keyword objjException try catch finally throw
syn keyword objjMessage alert confirm prompt status
syn keyword objjGlobal self window top parent
syn keyword objjMember document event location
syn keyword objjDeprecated escape unescape
syn keyword objjReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
if exists("objj_fold")
syn match objjFunction "\<function\>"
syn region objjFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
syn sync match objjSync grouphere objjFunctionFold "\<function\>"
syn sync match objjSync grouphere NONE "^}"
setlocal foldmethod=syntax
setlocal foldtext=getline(v:foldstart)
else
syn keyword objjFunction function
syn match objjBraces "[{}\[\]]"
syn match objjParens "[()]"
endif
syn sync fromstart
syn sync maxlines=100
if main_syntax == "objj"
syn sync ccomment objjComment
endif
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_objj_syn_inits")
if version >= 508 || !exists("did_objj_syntax_inits")
if version < 508
let did_objj_syn_inits = 1
let did_objj_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink objjComment Comment
HiLink objjLineComment Comment
HiLink objjCommentTodo Todo
HiLink objjSpecial Special
HiLink objjStringS String
HiLink objjStringD String
HiLink objjCharacter Character
HiLink objjSpecialCharacter objjSpecial
HiLink objjNumber objjValue
HiLink objjConditional Conditional
HiLink objjRepeat Repeat
HiLink objjBranch Conditional
HiLink objjOperator Operator
HiLink objjType Type
HiLink objjStatement Statement
HiLink objjFunction Function
HiLink objjBraces Function
HiLink objjError Error
HiLink javaScrParenError objjError
HiLink objjNull Keyword
HiLink objjBoolean Boolean
HiLink objjRegexpString String
HiLink objjIdentifier Identifier
HiLink objjLabel Label
HiLink objjException Exception
HiLink objjMessage Keyword
HiLink objjGlobal Keyword
HiLink objjMember Keyword
HiLink objjDeprecated Exception
HiLink objjReserved Keyword
HiLink objjDebug Debug
HiLink objjConstant Label
HiLink objjImport Include
HiLink objjImported String
HiLink objjImported cString
HiLink objjTypeModifier objjType
HiLink objjType Type
HiLink objjScopeDecl Statement
@@ -181,17 +131,14 @@ if version >= 508 || !exists("did_objj_syn_inits")
HiLink objjStatement Statement
HiLink objjDirective Statement
HiLink objjKeyForMethodParam None
HiLink objjString String
HiLink objjString cString
HiLink objjSpecial Special
HiLink objjProtocol None
HiLink objjConstant Constant
HiLink objjConstant cConstant
delcommand HiLink
endif
let b:current_syntax = "objj"
if main_syntax == 'objj'
unlet main_syntax
endif
" vim: ts=8
" vim: ts=8
+11 -2
View File
@@ -1,5 +1,14 @@
if [ -z "$NARWHAL_ENGINE" ] && [ -d "$NARWHAL_HOME/packages/narwhal-jsc" ]; then
export NARWHAL_ENGINE=jsc
if [ -z "$NARWHAL_ENGINE" ] && [ `uname` == "Darwin" ]; then
# We should check "narwhal-jsc.conf" and the corresponding executable to determine whether JSC can be "$NARWHAL_ENGINE".
if [ -f "$NARWHAL_HOME/packages/narwhal-jsc/narwhal-jsc.conf" ]; then
source "$NARWHAL_HOME/packages/narwhal-jsc/narwhal-jsc.conf"
fi
if [ -z "$NARWHAL_JSC_MODE" ]; then
NARWHAL_JSC_MODE="jscore"
fi
if [ -f "$NARWHAL_HOME/packages/narwhal-jsc/bin/narwhal-$NARWHAL_JSC_MODE" ]; then
export NARWHAL_ENGINE=jsc
fi
fi
if [ "$NARWHAL_ENGINE" == jsc ] && [ `ulimit -n` -lt 1024 ]; then