Merge remote-tracking branch 'cappuccino/master'

This commit is contained in:
Daniel
2018-03-20 13:46:13 -07:00
53 changed files with 1615 additions and 133 deletions
+5
View File
@@ -35,6 +35,11 @@
CPArray _allowedFileTypes @accessors(property=allowedFileTypes);
}
+ (CPURL)proposedFileURLWithDocumentName:(CPString)aDocumentName
{
return [CPURL URLWithString:aDocumentName];
}
+ (id)savePanel
{
return [[CPSavePanel alloc] init];
+1
View File
@@ -40,6 +40,7 @@
@protocol CPTextDelegate <CPObject>
@optional
- (BOOL)textShouldBeginEditing:(CPText)aTextObject;
- (BOOL)textShouldEndEditing:(CPText)aTextObject;
- (void)textDidBeginEditing:(CPNotification)aNotification;
+9 -3
View File
@@ -873,12 +873,18 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (!CPTextFieldInputDidBlur)
CPTextFieldBlurHandler();
CPTextFieldInputDidBlur = NO;
CPTextFieldInputResigning = NO;
if (element.parentNode == _DOMElement)
element.parentNode.removeChild(element);
// Previosly, we unflagged CPTextFieldInputDidBlur and CPTextFieldInputResigning before
// the call to removeChild. This resulted in DOM exceptions in Chrome under certain conditions.
// See https://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node
// for why we need to unflag CPTextFieldInputDidBlur and CPTextFieldInputResigning
// only after removing the element.
CPTextFieldInputDidBlur = NO;
CPTextFieldInputResigning = NO;
CPTextFieldInputIsActive = NO;
if (document.attachEvent)
+1 -4
View File
@@ -168,10 +168,7 @@ CPLineMovesUp = 4;
- (void)setTextView:(CPTextView)aTextView
{
if (_textView)
{
[self _removeAllLines];
[_textView setTextContainer:nil];
}
_textView = aTextView;
@@ -252,4 +249,4 @@ var CPTextContainerSizeKey = @"CPTextContainerSizeKey",
[aCoder encodeObject:_layoutManager forKey:CPTextContainerLayoutManagerKey];
}
@end
@end
+186 -54
View File
@@ -43,6 +43,7 @@
@protocol CPTextViewDelegate <CPTextDelegate>
@optional
- (BOOL)textView:(CPTextView)aTextView doCommandBySelector:(SEL)aSelector;
- (BOOL)textView:(CPTextView)aTextView shouldChangeTextInRange:(CPRange)affectedCharRange replacementString:(CPString)replacementString;
- (CPDictionary)textView:(CPTextView)textView shouldChangeTypingAttributes:(CPDictionary)oldTypingAttributes toAttributes:(CPDictionary)newTypingAttributes;
@@ -94,13 +95,16 @@ CPSelectByWord = 1;
CPSelectByParagraph = 2;
var kDelegateRespondsTo_textShouldBeginEditing = 1 << 0,
kDelegateRespondsTo_textView_doCommandBySelector = 1 << 1,
kDelegateRespondsTo_textView_willChangeSelectionFromCharacterRange_toCharacterRange = 1 << 2,
kDelegateRespondsTo_textView_shouldChangeTextInRange_replacementString = 1 << 3,
kDelegateRespondsTo_textView_shouldChangeTypingAttributes_toAttributes = 1 << 4,
kDelegateRespondsTo_textView_textDidChange = 1 << 5,
kDelegateRespondsTo_textView_didChangeSelection = 1 << 6,
kDelegateRespondsTo_textView_didChangeTypingAttributes = 1 << 7;
kDelegateRespondsTo_textShouldEndEditing = 1 << 1
kDelegateRespondsTo_textView_doCommandBySelector = 1 << 2,
kDelegateRespondsTo_textView_willChangeSelectionFromCharacterRange_toCharacterRange = 1 << 3,
kDelegateRespondsTo_textView_shouldChangeTextInRange_replacementString = 1 << 4,
kDelegateRespondsTo_textView_shouldChangeTypingAttributes_toAttributes = 1 << 5,
kDelegateRespondsTo_textView_textDidChange = 1 << 6,
kDelegateRespondsTo_textView_didChangeSelection = 1 << 7,
kDelegateRespondsTo_textView_didChangeTypingAttributes = 1 << 8,
kDelegateRespondsTo_textView_textDidBeginEditing = 1 << 9,
kDelegateRespondsTo_textView_textDidEndEditing = 1 << 10;
@class _CPCaret;
@@ -152,6 +156,10 @@ var kDelegateRespondsTo_textShouldBeginEditing
CPTimer _scrollingTimer;
CPString _placeholderString;
BOOL _firstResponderButNotEditingYet;
CPRange _mouseDownOldSelection;
}
+ (Class)_binderClassForBinding:(CPString)aBinding
@@ -264,6 +272,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
[super _removeObservers];
[self _setObserveWindowKeyNotifications:NO];
[self _removeDelegateObservers];
}
- (void)_addObservers
@@ -274,7 +283,53 @@ var kDelegateRespondsTo_textShouldBeginEditing
[super _addObservers];
[self _setObserveWindowKeyNotifications:YES];
[self _startObservingClipView];
[self _addDelegateObservers];
}
- (void)_addDelegateObservers
{
if (!_delegate) return;
var nc = [CPNotificationCenter defaultCenter];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidBeginEditing)
[nc addObserver:_delegate selector:@selector(textDidBeginEditing:) name:CPTextDidBeginEditingNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidChange)
[nc addObserver:_delegate selector:@selector(textDidChange:) name:CPTextDidChangeNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidEndEditing)
[nc addObserver:_delegate selector:@selector(textDidEndEditing:) name:CPTextDidEndEditingNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_didChangeSelection)
[nc addObserver:_delegate selector:@selector(textViewDidChangeSelection:) name:CPTextViewDidChangeSelectionNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_didChangeTypingAttributes)
[nc addObserver:_delegate selector:@selector(textViewDidChangeTypingAttributes:) name:CPTextViewDidChangeTypingAttributesNotification object:self];
}
- (void)_removeDelegateObservers
{
if (!_delegate) return;
var nc = [CPNotificationCenter defaultCenter];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidBeginEditing)
[nc removeObserver:_delegate name:CPTextDidBeginEditingNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidChange)
[nc removeObserver:_delegate name:CPTextDidChangeNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidEndEditing)
[nc removeObserver:_delegate name:CPTextDidEndEditingNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_didChangeSelection)
[nc removeObserver:_delegate name:CPTextViewDidChangeSelectionNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_didChangeTypingAttributes)
[nc removeObserver:_delegate name:CPTextViewDidChangeTypingAttributesNotification object:self];
}
- (void)_startObservingClipView
{
if (!_observedClipView)
@@ -358,7 +413,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (void)_windowDidResignKey:(CPNotification)aNotification
{
if (![[self window] isKeyWindow])
[self resignFirstResponder];
[self _resignFirstResponder];
}
- (void)_windowDidBecomeKey:(CPNotification)aNotification
@@ -452,17 +507,33 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (BOOL)becomeFirstResponder
{
[super becomeFirstResponder];
_firstResponderButNotEditingYet = YES;
[self _becomeFirstResponder];
return YES;
}
- (BOOL)resignFirstResponder
- (void)_resignFirstResponder
{
[self _reverseSetBinding];
[_caret stopBlinking];
[self setNeedsDisplay:YES];
[_CPNativeInputManager cancelCurrentInputSessionIfNeeded];
}
- (BOOL)resignFirstResponder
{
if (_firstResponderButNotEditingYet)
_firstResponderButNotEditingYet = NO;
else
{
if ([self _sendDelegateTextShouldEndEditing])
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextDidEndEditingNotification object:self];
else
return NO;
}
[self _resignFirstResponder];
return YES;
}
@@ -479,6 +550,8 @@ var kDelegateRespondsTo_textShouldBeginEditing
if (aDelegate === _delegate)
return;
[self _removeDelegateObservers];
_delegateRespondsToSelectorMask = 0;
_delegate = aDelegate;
@@ -493,12 +566,21 @@ var kDelegateRespondsTo_textShouldBeginEditing
if ([_delegate respondsToSelector:@selector(textViewDidChangeTypingAttributes:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textView_didChangeTypingAttributes;
if ([_delegate respondsToSelector:@selector(textDidBeginEditing:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textView_textDidBeginEditing;
if ([_delegate respondsToSelector:@selector(textDidEndEditing:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textView_textDidEndEditing;
if ([_delegate respondsToSelector:@selector(textView:doCommandBySelector:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textView_doCommandBySelector;
if ([_delegate respondsToSelector:@selector(textShouldBeginEditing:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textShouldBeginEditing;
if ([_delegate respondsToSelector:@selector(textShouldEndEditing:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textShouldEndEditing;
if ([_delegate respondsToSelector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textView_willChangeSelectionFromCharacterRange_toCharacterRange;
@@ -507,6 +589,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
if ([_delegate respondsToSelector:@selector(textView:shouldChangeTypingAttributes:toAttributes:)])
_delegateRespondsToSelectorMask |= kDelegateRespondsTo_textView_shouldChangeTypingAttributes_toAttributes;
if (_superview)
[self _addDelegateObservers];
}
}
@@ -643,9 +728,21 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (void)didChangeText
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextDidChangeNotification object:self];
}
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_textDidChange)
[_delegate textDidChange:[[CPNotification alloc] initWithName:CPTextDidChangeNotification object:self userInfo:nil]];
- (BOOL)_didBeginEditing
{
if (_firstResponderButNotEditingYet)
{
if ([self _sendDelegateTextShouldBeginEditing])
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextDidBeginEditingNotification object:self];
_firstResponderButNotEditingYet = NO;
} else
return NO;
}
return YES;
}
- (BOOL)shouldChangeTextInRange:(CPRange)aRange replacementString:(CPString)aString
@@ -653,7 +750,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
if (![self isEditable])
return NO;
return [self _sendDelegateTextShouldBeginEditing] && [self _sendDelegateShouldChangeTextInRange:aRange replacementString:aString];
return [self _sendDelegateShouldChangeTextInRange:aRange replacementString:aString];
}
@@ -685,7 +782,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
var isAttributed = [aString isKindOfClass:CPAttributedString],
string = isAttributed ? [aString string]:aString;
if (![self shouldChangeTextInRange:CPMakeRangeCopy(_selectionRange) replacementString:string])
if (![self _didBeginEditing] || ![self shouldChangeTextInRange:CPMakeRangeCopy(_selectionRange) replacementString:string])
return;
if (!isAttributed)
@@ -787,53 +884,80 @@ var kDelegateRespondsTo_textShouldBeginEditing
}
}
/*!
Sets the selection to a range of characters in response to user action.
@param range The range of characters to select. This range must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
*/
- (void)setSelectedRange:(CPRange)range
{
[_CPNativeInputManager cancelCurrentInputSessionIfNeeded];
[self setSelectedRange:range affinity:0 stillSelecting:NO];
}
/*!
Sets the selection to a range of characters in response to user action.
@param range The range of characters to select. This range must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
@param affinity The selection affinity for the selection. See selectionAffinity for more information about how affinities work.
@param selecting YES to behave appropriately for a continuing selection where the user is still dragging the mouse, NO otherwise. If YES, the receiver doesnt send notifications or remove the marking from its marked text. If NO, the receiver posts an NSTextViewDidChangeSelectionNotification to the default notification center and removes the marking from marked text if the new selection is greater than the marked region.
*/
- (void)setSelectedRange:(CPRange)range affinity:(CPSelectionAffinity)affinity stillSelecting:(BOOL)selecting
{
[self _setSelectedRange:range affinity:affinity stillSelecting:selecting overwriteTypingAttributes:YES];
}
/*!
Sets the selection to a range of characters in response to user action.
@param range The range of characters to select. This range must begin and end on glyph boundaries and not split base glyphs and their nonspacing marks.
@param affinity The selection affinity for the selection. See selectionAffinity for more information about how affinities work.
@param selecting YES to behave appropriately for a continuing selection where the user is still dragging the mouse, NO otherwise. If YES, the receiver doesnt send notifications or remove the marking from its marked text. If NO, the receiver posts an NSTextViewDidChangeSelectionNotification to the default notification center and removes the marking from marked text if the new selection is greater than the marked region.
@param doOverwrite YES to override typing attributes. NO to not override.
*/
- (void)_setSelectedRange:(CPRange)range affinity:(CPSelectionAffinity)affinity stillSelecting:(BOOL)selecting overwriteTypingAttributes:(BOOL)doOverwrite
{
var maxRange = CPMakeRange(0, [_layoutManager numberOfCharacters]);
var maxRange = CPMakeRange(0, [_layoutManager numberOfCharacters]),
newSelectionRange;
range = CPIntersectionRange(maxRange, range);
if (!selecting && [self _delegateRespondsToWillChangeSelectionFromCharacterRangeToCharacterRange])
{
_selectionRange = [self _sendDelegateWillChangeSelectionFromCharacterRange:_selectionRange toCharacterRange:range];
newSelectionRange = [self _sendDelegateWillChangeSelectionFromCharacterRange:_selectionRange toCharacterRange:range];
}
else
{
_selectionRange = CPMakeRangeCopy(range);
_selectionRange = [self selectionRangeForProposedRange:_selectionRange granularity:[self selectionGranularity]];
newSelectionRange = [self selectionRangeForProposedRange:range granularity:[self selectionGranularity]];
}
if (_selectionRange.length)
[_layoutManager invalidateDisplayForGlyphRange:_selectionRange];
var isNewSelection = !CPEqualRanges(newSelectionRange, _selectionRange);
if (isNewSelection)
_selectionRange = newSelectionRange;
if (newSelectionRange.length)
{
if (isNewSelection)
[_layoutManager invalidateDisplayForGlyphRange:newSelectionRange];
}
else
[self setNeedsDisplay:YES];
if (!selecting)
{
if ([self _isFirstResponder])
[self updateInsertionPointStateAndRestartTimer:((_selectionRange.length === 0) && ![_caret isBlinking])];
[self updateInsertionPointStateAndRestartTimer:((newSelectionRange.length === 0) && ![_caret isBlinking])];
if (doOverwrite && _placeholderString === nil)
// If there is no new selection but the pervious mouseDown has saved a selection we check against the saved selection instead
if (!isNewSelection && _mouseDownOldSelection)
isNewSelection = !CPEqualRanges(newSelectionRange, _mouseDownOldSelection);
if (doOverwrite && _placeholderString === nil && isNewSelection)
[self setTypingAttributes:[_textStorage attributesAtIndex:CPMaxRange(range) effectiveRange:nil]];
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeSelectionNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_didChangeSelection)
[_delegate textViewDidChangeSelection:[[CPNotification alloc] initWithName:CPTextViewDidChangeSelectionNotification object:self userInfo:nil]];
}
if (!selecting && _selectionRange.length > 0)
if (!selecting && newSelectionRange.length > 0)
[_CPNativeInputManager focusForClipboardOfTextView:self];
}
@@ -917,18 +1041,18 @@ var kDelegateRespondsTo_textShouldBeginEditing
{
var fraction = [],
point = [self convertPoint:point fromView:nil];
// convert to container coordinate
point.x -= _textContainerOrigin.x;
point.y -= _textContainerOrigin.y;
var index = [_layoutManager glyphIndexForPoint:point inTextContainer:_textContainer fractionOfDistanceThroughGlyph:fraction];
if (index === CPNotFound)
index = [_layoutManager numberOfCharacters];
else if (fraction[0] > 0.5)
index++;
return index;
}
- (CGPoint)_characterIndexFromEvent:(CPEvent)event
@@ -951,9 +1075,9 @@ var kDelegateRespondsTo_textShouldBeginEditing
[_CPNativeInputManager cancelCurrentInputSessionIfNeeded];
[_caret setVisibility:NO];
_startTrackingLocation = [self _characterIndexFromEvent:event];
var granularities = [CPNotFound, CPSelectByCharacter, CPSelectByWord, CPSelectByParagraph];
[self setSelectionGranularity:granularities[[event clickCount]]];
@@ -966,20 +1090,20 @@ var kDelegateRespondsTo_textShouldBeginEditing
placeholderFrame = CGRectIntersection([_layoutManager boundingRectForGlyphRange:placeholderRange inTextContainer:_textContainer], _frame),
rangeToHide = CPMakeRange(0, _selectionRange.location - lineBeginningIndex),
dragPlaceholder;
// hide the left part of the first line of the selection that is not included
[placeholderString addAttribute:CPForegroundColorAttributeName
value:[CPColor colorWithRed:1 green:1 blue:1 alpha:0]
range:rangeToHide];
_movingSelection = CPMakeRange(_startTrackingLocation, 0);
dragPlaceholder = [[CPTextView alloc] initWithFrame:placeholderFrame];
[dragPlaceholder._textStorage replaceCharactersInRange:CPMakeRange(0, 0) withAttributedString:placeholderString];
[dragPlaceholder setBackgroundColor:[CPColor colorWithRed:1 green:1 blue:1 alpha:0]];
[dragPlaceholder setAlphaValue:0.5];
var stringForPasting = [_textStorage attributedSubstringFromRange:CPMakeRangeCopy(_selectionRange)],
richData = [_CPRTFProducer produceRTF:stringForPasting documentAttributes:@{}],
draggingPasteboard = [CPPasteboard pasteboardWithName:CPDragPboard];
@@ -994,17 +1118,19 @@ var kDelegateRespondsTo_textShouldBeginEditing
pasteboard:draggingPasteboard
source:self
slideBack:YES];
return;
}
var setRange = CPMakeRange(_startTrackingLocation, 0);
if ([event modifierFlags] & CPShiftKeyMask)
setRange = _MakeRangeFromAbs(_startTrackingLocation < _MidRange(_selectionRange) ? CPMaxRange(_selectionRange) : _selectionRange.location, _startTrackingLocation);
else
_scrollingTimer = [CPTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(_supportScrolling:) userInfo:nil repeats:YES]; // fixme: only start if we are in the scrolling areas
// Save old selection so we can only send textViewDidChangeTypingAttribute notification when selection is changed on mouse up.
_mouseDownOldSelection = _selectionRange;
[self setSelectedRange:setRange affinity:0 stillSelecting:YES];
}
@@ -1020,7 +1146,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
if (_movingSelection)
return;
var oldRange = [self selectedRange],
index = [self _characterIndexFromEvent:event];
@@ -1047,6 +1173,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
_previousSelectionGranularity = [self selectionGranularity];
[self setSelectionGranularity:CPSelectByCharacter];
[self setSelectedRange:[self selectedRange] affinity:0 stillSelecting:NO];
_mouseDownOldSelection = nil;
var point = [_layoutManager locationForGlyphAtIndex:[self selectedRange].location];
_stickyXLocation = point.x;
@@ -1470,7 +1597,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (void)_deleteForRange:(CPRange)changedRange
{
if (![self shouldChangeTextInRange:changedRange replacementString:@""])
if (![self _didBeginEditing] || ![self shouldChangeTextInRange:changedRange replacementString:@""])
return;
changedRange = CPIntersectionRange(CPMakeRange(0, [_layoutManager numberOfCharacters]), changedRange);
@@ -1592,11 +1719,11 @@ var kDelegateRespondsTo_textShouldBeginEditing
[self _enrichEssentialTypingAttributes:_typingAttributes];
}
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeTypingAttributesNotification
object:self];
[[CPNotificationCenter defaultCenter] postNotificationName:CPTextViewDidChangeTypingAttributesNotification object:self];
if (_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_didChangeTypingAttributes)
[_delegate textViewDidChangeTypingAttributes:[[CPNotification alloc] initWithName:CPTextViewDidChangeTypingAttributesNotification object:self userInfo:nil]];
// We always clear the saved selection range from the last mouse down event here.
// This is normally done in mouseUp: but this is if that event was never sent.
_mouseDownOldSelection = nil;
}
- (CPDictionary)_attributesForFontPanel
@@ -1739,7 +1866,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (void)underline:(id)sender
{
if (![self shouldChangeTextInRange:_selectionRange replacementString:nil])
if (![self _didBeginEditing] || ![self shouldChangeTextInRange:_selectionRange replacementString:nil])
return;
if (!CPEmptyRange(_selectionRange))
@@ -2040,7 +2167,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
{
var point = [info draggingLocation],
location = [self _characterIndexFromRawPoint:CGPointCreateCopy(point)];
_movingSelection = CPMakeRange(location, 0);
[_caret _drawCaretAtLocation:_movingSelection.location];
[_caret setVisibility:YES];
@@ -2053,11 +2180,11 @@ var kDelegateRespondsTo_textShouldBeginEditing
{
var location = [self convertPoint:[aSender draggingLocation] fromView:nil],
pasteboard = [aSender draggingPasteboard];
if ([pasteboard availableTypeFromArray:[CPRTFPboardType, CPStringPboardType]])
{
[_caret setVisibility:NO];
if (CPLocationInRange(_movingSelection.location, _selectionRange))
{
[self setSelectedRange:_movingSelection];
@@ -2082,7 +2209,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
[self insertText:dataForPasting];
}, 0);
}
if ([pasteboard availableTypeFromArray:[CPColorDragType]])
[self setTextColor:[CPKeyedUnarchiver unarchiveObjectWithData:[pasteboard dataForType:CPColorDragType]] range:_selectionRange];
}
@@ -2156,6 +2283,14 @@ var kDelegateRespondsTo_textShouldBeginEditing
return [_delegate textShouldBeginEditing:self];
}
- (BOOL)_sendDelegateTextShouldEndEditing
{
if (!(_delegateRespondsToSelectorMask & kDelegateRespondsTo_textShouldEndEditing))
return YES;
return [_delegate textShouldEndEditing:self];
}
- (BOOL)_sendDelegateShouldChangeTextInRange:(CPRange)aRange replacementString:(CPString)aString
{
if (!(_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_shouldChangeTextInRange_replacementString))
@@ -2166,7 +2301,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (CPDictionary)_sendDelegateShouldChangeTypingAttributes:(CPDictionary)typingAttributes toAttributes:(CPDictionary)attributes
{
if (!(_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_doCommandBySelector))
if (!(_delegateRespondsToSelectorMask & kDelegateRespondsTo_textView_shouldChangeTypingAttributes_toAttributes))
return [CPDictionary dictionary];
return [_delegate textView:self shouldChangeTypingAttributes:typingAttributes toAttributes:attributes];
@@ -2399,7 +2534,7 @@ var CPTextViewAllowsUndoKey = @"CPTextViewAllowsUndoKey",
_caretTimer = nil;
}
}
- (void)_drawCaretAtLocation:(int)aLoc
{
var rect = [_textView._layoutManager boundingRectForGlyphRange:CPMakeRange(aLoc, 1) inTextContainer:_textView._textContainer];
@@ -2732,6 +2867,3 @@ var _CPCopyPlaceholder = '-';
}
@end
+3 -3
View File
@@ -113,13 +113,13 @@ var hexTable = [];
- (CPNumber)script
{
return [CPNumber numberWithInt: script];
return [CPNumber numberWithInt:script];
}
- (CPNumber)underline
{
if (underline != 0)
return [CPNumber numberWithInteger: underline];
return [CPNumber numberWithInt:underline];
else
return nil;
}
@@ -127,7 +127,7 @@ var hexTable = [];
- (CPNumber)strikethrough
{
if (strikethrough != 0)
return [CPNumber numberWithInteger: strikethrough];
return [CPNumber numberWithInt:strikethrough];
else
return nil;
}
+4 -6
View File
@@ -1,5 +1,5 @@
/*
RTFProducer.j
_CPRTFProducer.j
Serialize CPAttributedString to a RTF String
@@ -189,11 +189,9 @@ function _points2twips(a) { return (a) * 20.0; }
if (val)
{
var size = [val sizeValue];
detail = [CPString stringWithFormat:@"\\paperw%d \\paperh%d",
_points2twips(size.width),
_points2twips(size.height)];
_points2twips(val.width),
_points2twips(val.height)];
result += detail;
}
@@ -612,4 +610,4 @@ function _points2twips(a) { return (a) * 20.0; }
output += trailerString;
return output;
}
@end
@end
+12 -4
View File
@@ -523,17 +523,25 @@ CPTokenFieldDeleteButtonType = 1;
var element = [self _inputElement];
CPTokenFieldInputResigning = YES;
element.blur();
if (CPTokenFieldInputIsActive)
element.blur();
if (!CPTokenFieldInputDidBlur)
CPTokenFieldBlurHandler();
CPTokenFieldInputDidBlur = NO;
CPTokenFieldInputResigning = NO;
if (element.parentNode == [_tokenScrollView documentView]._DOMElement)
element.parentNode.removeChild(element);
// Previosly, we unflagged CPTokenFieldInputDidBlur and CPTokenFieldInputResigning before
// the call to removeChild. This may result in DOM exceptions in Chrome under certain conditions.
// See https://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node
// for why we need to unflag CPTokenFieldInputDidBlur and CPTokenFieldInputResigning
// only after removing the element.
CPTokenFieldInputDidBlur = NO;
CPTokenFieldInputResigning = NO;
CPTokenFieldInputIsActive = NO;
if (document.attachEvent)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 B

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 B

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 B

After

Width:  |  Height:  |  Size: 3.6 KiB

+15 -23
View File
@@ -508,9 +508,7 @@ var themedButtonValues = nil,
orientation: PatternIsVertical
}),
trackColorLegacy = PatternColor("scroller-legacy-vertical-track-center.png", 14.0, 1.0),
incrementColorLegacy = PatternColor("scroller-legacy-vertical-track-bottom.png", 14.0, 11.0),
decrementColorLegacy = PatternColor("scroller-legacy-vertical-track-top.png", 14.0, 11.0),
trackColorLegacy = PatternColor("scroller-legacy-vertical-track-center.png", 14.0, 1.0),
knobColor = PatternColor(
"scroller-vertical-knob{style}{position}.png",
@@ -535,7 +533,7 @@ var themedButtonValues = nil,
[@"minimum-knob-length", 21.0, CPThemeStateVertical],
// Overlay
[@"scroller-width", 9.0, CPThemeStateVertical],
[@"scroller-width", 14.0, CPThemeStateVertical],
[@"knob-inset", CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateVertical],
[@"track-inset", CGInsetMake(2.0, 0.0, 2.0, 0.0), CPThemeStateVertical],
[@"track-border-overlay", 12.0, CPThemeStateVertical],
@@ -553,7 +551,7 @@ var themedButtonValues = nil,
// Legacy
[@"scroller-width", 14.0, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"knob-inset", CGInsetMake(0.0, 2.0, 0.0, 2.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"track-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"track-border-overlay", 0.0, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
@@ -562,13 +560,11 @@ var themedButtonValues = nil,
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateSelected, CPThemeStateScrollerKnobDark]],
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
[@"knob-slot-color", trackColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
[@"knob-color", knobColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"knob-color", knobColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
[@"knob-color", knobColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
[@"increment-line-color", incrementColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"decrement-line-color", decrementColorLegacy, [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"decrement-line-size", CGSizeMake(14.0, 11.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"increment-line-size", CGSizeMake(14.0, 11.0), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]]
[@"knob-color", knobColor["dark"], [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"increment-line-color", [CPNull null], [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"decrement-line-color", [CPNull null], [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"decrement-line-size", CGSizeMakeZero(), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]],
[@"increment-line-size", CGSizeMakeZero(), [CPThemeStateVertical, CPThemeStateScrollViewLegacy]]
];
[self registerThemeValues:themedVerticalScrollerValues forView:scroller];
@@ -588,9 +584,7 @@ var themedButtonValues = nil,
orientation: PatternIsHorizontal
}),
trackColorLegacy = PatternColor("scroller-legacy-horizontal-track-center.png", 1.0, 14.0),
incrementColorLegacy = PatternColor("scroller-legacy-horizontal-track-right.png", 11.0, 14.0),
decrementColorLegacy = PatternColor("scroller-legacy-horizontal-track-left.png", 11.0, 14.0),
trackColorLegacy = PatternColor("scroller-legacy-horizontal-track-center.png", 1.0, 14.0),
knobColor = PatternColor(
"scroller-horizontal-knob{style}{position}.png",
@@ -631,20 +625,18 @@ var themedButtonValues = nil,
// Legacy
[@"scroller-width", 14.0, CPThemeStateScrollViewLegacy],
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateScrollViewLegacy],
[@"knob-inset", CGInsetMake(2.0, 0.0, 2.0, 0.0), CPThemeStateScrollViewLegacy],
[@"track-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateScrollViewLegacy],
[@"track-border-overlay", 0.0, CPThemeStateScrollViewLegacy],
[@"knob-slot-color", trackColorLegacy, CPThemeStateScrollViewLegacy],
[@"knob-slot-color", trackColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateSelected]],
[@"knob-slot-color", trackColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
[@"knob-slot-color", trackColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
[@"knob-color", knobColorLegacy, CPThemeStateScrollViewLegacy],
[@"knob-color", knobColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
[@"knob-color", knobColorLegacy, [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
[@"increment-line-color", incrementColorLegacy, CPThemeStateScrollViewLegacy],
[@"decrement-line-color", decrementColorLegacy, CPThemeStateScrollViewLegacy],
[@"decrement-line-size", CGSizeMake(11.0, 14.0), CPThemeStateScrollViewLegacy],
[@"increment-line-size", CGSizeMake(11.0, 14.0), CPThemeStateScrollViewLegacy]
[@"knob-color", knobColor["@"], CPThemeStateScrollViewLegacy],
[@"knob-color", knobColor["light"], [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobLight]],
[@"knob-color", knobColor["dark"], [CPThemeStateScrollViewLegacy, CPThemeStateScrollerKnobDark]],
[@"decrement-line-size", CGSizeMakeZero(), CPThemeStateScrollViewLegacy],
[@"increment-line-size", CGSizeMakeZero(), CPThemeStateScrollViewLegacy]
];
[self registerThemeValues:themedHorizontalScrollerValues forView:scroller];
+2 -1
View File
@@ -836,7 +836,8 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
- (void)setSelectedRange:(CPRange)aRange
{
#if PLATFORM(DOM)
[[[self window] platformWindow] setSelectedRange:aRange inElement:_DOMTextElement];
if (_DOMTextElement)
[[[self window] platformWindow] setSelectedRange:aRange inElement:_DOMTextElement];
#endif
}
+3 -6
View File
@@ -82,8 +82,7 @@
*/
- (void)encodePoint:(CGPoint)aPoint
{
[self encodeNumber:aPoint.x];
[self encodeNumber:aPoint.y];
_CPRaiseInvalidAbstractInvocation(self, _cmd);
}
/*!
@@ -92,8 +91,7 @@
*/
- (void)encodeRect:(CGRect)aRect
{
[self encodePoint:aRect.origin];
[self encodeSize:aRect.size];
_CPRaiseInvalidAbstractInvocation(self, _cmd);
}
/*!
@@ -102,8 +100,7 @@
*/
- (void)encodeSize:(CGSize)aSize
{
[self encodeNumber:aSize.width];
[self encodeNumber:aSize.height];
_CPRaiseInvalidAbstractInvocation(self, _cmd);
}
/*!
+1 -1
View File
@@ -209,7 +209,7 @@
[[self mutableArrayValueForKeyPath:aKeyPath] removeObjectsAtIndexes:indexes];
else if (changeKind === CPKeyValueChangeReplacement)
[[self mutableArrayValueForKeyPath:aKeyPath] replaceObjectAtIndexes:indexes withObjects:newValue];
[[self mutableArrayValueForKeyPath:aKeyPath] replaceObjectsAtIndexes:indexes withObjects:newValue];
}
else
{
+1 -1
View File
@@ -336,7 +336,7 @@ FIXME: Do we need this?
- (id)initWithCoder:(CPCoder)aCoder
{
return [aCoder decodeNumber];
return [aCoder decodeObjectForKey:@"self"];
}
- (void)encodeWithCoder:(CPCoder)aCoder
@@ -220,7 +220,7 @@ var CPSelectorNameKey = @"CPSelectorName",
{
if ([object isKindOfClass:[CPDictionary class]])
return [object objectForKey:anIndex];
else ([object isKindOfClass:[CPArray class]])
else if ([object isKindOfClass:[CPArray class]])
return [object objectAtIndex:anIndex];
[CPException raise:CPInvalidArgumentException reason:@"object[#] requires a CPDictionary or CPArray"];
@@ -70,7 +70,7 @@
return result;
}
- (BOOL)isEqual:(id)object;
- (BOOL)isEqual:(id)object
{
if (self === object)
return YES;
+7 -6
View File
@@ -310,18 +310,18 @@ var XML_XML = "xml",
#define FIRST_CHILD(anXMLNode) (anXMLNode.firstChild)
#define NEXT_SIBLING(anXMLNode) (anXMLNode.nextSibling)
#define PARENT_NODE(anXMLNode) (anXMLNode.parentNode)
#define DOCUMENT_ELEMENT(aDocument) (aDocument.documentElement)
#define DOCUMENT_ELEMENT(aDocument) (aDocument && aDocument.documentElement)
#define HAS_ATTRIBUTE_VALUE(anXMLNode, anAttributeName, aValue) (anXMLNode.getAttribute(anAttributeName) === aValue)
#define IS_OF_TYPE(anXMLNode, aType) (NODE_NAME(anXMLNode) === aType)
#define IS_PLIST(anXMLNode) IS_OF_TYPE(anXMLNode, PLIST_PLIST)
#define IS_WHITESPACE(anXMLNode) (NODE_TYPE(anXMLNode) === 8 || NODE_TYPE(anXMLNode) === 3)
#define IS_WHITESPACE(anXMLNode) (NODE_TYPE(anXMLNode) === 8 || NODE_TYPE(anXMLNode) === 3 || NODE_TYPE(anXMLNode) === 7)
#define IS_DOCUMENTTYPE(anXMLNode) (NODE_TYPE(anXMLNode) === 10)
#define PLIST_NEXT_SIBLING(anXMLNode) while ((anXMLNode = NEXT_SIBLING(anXMLNode)) && IS_WHITESPACE(anXMLNode));
#define PLIST_FIRST_CHILD(anXMLNode) { anXMLNode = FIRST_CHILD(anXMLNode); if (anXMLNode !== NULL && IS_WHITESPACE(anXMLNode)) PLIST_NEXT_SIBLING(anXMLNode) }
#define PLIST_FIRST_CHILD(anXMLNode) { anXMLNode = FIRST_CHILD(anXMLNode); if (anXMLNode != NULL && IS_WHITESPACE(anXMLNode)) PLIST_NEXT_SIBLING(anXMLNode) }
var textContent = function(nodes)
{
@@ -544,15 +544,16 @@ CFPropertyList.propertyListFromXML = function(/*String | XMLNode*/ aStringOrXMLN
XMLNode = parseXML(aStringOrXMLNode);
// Skip over DOCTYPE and so forth.
while (IS_OF_TYPE(XMLNode, XML_DOCUMENT) || IS_OF_TYPE(XMLNode, XML_XML))
while (XMLNode && (IS_OF_TYPE(XMLNode, XML_DOCUMENT) || IS_OF_TYPE(XMLNode, XML_XML))) {
PLIST_FIRST_CHILD(XMLNode);
}
// Skip over the DOCTYPE... see a pattern?
if (IS_DOCUMENTTYPE(XMLNode))
if (XMLNode && IS_DOCUMENTTYPE(XMLNode))
PLIST_NEXT_SIBLING(XMLNode);
// If this is not a PLIST, bail.
if (!IS_PLIST(XMLNode))
if (!XMLNode || !IS_PLIST(XMLNode))
return NULL;
var key = "",
+119 -19
View File
@@ -48,26 +48,91 @@
- (void)testTextViewSelectionRange
{
//TODO : uncomment once ojtest will be up to date on travis
var range;
//
//[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0,0), CPMakeRange(0, 18)]];
//[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
//[textView selectAll:self];
//range = [[textView selectedRanges] firstObject];
//[self assert:0 equals:range.location];
//[self assert:18 equals:range.length];
// [delegateSpy verifyThatAllExpectationsHaveBeenMet];
//
//
// [delegateSpy reset];
// [delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0, 18), CPMakeRange(3, 6)]];
// [delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
//[textView setSelectedRange:CPMakeRange(3, 6)];
//range = [[textView selectedRanges] firstObject];
//[self assert:3 equals:range.location];
//[self assert:6 equals:range.length];
// [delegateSpy verifyThatAllExpectationsHaveBeenMet];
[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0,0), CPMakeRange(0, 18)]];
[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
[delegateSpy selector:@selector(textView:shouldChangeTypingAttributes:toAttributes:) times:1];
[delegateSpy selector:@selector(textViewDidChangeTypingAttributes:) times:1];
[delegateSpy selector:@selector(textDidChange:) times:0];
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
[textView selectAll:self];
range = [[textView selectedRanges] firstObject];
[self assert:0 equals:range.location];
[self assert:18 equals:range.length];
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
[delegateSpy reset];
[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(0, 18), CPMakeRange(3, 6)]];
[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
[delegateSpy selector:@selector(textView:shouldChangeTypingAttributes:toAttributes:) times:1];
[delegateSpy selector:@selector(textViewDidChangeTypingAttributes:) times:1];
[delegateSpy selector:@selector(textDidChange:) times:0];
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
[textView setSelectedRange:CPMakeRange(3, 6)];
range = [[textView selectedRanges] firstObject];
[self assert:3 equals:range.location];
[self assert:6 equals:range.length];
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
// When selecting the same range again textView:shouldChangeTypingAttributes:toAttributes: or textViewDidChangeTypingAttributes: should not be triggered
[delegateSpy reset];
[delegateSpy selector:@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:) times:1 arguments:[textView, CPMakeRange(3, 6), CPMakeRange(3, 6)]];
[delegateSpy selector:@selector(textViewDidChangeSelection:) times:1];
[delegateSpy selector:@selector(textView:shouldChangeTypingAttributes:toAttributes:) times:0];
[delegateSpy selector:@selector(textViewDidChangeTypingAttributes:) times:0];
[delegateSpy selector:@selector(textDidChange:) times:0];
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
[textView setSelectedRange:CPMakeRange(3, 6)];
range = [[textView selectedRanges] firstObject];
[self assert:3 equals:range.location];
[self assert:6 equals:range.length];
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
}
- (void)testTextDidChange
{
[delegateSpy selector:@selector(textDidChange:) times:1];
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
[textView setString:@"New text"];
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
}
- (void)testTextBeginEditing
{
[delegateSpy selector:@selector(textDidChange:) times:1];
[delegateSpy selector:@selector(textShouldBeginEditing:) times:1];
[delegateSpy selector:@selector(textDidBeginEditing:) times:1];
[delegateSpy selector:@selector(textShouldEndEditing:) times:0];
[delegateSpy selector:@selector(textDidEndEditing:) times:0];
[self assertTrue:[theWindow makeFirstResponder:textView]];
[textView insertText:@"New text"];
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
}
- (void)testTextEndEditing
{
[self assertTrue:[theWindow makeFirstResponder:textView]];
[textView insertText:@"New text"];
[delegateSpy selector:@selector(textDidChange:) times:0];
[delegateSpy selector:@selector(textShouldBeginEditing:) times:0];
[delegateSpy selector:@selector(textDidBeginEditing:) times:0];
[delegateSpy selector:@selector(textShouldEndEditing:) times:1];
[delegateSpy selector:@selector(textDidEndEditing:) times:1];
[self assertFalse:[theWindow makeFirstResponder:nil]];
[delegateSpy verifyThatAllExpectationsHaveBeenMet];
}
@end
@@ -79,9 +144,44 @@
return newSelectedCharRange;
}
- (CPDictionary)textView:(CPTextView)textView shouldChangeTypingAttributes:(CPDictionary)oldTypingAttributes toAttributes:(CPDictionary)newTypingAttributes
{
return newTypingAttributes;
}
- (void)textViewDidChangeSelection:(CPNotification)aNotification
{
}
- (void)textViewDidChangeTypingAttributes:(CPNotification)aNotification
{
}
- (void)textDidChange:(CPNotification)aNotification
{
}
- (BOOL)textShouldBeginEditing:(CPText)aTextObject
{
return YES;
}
- (void)textDidBeginEditing:(CPNotification)aNotification
{
}
- (BOOL)textShouldEndEditing:(CPText)aTextObject
{
return YES;
}
- (void)textDidEndEditing:(CPNotification)aNotification
{
}
@end
@@ -0,0 +1,125 @@
/*
* AppController.j
* CPTextViewDelegateAndNotifications
*
* Created by Martin Carlberg on December 22, 2017.
* Copyright 2017, Oops AB All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "NotificationStatistics.j"
@implementation AppController : CPObject
{
@outlet CPWindow theWindow;
CPArray notificationStatistics @accessors;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
[self setNotificationStatistics: @[
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textView:willChangeSelectionFromCharacterRange:toCharacterRange:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textView:shouldChangeTextInRange:replacementString:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textView:doCommandBySelector:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textViewDidChangeSelection:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textView:shouldChangeTypingAttributes:toAttributes:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textViewDidChangeTypingAttributes:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textShouldBeginEditing:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textShouldEndEditing:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textDidBeginEditing:))],
[NotificationStatistics notificationStatisticsWithName:CPStringFromSelector(@selector(textDidEndEditing:))],
]];
self.globalOrder = 0;
}
- (void)awakeFromCib
{
// This is called when the cib is done loading.
// You can implement this method on any object instantiated from a Cib.
// It's a useful hook for setting up current UI values, and other things.
// In this case, we want the window from Cib to become our full browser window
[theWindow setFullPlatformWindow:YES];
self.globalOrder = 0;
}
- (IBAction)resetStatistics:(id)sender {
self.globalOrder = 0;
for (var i = 0, array = [self notificationStatistics]; i < array.length; i++) {
var ns = array[i];
[ns setOrder:0];
[ns setCount:0];
}
}
- (NotificationStatistics)notificationStatisticsWithName:(CPString)aName
{
for (var i = 0, array = [self notificationStatistics]; i < array.length; i++) {
var ns = array[i];
if ([ns.name isEqualToString:aName]) {
return ns;
}
}
return nil;
}
- (void)registerNotificationWithSelector:(SEL)selector
{
var ns = [self notificationStatisticsWithName:CPStringFromSelector(selector)];
if (ns) {
[ns setCount:[ns count] + 1];
[ns setOrder:self.globalOrder += 1];
}
}
- (CPRange)textView:(CPTextView)textView willChangeSelectionFromCharacterRange:(CPRange)oldSelectedCharRange toCharacterRange:(CPRange)newSelectedCharRange {
[self registerNotificationWithSelector:_cmd];
return newSelectedCharRange;
}
- (BOOL)textView:(CPTextView)textView shouldChangeTextInRange:(CPRange)affectedCharRange replacementString:(CPString)replacementString {
[self registerNotificationWithSelector:_cmd];
return YES;
}
- (BOOL)textView:(CPTextView)textView doCommandBySelector:(SEL)commandSelector {
[self registerNotificationWithSelector:_cmd];
return NO;
}
- (CPDictionary)textView:(CPTextView)textView shouldChangeTypingAttributes:(CPDictionary)oldTypingAttributes toAttributes:(CPDictionary)newTypingAttributes {
[self registerNotificationWithSelector:_cmd];
return newTypingAttributes;
}
- (void)textViewDidChangeSelection:(CPNotification)notification {
[self registerNotificationWithSelector:_cmd];
}
- (void)textViewDidChangeTypingAttributes:(CPNotification)notification {
[self registerNotificationWithSelector:_cmd];
}
- (BOOL)textShouldBeginEditing:(CPText)textObject {
[self registerNotificationWithSelector:_cmd];
return YES;
}
- (BOOL)textShouldEndEditing:(CPText)textObject {
[self registerNotificationWithSelector:_cmd];
return YES;
}
- (void)textDidBeginEditing:(CPNotification)notification {
[self registerNotificationWithSelector:_cmd];
}
- (void)textDidEndEditing:(CPNotification)notification {
[self registerNotificationWithSelector:_cmd];
}
@end
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>CPTextViewDelegateAndNotifications</string>
<key>CPBundleVersion</key>
<string>1.0</string>
<key>CPHumanReadableCopyright</key>
<string>Copyright © 2017, Your Company All rights reserved.</string>
</dict>
</plist>
@@ -0,0 +1,172 @@
/*
* Jakefile
* CPTextViewDelegateAndNotifications
*
* Created by You on December 22, 2017.
* Copyright 2017, Your Company All rights reserved.
*/
var ENV = require("system").env,
FILE = require("file"),
JAKE = require("jake"),
task = JAKE.task,
FileList = JAKE.FileList,
app = require("cappuccino/jake").app,
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug",
OS = require("os"),
projectName = "CPTextViewDelegateAndNotifications";
app (projectName, function(task)
{
ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks";
if (configuration === "Debug")
ENV["OBJJ_INCLUDE_PATHS"] = FILE.join(ENV["OBJJ_INCLUDE_PATHS"], configuration);
task.setBuildIntermediatesPath(FILE.join("Build", "CPTextViewDelegateAndNotifications.build", configuration));
task.setBuildPath(FILE.join("Build", configuration));
task.setProductName("CPTextViewDelegateAndNotifications");
task.setIdentifier("com.yourcompany.CPTextViewDelegateAndNotifications");
task.setVersion("1.0");
task.setAuthor("Your Company");
task.setEmail("feedback @nospam@ yourcompany.com");
task.setSummary("CPTextViewDelegateAndNotifications");
task.setSources(new FileList("**/*.j").exclude(FILE.join("Build", "**")).exclude(FILE.join("Frameworks", "Source", "**")));
task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist");
if (configuration === "Debug")
task.setCompilerFlags("-DDEBUG -g -S --inline-msg-send");
else
task.setCompilerFlags("-O2");
});
task ("default", [projectName], function()
{
printResults(configuration);
});
task ("build", ["default"], function()
{
updateApplicationSize();
});
task ("debug", function()
{
configuration = ENV["CONFIGURATION"] = "Debug";
JAKE.subjake(["."], "build", ENV);
});
task ("release", function()
{
configuration = ENV["CONFIGURATION"] = "Release";
JAKE.subjake(["."], "build", ENV);
});
task ("run", ["debug"], function()
{
OS.system(["open", FILE.join("Build", "Debug", projectName, "index.html")]);
});
task ("run-release", ["release"], function()
{
OS.system(["open", FILE.join("Build", "Release", projectName, "index.html")]);
});
task ("deploy", ["release"], function()
{
FILE.mkdirs(FILE.join("Build", "Deployment", projectName));
OS.system(["press", "-f", FILE.join("Build", "Release", projectName), FILE.join("Build", "Deployment", projectName)]);
printResults("Deployment")
});
function printResults(configuration)
{
print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, projectName));
print("----------------------------");
}
function updateApplicationSize()
{
print("Calculating application file sizes...");
var contents = FILE.read(FILE.join("Build", configuration, projectName, "Info.plist"), { charset:"UTF-8" }),
format = CFPropertyList.sniffedFormatOfString(contents),
plist = CFPropertyList.propertyListFromString(contents),
totalBytes = {executable:0, data:0, mhtml:0};
// Get the size of all framework executables and sprite data
var frameworksDir = "Frameworks";
if (configuration === "Debug")
frameworksDir = FILE.join(frameworksDir, "Debug");
var frameworks = FILE.list(frameworksDir);
frameworks.forEach(function(framework)
{
if (framework !== "Source")
addBundleFileSizes(FILE.join(frameworksDir, framework), totalBytes);
});
// Read in the default theme name, and attempt to get its size
var themeName = plist.valueForKey("CPDefaultTheme") || "Aristo2",
themePath = nil;
if (themeName === "Aristo" || themeName === "Aristo2")
themePath = FILE.join(frameworksDir, "AppKit", "Resources", themeName + ".blend");
else
themePath = FILE.join("Frameworks", "Resources", themeName + ".blend");
if (FILE.isDirectory(themePath))
addBundleFileSizes(themePath, totalBytes);
// Add sizes for the app
addBundleFileSizes(FILE.join("Build", configuration, projectName), totalBytes);
print("Executables: " + totalBytes.executable + ", sprite data: " + totalBytes.data + ", total: " + (totalBytes.executable + totalBytes.data));
var dict = new CFMutableDictionary();
dict.setValueForKey("executable", totalBytes.executable);
dict.setValueForKey("data", totalBytes.data);
dict.setValueForKey("mhtml", totalBytes.mhtml);
plist.setValueForKey("CPApplicationSize", dict);
FILE.write(FILE.join("Build", configuration, projectName, "Info.plist"), CFPropertyList.stringFromPropertyList(plist, format), { charset:"UTF-8" });
}
function addBundleFileSizes(bundlePath, totalBytes)
{
var bundleName = FILE.basename(bundlePath),
environment = bundleName === "Foundation" ? "Objj" : "Browser",
bundlePath = FILE.join(bundlePath, environment + ".environment");
if (FILE.isDirectory(bundlePath))
{
var filename = bundleName + ".sj",
filePath = new FILE.Path(FILE.join(bundlePath, filename));
if (filePath.exists())
totalBytes.executable += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "dataURLs.txt"));
if (filePath.exists())
totalBytes.data += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLData.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
filePath = new FILE.Path(FILE.join(bundlePath, "MHTMLPaths.txt"));
if (filePath.exists())
totalBytes.mhtml += filePath.size();
}
}
@@ -0,0 +1,33 @@
/*
* NotificationStatistics.j
* CPTextViewDelegateAndNotifications
*
* Created by Martin Carlberg on December 22, 2017.
* Copyright 2017, Oops AB All rights reserved.
*/
@import <Foundation/CPObject.j>
@implementation NotificationStatistics : CPObject {
CPString name @accessors;
CPUInteger order @accessors;
CPUInteger count @accessors;
}
+ (id)notificationStatisticsWithName:(CPString)aName
{
return [[NotificationStatistics alloc] initWithName:aName];
}
- (id)initWithName:(CPString)aName
{
self = [super init];
if (self) {
[self setName: aName];
[self setOrder:0];
[self setCount:0];
}
return self;
}
@end
File diff suppressed because one or more lines are too long
@@ -0,0 +1,503 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1050" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="450" id="451"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="AMainMenu" systemMenu="main" id="29" userLabel="MainMenu">
<items>
<menuItem title="NewApplication" id="56">
<menu key="submenu" title="NewApplication" systemMenu="apple" id="57">
<items>
<menuItem title="About NewApplication" id="58">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-2" id="142"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="236">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Preferences…" keyEquivalent="," id="129"/>
<menuItem isSeparatorItem="YES" id="143">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Quit NewApplication" keyEquivalent="q" id="136">
<connections>
<action selector="terminate:" target="-3" id="449"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="File" id="83">
<menu key="submenu" title="File" id="81">
<items>
<menuItem title="New" keyEquivalent="n" id="82">
<connections>
<action selector="newDocument:" target="-1" id="373"/>
</connections>
</menuItem>
<menuItem title="Open…" keyEquivalent="o" id="72">
<connections>
<action selector="openDocument:" target="-1" id="374"/>
</connections>
</menuItem>
<menuItem title="Open Recent" id="124">
<menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="125">
<items>
<menuItem title="Clear Menu" id="126">
<connections>
<action selector="clearRecentDocuments:" target="-1" id="127"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="79">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Close" keyEquivalent="w" id="73">
<connections>
<action selector="performClose:" target="-1" id="193"/>
</connections>
</menuItem>
<menuItem title="Save" keyEquivalent="s" id="75">
<connections>
<action selector="saveDocument:" target="-1" id="362"/>
</connections>
</menuItem>
<menuItem title="Save As…" keyEquivalent="S" id="80">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
<connections>
<action selector="saveDocumentAs:" target="-1" id="363"/>
</connections>
</menuItem>
<menuItem title="Revert to Saved" id="112">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="revertDocumentToSaved:" target="-1" id="364"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="217">
<menu key="submenu" title="Edit" id="205">
<items>
<menuItem title="Undo" keyEquivalent="z" id="207">
<connections>
<action selector="undo:" target="-1" id="223"/>
</connections>
</menuItem>
<menuItem title="Redo" keyEquivalent="Z" id="215">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
<connections>
<action selector="redo:" target="-1" id="231"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="206">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Cut" keyEquivalent="x" id="199">
<connections>
<action selector="cut:" target="-1" id="228"/>
</connections>
</menuItem>
<menuItem title="Copy" keyEquivalent="c" id="197">
<connections>
<action selector="copy:" target="-1" id="224"/>
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="203">
<connections>
<action selector="paste:" target="-1" id="226"/>
</connections>
</menuItem>
<menuItem title="Delete" id="202">
<connections>
<action selector="delete:" target="-1" id="235"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="198">
<connections>
<action selector="selectAll:" target="-1" id="232"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="214">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Find" id="218">
<menu key="submenu" title="Find" id="220">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="209">
<connections>
<action selector="performFindPanelAction:" target="-1" id="241"/>
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="208"/>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="213">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="221"/>
<menuItem title="Jump to Selection" keyEquivalent="j" id="210">
<connections>
<action selector="centerSelectionInVisibleArea:" target="-1" id="245"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Spelling and Grammar" id="216">
<menu key="submenu" title="Spelling and Grammar" id="200">
<items>
<menuItem title="Show Spelling…" keyEquivalent=":" id="204">
<connections>
<action selector="showGuessPanel:" target="-1" id="230"/>
</connections>
</menuItem>
<menuItem title="Check Spelling" keyEquivalent=";" id="201">
<connections>
<action selector="checkSpelling:" target="-1" id="225"/>
</connections>
</menuItem>
<menuItem title="Check Spelling While Typing" id="219">
<connections>
<action selector="toggleContinuousSpellChecking:" target="-1" id="222"/>
</connections>
</menuItem>
<menuItem title="Check Grammar With Spelling" id="346">
<connections>
<action selector="toggleGrammarChecking:" target="-1" id="347"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Substitutions" id="348">
<menu key="submenu" title="Substitutions" id="349">
<items>
<menuItem title="Smart Copy/Paste" tag="1" keyEquivalent="f" id="350">
<connections>
<action selector="toggleSmartInsertDelete:" target="-1" id="355"/>
</connections>
</menuItem>
<menuItem title="Smart Quotes" tag="2" keyEquivalent="g" id="351">
<connections>
<action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="356"/>
</connections>
</menuItem>
<menuItem title="Smart Links" tag="3" keyEquivalent="G" id="354">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
<connections>
<action selector="toggleAutomaticLinkDetection:" target="-1" id="357"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Speech" id="211">
<menu key="submenu" title="Speech" id="212">
<items>
<menuItem title="Start Speaking" id="196">
<connections>
<action selector="startSpeaking:" target="-1" id="233"/>
</connections>
</menuItem>
<menuItem title="Stop Speaking" id="195">
<connections>
<action selector="stopSpeaking:" target="-1" id="227"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="295">
<menu key="submenu" title="View" id="296">
<items>
<menuItem title="Show Toolbar" keyEquivalent="t" id="297">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="toggleToolbarShown:" target="-1" id="366"/>
</connections>
</menuItem>
<menuItem title="Customize Toolbar…" id="298">
<connections>
<action selector="runToolbarCustomizationPalette:" target="-1" id="365"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="19">
<menu key="submenu" title="Window" systemMenu="window" id="24">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="23">
<connections>
<action selector="performMiniaturize:" target="-1" id="37"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="239">
<connections>
<action selector="performZoom:" target="-1" id="240"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="92">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Bring All to Front" id="5">
<connections>
<action selector="arrangeInFront:" target="-1" id="39"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="103">
<menu key="submenu" title="Help" id="106">
<items>
<menuItem title="NewApplication Help" keyEquivalent="?" id="111">
<connections>
<action selector="showHelp:" target="-1" id="360"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
<point key="canvasLocation" x="120" y="359"/>
</menu>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="858" height="573"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
<view key="contentView" misplaced="YES" id="372">
<rect key="frame" x="0.0" y="0.0" width="858" height="573"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView misplaced="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="pkG-9p-L1p">
<rect key="frame" x="20" y="20" width="235" height="424"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<clipView key="contentView" id="EiI-ee-zCR">
<rect key="frame" x="1" y="1" width="218" height="422"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView importsGraphics="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="nUr-pg-zDx">
<rect key="frame" x="0.0" y="0.0" width="218" height="422"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="218" height="422"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="delegate" destination="450" id="2RS-z0-999"/>
</connections>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="RLI-ow-1u2">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="KgG-pv-JKw">
<rect key="frame" x="219" y="1" width="15" height="422"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<scrollView misplaced="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="oV3-St-RDT">
<rect key="frame" x="286" y="67" width="552" height="377"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="4G8-Fm-Isb">
<rect key="frame" x="1" y="0.0" width="550" height="376"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" autosaveName="NotificationStatistics" rowSizeStyle="automatic" headerView="7tf-PJ-zK5" viewBased="YES" id="2KG-kQ-cpM">
<rect key="frame" x="0.0" y="0.0" width="550" height="353"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="" width="316" minWidth="40" maxWidth="1000" id="k8O-E6-x6h">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Delegate method or Notification name">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="dcx-tu-bTu">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView misplaced="YES" id="DQw-W7-XIz">
<rect key="frame" x="1" y="1" width="316" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="phx-UH-hQH">
<rect key="frame" x="0.0" y="0.0" width="316" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="PwH-1T-aU0">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<connections>
<binding destination="DQw-W7-XIz" name="value" keyPath="objectValue.name" id="PaH-0y-yEa"/>
</connections>
</textFieldCell>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="phx-UH-hQH" id="uKc-cR-Bhw"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="" width="117" minWidth="10" maxWidth="3.4028234663852886e+38" id="bwc-2R-1Du">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Call order">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="n8r-c2-apm">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView misplaced="YES" id="ZgP-Mi-KmX">
<rect key="frame" x="320" y="1" width="117" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="01B-8B-a03">
<rect key="frame" x="0.0" y="0.0" width="117" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="mVi-7F-HQf">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<connections>
<binding destination="ZgP-Mi-KmX" name="value" keyPath="objectValue.order" id="HWU-4L-lvh"/>
</connections>
</textFieldCell>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="01B-8B-a03" id="xlW-wW-cKf"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="" width="108" minWidth="10" maxWidth="3.4028234663852886e+38" id="cRC-bG-ngq">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Number of calls">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="XOd-z8-Ye0">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView misplaced="YES" id="Nis-LS-J2r">
<rect key="frame" x="440" y="1" width="108" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="asb-V9-wBZ">
<rect key="frame" x="0.0" y="0.0" width="108" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="Ee5-H2-1UN">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<connections>
<binding destination="Nis-LS-J2r" name="value" keyPath="objectValue.count" id="pk4-2L-iZx"/>
</connections>
</textFieldCell>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="asb-V9-wBZ" id="q3w-4g-0WX"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<binding destination="gam-xN-1Lo" name="content" keyPath="arrangedObjects" id="8oG-xo-sWz"/>
</connections>
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="GO1-vn-D6b">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Acv-DO-UnI">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="7tf-PJ-zK5">
<rect key="frame" x="0.0" y="0.0" width="550" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" misplaced="YES" id="R6K-jS-lkH">
<rect key="frame" x="280" y="13" width="108" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="push" title="Reset stats" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="2MD-k0-PMk">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="resetStatistics:" target="450" id="HJn-kg-XwG"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" id="obI-bJ-c88">
<rect key="frame" x="18" y="460" width="822" height="99"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" id="p4W-vb-EYI">
<font key="font" metaFont="system"/>
<string key="title">This test application will track delegate methods and notification messages from the CPTextView to the left below.
 
The Call order column tells in which order they are called. It is an increasing global number for each call to a delegate method or notification message.
The Number of calls column show how many times this method or message has been sent.</string>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
<point key="canvasLocation" x="-21" y="-228.5"/>
</window>
<customObject id="450" customClass="AppController">
<connections>
<outlet property="theWindow" destination="371" id="459"/>
</connections>
</customObject>
<arrayController objectClassName="NotificationStatistics" editable="NO" preservesSelection="NO" selectsInsertedObjects="NO" avoidsEmptySelection="NO" clearsFilterPredicateOnInsertion="NO" id="gam-xN-1Lo">
<connections>
<binding destination="450" name="contentArray" keyPath="self.notificationStatistics" id="wRu-Y1-zDw"/>
</connections>
</arrayController>
<userDefaultsController representsSharedInstance="YES" id="MG9-sm-bR3"/>
</objects>
</document>
@@ -0,0 +1,204 @@
<!DOCTYPE html>
<html lang="en">
<!--
index-debug.html
CPTextViewDelegateAndNotifications
Created by You on December 22, 2017.
Copyright 2017, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPTextViewDelegateAndNotifications</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks"];
// The below will tell the compiler to generate debug symbols, type signatures and not inline objj_msgSend functions.
// This will affect only Objective-J code that is compiled when loading the application. It will not affect precompiled
// code like the Cappuccino frameworks.
//
// Debug symbols will give each Objective-J method a Javascript function name. Without a name it will be very hard to find
// the methods in the debugger.
// Type Signatures will give type information to the Objective-J runtime for instance variables and methods.
// Inline objj_msgSend will give a speed increase but decorators will not work. Check below on debug options for
// more information on decorators.
//
// Uncomment or comment on the line below to change the flags
OBJJ_COMPILER_FLAGS = ["IncludeDebugSymbols", "IncludeTypeSignatures", "SourceMap", "InlineMsgSend"];
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript">
objj_msgSend_reset();
// DEBUG OPTIONS:
// Decorators will only work when the code is compiled without the compiler option 'InlineMsgSend'. Check above.
// Uncomment to enable printing of backtraces on exceptions:
//objj_msgSend_decorate(objj_backtrace_decorator);
// Uncomment to supress exceptions that take place inside a message
//objj_msgSend_decorate(objj_supress_exceptions_decorator)
// Uncomment to enable runtime type checking:
//objj_msgSend_decorate(objj_typecheck_decorator);
// Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
// Tag view DOM elements with a "data-cappuccino-view" attribute that contains
// the class name of the view that created them. Comment this or set to false to disable.
appkit_tag_dom_elements = true;
</script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: 0;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
@@ -0,0 +1,166 @@
<!DOCTYPE html>
<html lang="en">
<!--
index.html
CPTextViewDelegateAndNotifications
Created by You on December 22, 2017.
Copyright 2017, Your Company All rights reserved.
-->
<head>
<meta charset="utf-8">
<!--[if lte IE 8]>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7, chrome=1">
<![endif]-->
<!--[if gte IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<![endif]-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="Resources/icon.png">
<link rel="apple-touch-startup-image" href="Resources/default.png">
<title>CPTextViewDelegateAndNotifications</title>
<!-- Custom javascript goes here -->
<!-- End custom javascript -->
<script type="text/javascript">
OBJJ_MAIN_FILE = "main.j";
// The below will tell the compiler to not generate debug symbols but will generate type signatures and inline objj_msgSend functions.
// This will affect only Objective-J code that is compiled when loading the application. It will not affect precompiled
// code like the Cappuccino frameworks.
// Uncomment or comment on the line below to change the flags
OBJJ_COMPILER_FLAGS = [/*"IncludeDebugSymbols"*/, "IncludeTypeSignatures"/*, "SourceMap"*/, "InlineMsgSend"];
var progressBar = null;
OBJJ_PROGRESS_CALLBACK = function(percent, appSize, path)
{
percent = percent * 100;
if (!progressBar)
progressBar = document.getElementById("progress-bar");
if (progressBar)
progressBar.style.width = Math.min(percent, 100) + "%";
}
var loadingHTML =
'<div id="loading">' +
' <div id="loading-text">Loading...</div>' +
' <div id="progress-indicator">' +
' <span id="progress-bar" style="width:0%"></span>' +
' </div>' +
'</div>';
</script>
<script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css">
html, body, h1, p {
margin: 0;
padding: 0;
}
/* We need a body wrapper because Cappuccino is unhappy if we change the body element */
#cappuccino-body {
/* Position it absolutely so it will fill the height without content */
position: absolute;
top: 0;
bottom: 0;
width: 100%;
/* Put it at the bottom of the stack so it doesn't interfere with UI */
z-index: 0;
}
#cappuccino-body .container {
display: table;
margin: 0 auto;
height: 100%;
}
#cappuccino-body .content {
display: table-cell;
height: 100%;
vertical-align: top;
}
#loading {
position: relative;
top: 35%;
}
#loading-text {
height: 1.5em;
color: #555;
font: normal bold 36px/36px Arial, sans-serif;
}
#progress-indicator {
padding: 0px;
height: 16px;
border: 5px solid #555;
border-radius: 18px;
background-color: white;
}
#progress-bar {
position: relative;
top: -1px;
left: -1px;
display: block;
height: 18px;
/* Compensate for moving the bar left 1px to overlap the indicator border */
border-right: 1px solid #555;
background-color: #555;
}
#noscript {
position: relative;
top: 35%;
padding: 1em 1.5em;
border: 5px solid #555;
border-radius: 16px;
background-color: white;
color: #555;
text-align: center;
font: bold 24px Arial, sans-serif;
}
#noscript a {
color: #98c0ff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="cappuccino-body">
<div class="container">
<div class="content">
<script type="text/javascript">
document.write(loadingHTML);
</script>
</div>
</div>
<noscript style="position:absolute; top:0; left:0; width:100%; height:100%">
<div class="container">
<div class="content">
<div id="noscript">
<p style="font-size:120%; margin-bottom:.75em">JavaScript is required for this site.</p>
<p><a href="http://www.enable-javascript.com" target="_blank">Enable JavaScript</a></p>
</div>
</div>
</div>
</noscript>
</div>
</body>
</html>
@@ -0,0 +1,18 @@
/*
* AppController.j
* CPTextViewDelegateAndNotifications
*
* Created by You on December 22, 2017.
* Copyright 2017, Your Company All rights reserved.
*/
@import <Foundation/Foundation.j>
@import <AppKit/AppKit.j>
@import "AppController.j"
function main(args, namedArgs)
{
CPApplicationMain(args, namedArgs);
}
+5
View File
@@ -26,6 +26,7 @@
@import "NSCell.j"
@import "NSControl.j"
@global NIB_CONNECTION_EQUIVALENCY_TABLE
@implementation CPTextField (NSCoding)
@@ -82,6 +83,10 @@
if (self)
{
var cell = [aCoder decodeObjectForKey:@"NSCell"];
// If we have bindings/connections connected to the text field cell make sure they are replaced
NIB_CONNECTION_EQUIVALENCY_TABLE[[cell UID]] = self;
[self NS_initWithCell:cell];
[self _adjustNib2CibSize];
}