From a7a48ea407aa07ed8f15facee2b74dbe282a98b6 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Sat, 16 Feb 2013 21:37:29 +0000 Subject: [PATCH] More CGFloat, NSUInteger and NSInteger changes. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@36153 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 15 ++++ Headers/AppKit/NSDragging.h | 2 +- Headers/AppKit/NSInputManager.h | 6 +- Headers/AppKit/NSLayoutManager.h | 4 +- Headers/AppKit/NSRulerView.h | 12 ++-- Headers/AppKit/NSText.h | 2 +- Headers/AppKit/NSTextView.h | 78 ++++++++------------- Source/NSInputManager.m | 4 +- Source/NSLayoutManager.m | 29 ++++++-- Source/NSText.m | 21 +++--- Source/NSTextView.m | 117 ++++++++++++++++--------------- Source/NSTextView_actions.m | 92 ++++++++++++------------ 12 files changed, 196 insertions(+), 186 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee6556b81..0e9808f36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2013-02-16 Fred Kiefer + + * Headers/AppKit/NSDragging.h + * Headers/AppKit/NSInputManager.h + * Headers/AppKit/NSLayoutManager.h + * Headers/AppKit/NSRulerView.h + * Headers/AppKit/NSText.h + * Headers/AppKit/NSTextView.h + * Source/NSInputManager.m + * Source/NSLayoutManager.m + * Source/NSText.m + * Source/NSTextView.m + * Source/NSTextView_actions.m + More CGFloat, NSUInteger and NSInteger changes. + 2013-02-16 Fred Kiefer * Headers/Additions/GNUstepGUI/GSWindowDecorationView.h diff --git a/Headers/AppKit/NSDragging.h b/Headers/AppKit/NSDragging.h index 4e2faa1a9..d596b1db4 100644 --- a/Headers/AppKit/NSDragging.h +++ b/Headers/AppKit/NSDragging.h @@ -50,7 +50,7 @@ enum _NSDragOperation { NSDragOperationEvery = UINT_MAX }; -typedef unsigned int NSDragOperation; +typedef NSUInteger NSDragOperation; @protocol NSDraggingInfo diff --git a/Headers/AppKit/NSInputManager.h b/Headers/AppKit/NSInputManager.h index 05bfe8925..7f200765d 100644 --- a/Headers/AppKit/NSInputManager.h +++ b/Headers/AppKit/NSInputManager.h @@ -40,7 +40,7 @@ @class NSImage; @protocol NSTextInput -- (void) setMarkedText: (id)aString selectedRange: (NSRange)selRange; +- (void) setMarkedText: (id)aString selectedRange: (NSRange)selRange; - (BOOL) hasMarkedText; - (NSRange) markedRange; - (NSRange) selectedRange; @@ -49,8 +49,8 @@ - (NSAttributedString *) attributedSubstringFromRange: (NSRange)theRange; -- (unsigned int) characterIndexForPoint: (NSPoint)thePoint; -- (long) conversationIdentifier; +- (NSUInteger) characterIndexForPoint: (NSPoint)thePoint; +- (NSInteger) conversationIdentifier; - (void) doCommandBySelector: (SEL)aSelector; - (NSRect) firstRectForCharacterRange: (NSRange)theRange; - (void) insertText: (id)aString; diff --git a/Headers/AppKit/NSLayoutManager.h b/Headers/AppKit/NSLayoutManager.h index 7b92ea330..bd011cf4f 100644 --- a/Headers/AppKit/NSLayoutManager.h +++ b/Headers/AppKit/NSLayoutManager.h @@ -122,9 +122,9 @@ typedef enum { - (unsigned int) glyphIndexForPoint: (NSPoint)aPoint inTextContainer: (NSTextContainer *)aTextContainer; -- (unsigned int) glyphIndexForPoint: (NSPoint)point +- (NSUInteger) glyphIndexForPoint: (NSPoint)point inTextContainer: (NSTextContainer *)container - fractionOfDistanceThroughGlyph: (float *)partialFraction; + fractionOfDistanceThroughGlyph: (CGFloat *)partialFraction; /* diff --git a/Headers/AppKit/NSRulerView.h b/Headers/AppKit/NSRulerView.h index 5ac1c7a45..29fce388e 100644 --- a/Headers/AppKit/NSRulerView.h +++ b/Headers/AppKit/NSRulerView.h @@ -159,13 +159,13 @@ typedef enum { - (BOOL)rulerView: (NSRulerView *)aRulerView shouldRemoveMarker: (NSRulerMarker *)aMarker; -- (float)rulerView: (NSRulerView *)aRulerView - willAddMarker: (NSRulerMarker *)aMarker - atLocation: (float)location; +- (CGFloat)rulerView: (NSRulerView *)aRulerView + willAddMarker: (NSRulerMarker *)aMarker + atLocation: (CGFloat)location; -- (float)rulerView: (NSRulerView *)aRulerView - willMoveMarker: (NSRulerMarker *)aMarker - toLocation: (float)location; +- (CGFloat)rulerView: (NSRulerView *)aRulerView + willMoveMarker: (NSRulerMarker *)aMarker + toLocation: (CGFloat)location; - (void)rulerView: (NSRulerView *)aRulerView willSetClientView: (NSView *)newClient; diff --git a/Headers/AppKit/NSText.h b/Headers/AppKit/NSText.h index ec07a6eac..b0bb00b94 100644 --- a/Headers/AppKit/NSText.h +++ b/Headers/AppKit/NSText.h @@ -286,7 +286,7 @@ enum { @interface NSText (GNUstepExtensions) -- (unsigned) textLength; /* PRIMITIVE */ +- (NSUInteger) textLength; /* PRIMITIVE */ @end diff --git a/Headers/AppKit/NSTextView.h b/Headers/AppKit/NSTextView.h index 7f2c01003..9d7df7d86 100644 --- a/Headers/AppKit/NSTextView.h +++ b/Headers/AppKit/NSTextView.h @@ -46,22 +46,23 @@ @class NSRulerView,NSRulerMarker; -typedef enum _NSSelectionGranularity { +enum _NSSelectionGranularity { NSSelectByCharacter = 0, NSSelectByWord = 1, NSSelectByParagraph = 2, -} NSSelectionGranularity; - +}; +typedef NSUInteger NSSelectionGranularity; /* TODO: this looks like a mosx extension, not a GNUstep extension. should double-check */ -typedef enum _NSSelectionAffinity { +enum _NSSelectionAffinity { NSSelectionAffinityUpstream = 0, NSSelectionAffinityDownstream = 1, -} NSSelectionAffinity; +}; +typedef NSUInteger NSSelectionAffinity; #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST) -typedef enum _NSFindPanelAction +enum _NSFindPanelAction { NSFindPanelActionShowFindPanel = 1, NSFindPanelActionNext, @@ -76,7 +77,8 @@ typedef enum _NSFindPanelAction NSFindPanelActionSelectAll, NSFindPanelActionSelectAllInSelection #endif -} NSFindPanelAction; +}; +typedef NSUInteger NSFindPanelAction; #endif /* @@ -162,14 +164,12 @@ therefore be stored in the NSLayoutManager to avoid problems. /* shared by all text views attached to one NSTextStorage */ - int _spellCheckerDocumentTag; - + NSInteger _spellCheckerDocumentTag; NSColor *_backgroundColor; NSSize _minSize; NSSize _maxSize; - /* The following is the object used when posting notifications. It is usually `self' - but in the case of multiple textviews @@ -177,7 +177,6 @@ therefore be stored in the NSLayoutManager to avoid problems. might or might not be `self'. This must *not* be retained. */ NSTextView *_notifObject; - /* other members of the text network */ NSTextContainer *_textContainer; NSLayoutManager *_layoutManager; @@ -204,7 +203,6 @@ therefore be stored in the NSLayoutManager to avoid problems. BOOL _drawInsertionPointNow; //#endif - /* Stores the insertion point rect - updated by updateInsertionPointStateAndRestartTimer: - we must make sure we call the method every time that the insertion point rect might @@ -218,12 +216,13 @@ therefore be stored in the NSLayoutManager to avoid problems. NSLayoutManager tries to maintain the original horizontal position when moving up/down.) */ - unsigned int _originalInsertionPointCharacterIndex; + NSUInteger _originalInsertionPointCharacterIndex; /* - 0=no information (_originalInsertionPointCharacterIndex undefined) - 1=horizontal - 2=vertical + * GSInsertionPointMovementDirection + * 0=no information (_originalInsertionPointCharacterIndex undefined) + * 1=horizontal + * 2=vertical */ int _currentInsertionPointMovementDirection; @@ -485,26 +484,6 @@ user/programmatic changes of the text. @interface NSTextView (leftovers) - - -/*** Ruler support ***/ - --(void) rulerView: (NSRulerView *)ruler didMoveMarker: (NSRulerMarker *)marker; --(void) rulerView: (NSRulerView *)ruler didRemoveMarker: (NSRulerMarker *)marker; --(void) rulerView: (NSRulerView *)ruler didAddMarker: (NSRulerMarker *)marker; --(BOOL) rulerView: (NSRulerView *)ruler shouldMoveMarker: (NSRulerMarker *)marker; --(BOOL) rulerView: (NSRulerView *)ruler shouldRemoveMarker: (NSRulerMarker *)marker; --(BOOL) rulerView: (NSRulerView *)ruler shouldAddMarker: (NSRulerMarker *)marker; --(float) rulerView: (NSRulerView *)ruler - willMoveMarker: (NSRulerMarker *)marker - toLocation: (float)location; --(float) rulerView: (NSRulerView *)ruler - willAddMarker: (NSRulerMarker *)marker - atLocation: (float)location; --(void) rulerView: (NSRulerView *)ruler - handleMouseDown: (NSEvent *)event; - - /*** Fine display control ***/ /* Like -setNeedsDisplayInRect: (NSView), bit if flag is YES, won't do any @@ -542,8 +521,8 @@ already been laid out. */ -(NSImage *) dragImageForSelectionWithEvent: (NSEvent *)event origin: (NSPoint *)origin; /* mosx */ --(unsigned int) dragOperationForDraggingInfo: (id )dragInfo - type: (NSString *)type; /* mosx */ +-(NSDragOperation) dragOperationForDraggingInfo: (id )dragInfo + type: (NSString *)type; /* mosx */ -(BOOL) dragSelectionWithEvent: (NSEvent *)event offset: (NSSize)mouseOffset slideBack: (BOOL)slideBack; /* mosx */ @@ -580,7 +559,7 @@ already been laid out. */ /*** Spell checking ***/ --(int) spellCheckerDocumentTag; +-(NSInteger) spellCheckerDocumentTag; /*** Smart copy/paste/delete support ***/ @@ -606,7 +585,7 @@ already been laid out. */ -(void) setTypingAttributes: (NSDictionary *)attrs; - (void) clickedOnLink: (id)link - atIndex: (unsigned int)charIndex; + atIndex: (NSUInteger)charIndex; -(void) updateRuler; -(void) updateFontPanel; @@ -632,10 +611,10 @@ already been laid out. */ - (void) complete: (id)sender; - (NSArray *) completionsForPartialWordRange: (NSRange)range - indexOfSelectedItem: (int *)index; + indexOfSelectedItem: (NSInteger *)index; - (void) insertCompletion: (NSString *)word forPartialWordRange: (NSRange)range - movement: (int)movement + movement: (NSInteger)movement isFinal: (BOOL)flag; - (void) performFindPanelAction: (id)sender; @@ -683,12 +662,12 @@ layout manager. */ -(void) textView: (NSTextView *)textView clickedOnCell: (id )cell inRect: (NSRect)cellFrame - atIndex: (unsigned)charIndex; + atIndex: (NSUInteger)charIndex; -(BOOL) textView: (NSTextView *)textView clickedOnLink: (id)link; -(BOOL) textView: (NSTextView *)textView clickedOnLink: (id)link - atIndex: (unsigned)charIndex; + atIndex: (NSUInteger)charIndex; -(void) textView: (NSTextView *)textView doubleClickedOnCell: (id )cell @@ -696,16 +675,17 @@ doubleClickedOnCell: (id )cell -(void) textView: (NSTextView *)textView doubleClickedOnCell: (id )cell inRect: (NSRect)cellFrame - atIndex: (unsigned)charIndex; + atIndex: (NSUInteger)charIndex; -(void) textView: (NSTextView *)view draggedCell: (id )cell - inRect: (NSRect)rect event:(NSEvent *)event; + inRect: (NSRect)rect + event:(NSEvent *)event; -(void) textView: (NSTextView *)view draggedCell: (id )cell inRect: (NSRect)rect event: (NSEvent *)event - atIndex: (unsigned)charIndex; + atIndex: (NSUInteger)charIndex; -(NSRange) textView: (NSTextView *)textView willChangeSelectionFromCharacterRange: (NSRange)oldSelectedCharRange @@ -729,10 +709,10 @@ replacementString will be nil. */ - (NSArray *) textView: (NSTextView *)textView completions: (NSArray *)words forPartialWordRange: (NSRange)range - indexOfSelectedItem: (int *)index; + indexOfSelectedItem: (NSInteger *)index; - (NSString *) textView: (NSTextView *)textView willDisplayToolTip: (NSString *)tooltip - forCharacterAtIndex: (unsigned int)index; + forCharacterAtIndex: (NSUInteger)index; - (void) textViewDidChangeTypingAttributes: (NSNotification *)notification; #endif #if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) diff --git a/Source/NSInputManager.m b/Source/NSInputManager.m index 0187c694b..d5a7cf9b1 100644 --- a/Source/NSInputManager.m +++ b/Source/NSInputManager.m @@ -770,12 +770,12 @@ static NSInputManager *currentInputManager = nil; return nil; } -- (unsigned int) characterIndexForPoint: (NSPoint)thePoint +- (NSUInteger) characterIndexForPoint: (NSPoint)thePoint { return 0; } -- (long) conversationIdentifier +- (NSInteger) conversationIdentifier { return 0; } diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index 3d691bcc6..34033bfec 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -635,15 +635,15 @@ line frag rect. */ TODO: decide on behavior wrt. invisible glyphs and pointer far away from anything visible */ --(unsigned int) glyphIndexForPoint: (NSPoint)point - inTextContainer: (NSTextContainer *)container - fractionOfDistanceThroughGlyph: (float *)partialFraction +-(NSUInteger) glyphIndexForPoint: (NSPoint)point + inTextContainer: (NSTextContainer *)container + fractionOfDistanceThroughGlyph: (CGFloat *)partialFraction { int i; textcontainer_t *tc; linefrag_t *lf; linefrag_point_t *lp; - float dummy; + CGFloat dummy; if (!partialFraction) partialFraction = &dummy; @@ -654,7 +654,7 @@ anything visible if (i == num_textcontainers) { NSLog(@"%s: invalid text container", __PRETTY_FUNCTION__); - return -1; + return NSNotFound; } [self _doLayoutToContainer: i point: point]; @@ -681,7 +681,14 @@ anything visible if (i > 0) { *partialFraction = 1.0; - return lf->pos - 1; + if (lf->pos == 0) + { + return NSNotFound; + } + else + { + return lf->pos - 1; + } } else { @@ -713,7 +720,15 @@ anything visible if (i == tc->num_linefrags) { *partialFraction = 1.0; - return tc->pos + tc->length - 1; /* TODO: this should return the correct thing even if the container is empty */ + /* TODO: this should return the correct thing even if the container is empty */ + if (tc->pos + tc->length == 0) + { + return NSNotFound; + } + else + { + return tc->pos + tc->length - 1; + } } /* only interested in x from here on */ diff --git a/Source/NSText.m b/Source/NSText.m index 71925855e..29fd07f5d 100644 --- a/Source/NSText.m +++ b/Source/NSText.m @@ -78,7 +78,8 @@ static Class concrete; /* * Getting and Setting Contents */ -- (void) replaceCharactersInRange: (NSRange)aRange withRTF: (NSData *)rtfData +- (void) replaceCharactersInRange: (NSRange)aRange + withRTF: (NSData *)rtfData { NSAttributedString *attr; @@ -146,24 +147,24 @@ old text. */ /* * old OpenStep methods doing the same */ -- (void) replaceRange: (NSRange)aRange withRTFD: (NSData*)rtfdData +- (void) replaceRange: (NSRange)aRange withRTFD: (NSData*)rtfdData { - [self replaceCharactersInRange: aRange withRTFD: rtfdData]; + [self replaceCharactersInRange: aRange withRTFD: rtfdData]; } -- (void) replaceRange: (NSRange)aRange withRTF: (NSData*)rtfData +- (void) replaceRange: (NSRange)aRange withRTF: (NSData*)rtfData { - [self replaceCharactersInRange: aRange withRTF: rtfData]; + [self replaceCharactersInRange: aRange withRTF: rtfData]; } -- (void) replaceRange: (NSRange)aRange withString: (NSString*)aString +- (void) replaceRange: (NSRange)aRange withString: (NSString*)aString { - [self replaceCharactersInRange: aRange withString: aString]; + [self replaceCharactersInRange: aRange withString: aString]; } -- (void) setText: (NSString*)aString range: (NSRange)aRange +- (void) setText: (NSString*)aString range: (NSRange)aRange { - [self replaceCharactersInRange: aRange withString: aString]; + [self replaceCharactersInRange: aRange withString: aString]; } - (void) setText: (NSString*)aString @@ -652,7 +653,7 @@ old text. */ @implementation NSText (GNUstepExtensions) /* PRIMITIVE */ -- (unsigned) textLength +- (NSUInteger) textLength { [self subclassResponsibility: _cmd]; return 0; diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 0fa0787a4..3cafdbe44 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -133,8 +133,8 @@ a new internal method called from NSLayoutManager when text has changed. Interface for a bunch of internal methods that need to be cleaned up. */ @interface NSTextView (GNUstepPrivate) -- (unsigned int) _characterIndexForPoint: (NSPoint)point - respectFraction: (BOOL)respectFraction; +- (NSUInteger) _characterIndexForPoint: (NSPoint)point + respectFraction: (BOOL)respectFraction; /* * Used to implement the blinking insertion point @@ -438,7 +438,7 @@ editing is turned on or off. withFlag: (BOOL)flag { NSArray *array; - int i, count; + NSUInteger i, count; if (IS_SYNCHRONIZING_FLAGS == YES) { @@ -1156,7 +1156,7 @@ to this method from the text container or layout manager. */ - (void) setTextContainer: (NSTextContainer *)container { - unsigned int i, c; + NSUInteger i, c; NSArray *tcs; NSTextView *other; @@ -1224,7 +1224,7 @@ to this method from the text container or layout manager. - (void) replaceTextContainer: (NSTextContainer *)newContainer { NSLayoutManager *lm = _layoutManager; - unsigned int index = [[lm textContainers] indexOfObject: _textContainer]; + NSUInteger index = [[lm textContainers] indexOfObject: _textContainer]; NSTextStorage *ts = _textStorage; RETAIN(self); @@ -1301,7 +1301,7 @@ to make sure syncing is handled properly in all cases. /* Invoke setDelegate: on all the textviews which share this delegate. */ NSArray *array; - int i, count; + NSUInteger i, count; IS_SYNCHRONIZING_DELEGATES = YES; @@ -1645,7 +1645,7 @@ to make sure syncing is handled properly in all cases. { id futureFirstResponder; NSArray *textContainers; - int i, count; + NSUInteger i, count; futureFirstResponder = [_window _futureFirstResponder]; textContainers = [_layoutManager textContainers]; @@ -2072,7 +2072,7 @@ here. */ } // This method takes screen coordinates as input. -- (unsigned int) characterIndexForPoint: (NSPoint)point +- (NSUInteger) characterIndexForPoint: (NSPoint)point { point = [[self window] convertScreenToBase: point]; point = [self convertPoint:point fromView: nil]; @@ -2119,9 +2119,9 @@ here. */ NSForegroundColorAttributeName, NSFontAttributeName, nil]; } -- (long int) conversationIdentifier +- (NSInteger) conversationIdentifier { - return (long int)_textStorage; + return (NSInteger)_textStorage; } - (NSRect) firstRectForCharacterRange: (NSRange)theRange @@ -2455,7 +2455,7 @@ the attributes for the range, and do not update the typing attributes. return [_textStorage string]; } -- (unsigned) textLength +- (NSUInteger) textLength { return [_textStorage length]; } @@ -2906,7 +2906,7 @@ Scroll so that the beginning of the range is visible. { NSRect rect, r; NSView *cv; - float width; + CGFloat width; NSPoint p0, p1; NSRange ourCharRange; @@ -3062,7 +3062,7 @@ Scroll so that the beginning of the range is visible. { /* Otherwise, fill the clip view with text; no blank space on either side. */ - float x; + CGFloat x; x = p1.x - width; if (x < rect.origin.x) @@ -3228,7 +3228,7 @@ This method is for user changes; see NSTextView_actions.m. - (void) changeFont: (id)sender { NSRange foundRange; - unsigned int maxSelRange; + NSUInteger maxSelRange; NSRange aRange= [self rangeForUserCharacterAttributeChange]; NSRange searchRange = aRange; NSFont *font; @@ -3401,7 +3401,7 @@ This method is for user changes; see NSTextView_actions.m. } - (void) clickedOnLink: (id)link - atIndex: (unsigned int)charIndex + atIndex: (NSUInteger)charIndex { if (_delegate != nil) { @@ -3409,7 +3409,7 @@ This method is for user changes; see NSTextView_actions.m. if ([_delegate respondsToSelector: selector]) { - [_delegate textView: self clickedOnLink: link atIndex: charIndex]; + [_delegate textView: self clickedOnLink: link atIndex: charIndex]; } } } @@ -3567,11 +3567,11 @@ afterString in order over charRange. - (NSRange) selectionRangeForProposedRange: (NSRange)proposedCharRange granularity: (NSSelectionGranularity)gr { - unsigned index; + NSUInteger index; NSRange aRange; NSRange newRange; NSString *string = [self string]; - unsigned length = [string length]; + NSUInteger length = [string length]; if (NSMaxRange (proposedCharRange) > length) { @@ -3647,7 +3647,7 @@ afterString in order over charRange. displayed selection could have been a temporary selection, different from the last official one: */ NSRange oldDisplayedRange; - unsigned int length = [_textStorage length]; + NSUInteger length = [_textStorage length]; oldDisplayedRange = _layoutManager->_selected_range; @@ -4093,7 +4093,7 @@ Figure out how the additional layout stuff is supposed to work. fromView: nil]; // Find out what the corresponding text is. startIndex = [self _characterIndexForPoint: point - respectFraction: NO]; + respectFraction: NO]; // Look up what the tooltip text should be. value = [_textStorage attribute: NSToolTipAttributeName atIndex: startIndex @@ -4330,7 +4330,7 @@ Figure out how the additional layout stuff is supposed to work. NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType] location: [marker markerLocation]]; NSRange range = [self rangeForUserParagraphAttributeChange]; - unsigned loc = range.location; + NSUInteger loc = range.location; NSParagraphStyle *style; NSMutableParagraphStyle *mstyle; @@ -4391,7 +4391,7 @@ Figure out how the additional layout stuff is supposed to work. { NSTextTab *tab = (NSTextTab *)[marker representedObject]; NSRange range = [self rangeForUserParagraphAttributeChange]; - unsigned loc = range.location; + NSUInteger loc = range.location; NSParagraphStyle *style; NSMutableParagraphStyle *mstyle; @@ -4446,7 +4446,7 @@ Figure out how the additional layout stuff is supposed to work. NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType] location: [marker markerLocation]]; NSRange range = [self rangeForUserParagraphAttributeChange]; - unsigned loc = range.location; + NSUInteger loc = range.location; NSParagraphStyle *style; NSMutableParagraphStyle *mstyle; @@ -4505,7 +4505,7 @@ Figure out how the additional layout stuff is supposed to work. { NSPoint point = [ruler convertPoint: [event locationInWindow] fromView: nil]; - float location = point.x; + CGFloat location = point.x; NSRulerMarker *marker = [[NSRulerMarker alloc] initWithRulerView: ruler markerLocation: location @@ -4553,9 +4553,9 @@ shouldRemoveMarker: (NSRulerMarker *)marker /** * Return a position for adding by constraining the specified location. */ -- (float) rulerView: (NSRulerView *)ruler - willAddMarker: (NSRulerMarker *)marker - atLocation: (float)location +- (CGFloat) rulerView: (NSRulerView *)ruler + willAddMarker: (NSRulerMarker *)marker + atLocation: (CGFloat)location { NSSize size = [_textContainer containerSize]; @@ -4571,9 +4571,9 @@ shouldRemoveMarker: (NSRulerMarker *)marker /** * Return a new position by constraining the specified location. */ -- (float) rulerView: (NSRulerView *)ruler - willMoveMarker: (NSRulerMarker *)marker - toLocation: (float)location +- (CGFloat) rulerView: (NSRulerView *)ruler + willMoveMarker: (NSRulerMarker *)marker + toLocation: (CGFloat)location { NSSize size = [_textContainer containerSize]; @@ -4668,7 +4668,7 @@ shouldRemoveMarker: (NSRulerMarker *)marker } -- (int) spellCheckerDocumentTag +- (NSInteger) spellCheckerDocumentTag { if (!_spellCheckerDocumentTag) _spellCheckerDocumentTag = [NSSpellChecker uniqueSpellDocumentTag]; @@ -5199,17 +5199,17 @@ other than copy/paste or dragging. */ } - (void) _updateDragTargetLocation: (id )sender - operation: (unsigned int *)flags + operation: (NSDragOperation *)flags { if (*flags != NSDragOperationNone) { - NSPoint dragPoint; - unsigned dragIndex; + NSPoint dragPoint; + NSUInteger dragIndex; dragPoint = [sender draggingLocation]; dragPoint = [self convertPoint: dragPoint fromView: nil]; dragIndex = [self _characterIndexForPoint: dragPoint - respectFraction: YES]; + respectFraction: YES]; if ([sender draggingSource] != self || dragIndex <= [self selectedRange].location || @@ -5237,7 +5237,7 @@ other than copy/paste or dragging. */ NSArray *types = [self readablePasteboardTypes]; NSString *type = [self preferredPasteboardTypeFromArray: [pboard types] restrictedToTypesFromArray: types]; - unsigned int flags = [self dragOperationForDraggingInfo: sender type: type]; + NSDragOperation flags = [self dragOperationForDraggingInfo: sender type: type]; if (![type isEqual: NSColorPboardType]) { @@ -5252,7 +5252,7 @@ other than copy/paste or dragging. */ NSArray *types = [self readablePasteboardTypes]; NSString *type = [self preferredPasteboardTypeFromArray: [pboard types] restrictedToTypesFromArray: types]; - unsigned int flags = [self dragOperationForDraggingInfo: sender type: type]; + NSDragOperation flags = [self dragOperationForDraggingInfo: sender type: type]; NSPoint dragPoint; NSRect vRect; @@ -5305,7 +5305,7 @@ other than copy/paste or dragging. */ - (void) draggingExited: (id )sender { - unsigned int flags = NSDragOperationNone; + NSDragOperation flags = NSDragOperationNone; [self _updateDragTargetLocation: sender operation: &flags]; } @@ -5375,8 +5375,8 @@ other than copy/paste or dragging. */ [self displayIfNeeded]; } -- (unsigned int) dragOperationForDraggingInfo: (id )dragInfo - type: (NSString *)type +- (NSDragOperation) dragOperationForDraggingInfo: (id )dragInfo + type: (NSString *)type { //TODO return NSDragOperationCopy | NSDragOperationGeneric; @@ -5447,7 +5447,7 @@ other than copy/paste or dragging. */ startPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil]; startIndex = [self _characterIndexForPoint: startPoint - respectFraction: [theEvent clickCount] == 1]; + respectFraction: [theEvent clickCount] == 1]; if ([theEvent modifierFlags] & NSShiftKeyMask) { @@ -5585,8 +5585,9 @@ other than copy/paste or dragging. */ YES if it handles the click, NO if it doesn't -- and if it doesn't, we need to pass the click to the next responder. */ - if ([_delegate textView: self clickedOnLink: link - atIndex: startIndex]) + if ([_delegate textView: self + clickedOnLink: link + atIndex: startIndex]) { return; } @@ -5602,10 +5603,10 @@ other than copy/paste or dragging. */ } chosenRange = [self selectionRangeForProposedRange: proposedRange - granularity: granularity]; + granularity: granularity]; if (canDrag) { - unsigned int mask = NSLeftMouseDraggedMask | NSLeftMouseUpMask; + NSUInteger mask = NSLeftMouseDraggedMask | NSLeftMouseUpMask; NSEvent *currentEvent; currentEvent = [_window nextEventMatchingMask: mask @@ -5626,8 +5627,8 @@ other than copy/paste or dragging. */ /* Enter modal loop tracking the mouse */ { - unsigned int mask = NSLeftMouseDraggedMask | NSLeftMouseUpMask - | NSPeriodicMask; + NSUInteger mask = NSLeftMouseDraggedMask | NSLeftMouseUpMask + | NSPeriodicMask; NSEvent *currentEvent; NSEvent *lastEvent = nil; /* Last non-periodic event. */ NSDate *distantPast = [NSDate distantPast]; @@ -5779,7 +5780,7 @@ static const NSInteger GSSpellingSuggestionMenuItemTag = 1; - (void) rightMouseDown: (NSEvent *)theEvent { - int i; + NSUInteger i; NSMenu *menu = [[self class] defaultMenu]; NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil]; NSUInteger index = [self _characterIndexForPoint: point @@ -5925,8 +5926,8 @@ configuation! */ NSDictionary *attributes; NSRange aRange = [self rangeForUserCharacterAttributeChange]; NSRange foundRange; - unsigned int location; - unsigned int maxSelRange = NSMaxRange(aRange); + NSUInteger location; + NSUInteger maxSelRange = NSMaxRange(aRange); if (aRange.location == NSNotFound) return; @@ -5966,7 +5967,7 @@ configuation! */ } - (NSArray *) completionsForPartialWordRange: (NSRange)range - indexOfSelectedItem: (int *)index + indexOfSelectedItem: (NSInteger *)index { // FIXME return nil; @@ -5974,7 +5975,7 @@ configuation! */ - (void) insertCompletion: (NSString *)word forPartialWordRange: (NSRange)range - movement: (int)movement + movement: (NSInteger)movement isFinal: (BOOL)flag { // FIXME @@ -6011,11 +6012,11 @@ configuation! */ TODO: make sure this is only called when _layoutManager is known non-nil, or add guards */ -- (unsigned int) _characterIndexForPoint: (NSPoint)point - respectFraction: (BOOL)respectFraction +- (NSUInteger) _characterIndexForPoint: (NSPoint)point + respectFraction: (BOOL)respectFraction { - unsigned index; - float fraction; + NSUInteger index; + CGFloat fraction; point.x -= _textContainerOrigin.x; point.y -= _textContainerOrigin.y; @@ -6032,7 +6033,7 @@ or add guards fractionOfDistanceThroughGlyph: &fraction]; // FIXME The layoutManager should never return -1. // Assume that the text is empty if this happens. - if (index == (unsigned int)-1) + if (index == NSNotFound) return 0; index = [_layoutManager characterIndexForGlyphAtIndex: index]; @@ -6429,7 +6430,7 @@ or add guards - (NSTextView *) bestTextViewForTextStorage: (NSTextStorage *)aTextStorage { - int i, j; + NSUInteger i, j; NSArray *layoutManagers, *textContainers; NSTextView *tv, *first = nil, *best = nil; NSWindow *win; diff --git a/Source/NSTextView_actions.m b/Source/NSTextView_actions.m index 6eac6026e..b7cdf5a2b 100644 --- a/Source/NSTextView_actions.m +++ b/Source/NSTextView_actions.m @@ -175,11 +175,11 @@ static NSString *killBuffer = @""; inRange: (NSRange)r using: (NSNumber*(*)(NSNumber*))func { - unsigned int i; + NSUInteger i; NSRange e, r2; id current, new; - if (![self shouldChangeTextInRange: r replacementString: nil]) + if (![self shouldChangeTextInRange: r replacementString: nil]) return; [_textStorage beginEditing]; @@ -830,7 +830,7 @@ added to the selection (1,3). return NSMaxRange(range); } -- (unsigned int) _movementEnd +- (NSUInteger) _movementEnd { NSRange range = [self selectedRange]; @@ -840,12 +840,12 @@ added to the selection (1,3). return NSMaxRange(range); } -- (void) _moveTo: (unsigned int)cindex +- (void) _moveTo: (NSUInteger)cindex select: (BOOL)select { if (select) { - unsigned int anchor = [self _movementEnd]; + NSUInteger anchor = [self _movementEnd]; if (anchor < cindex) { @@ -867,9 +867,9 @@ added to the selection (1,3). [self scrollRangeToVisible: NSMakeRange(cindex, 0)]; } -- (void) _moveFrom: (unsigned int)cindex +- (void) _moveFrom: (NSUInteger)cindex direction: (GSInsertionPointMovementDirection)direction - distance: (float)distance + distance: (CGFloat)distance select: (BOOL)select { int new_direction; @@ -907,7 +907,7 @@ added to the selection (1,3). } - (void) _move: (GSInsertionPointMovementDirection)direction - distance: (float)distance + distance: (CGFloat)distance select: (BOOL)select { [self _moveFrom: [self _movementOrigin] @@ -923,10 +923,10 @@ added to the selection (1,3). * it should only be used when moving a literal direction such as left right * up or down, not directions like forward, backward, beginning or end */ -- (unsigned int) _characterIndexForSelectedRange: (NSRange)range - direction: (GSInsertionPointMovementDirection)direction +- (NSUInteger) _characterIndexForSelectedRange: (NSRange)range + direction: (GSInsertionPointMovementDirection)direction { - unsigned int cIndex; + NSUInteger cIndex; NSParagraphStyle *parStyle; NSWritingDirection writingDirection; @@ -975,7 +975,7 @@ check if there was a reason for that. - (void) moveUp: (id)sender { NSRange range = [self selectedRange]; - unsigned int cIndex = [self _characterIndexForSelectedRange:range + NSUInteger cIndex = [self _characterIndexForSelectedRange:range direction:GSInsertionPointMoveUp]; [self _moveFrom: cIndex @@ -994,7 +994,7 @@ check if there was a reason for that. - (void) moveDown: (id)sender { NSRange range = [self selectedRange]; - unsigned int cIndex = [self _characterIndexForSelectedRange: range + NSUInteger cIndex = [self _characterIndexForSelectedRange: range direction: GSInsertionPointMoveDown]; [self _moveFrom: cIndex direction: GSInsertionPointMoveDown @@ -1015,7 +1015,7 @@ check if there was a reason for that. if (range.length) { - unsigned int cIndex; + NSUInteger cIndex; cIndex = [self _characterIndexForSelectedRange: range direction:GSInsertionPointMoveLeft]; @@ -1023,7 +1023,6 @@ check if there was a reason for that. } else { - [self _move: GSInsertionPointMoveLeft distance: 0.0 select: NO]; @@ -1055,7 +1054,7 @@ check if there was a reason for that. if (range.length) { - unsigned int cIndex; + NSUInteger cIndex; cIndex = [self _characterIndexForSelectedRange: range direction: GSInsertionPointMoveRight]; @@ -1080,18 +1079,18 @@ check if there was a reason for that. if (writingDirection == NSWritingDirectionRightToLeft) { - [self moveBackwardAndModifySelection: sender]; + [self moveBackwardAndModifySelection: sender]; } else { - [self moveForwardAndModifySelection: sender]; + [self moveForwardAndModifySelection: sender]; } } - (void) moveBackward: (id)sender { NSRange range = [self selectedRange]; - unsigned int to = range.location; + NSUInteger to = range.location; if (range.length == 0 && to) { @@ -1104,7 +1103,7 @@ check if there was a reason for that. - (void) moveBackwardAndModifySelection: (id)sender { - unsigned int to = [self _movementOrigin]; + NSUInteger to = [self _movementOrigin]; if (to == 0) return; @@ -1116,7 +1115,7 @@ check if there was a reason for that. - (void) moveForward: (id)sender { NSRange range = [self selectedRange]; - unsigned int to = NSMaxRange(range); + NSUInteger to = NSMaxRange(range); if (range.length == 0 && to != [_textStorage length]) { @@ -1129,7 +1128,7 @@ check if there was a reason for that. - (void) moveForwardAndModifySelection: (id)sender { - unsigned int to = [self _movementOrigin]; + NSUInteger to = [self _movementOrigin]; if (to == [_textStorage length]) return; @@ -1141,8 +1140,8 @@ check if there was a reason for that. - (void) moveWordBackward: (id)sender { NSRange range = [self selectedRange]; - unsigned int newLocation; - unsigned int cIndex = range.location; + NSUInteger newLocation; + NSUInteger cIndex = range.location; newLocation = [_textStorage nextWordFromIndex: cIndex forward: NO]; @@ -1152,7 +1151,7 @@ check if there was a reason for that. - (void) moveWordBackwardAndModifySelection: (id)sender { - unsigned int newLocation; + NSUInteger newLocation; newLocation = [_textStorage nextWordFromIndex: [self _movementOrigin] forward: NO]; @@ -1162,8 +1161,8 @@ check if there was a reason for that. - (void) moveWordForward: (id)sender { - unsigned newLocation; - unsigned int cIndex = NSMaxRange([self selectedRange]); + NSUInteger newLocation; + NSUInteger cIndex = NSMaxRange([self selectedRange]); newLocation = [_textStorage nextWordFromIndex: cIndex forward: YES]; @@ -1173,7 +1172,7 @@ check if there was a reason for that. - (void) moveWordForwardAndModifySelection: (id)sender { - unsigned newLocation; + NSUInteger newLocation; newLocation = [_textStorage nextWordFromIndex: [self _movementOrigin] forward: YES]; @@ -1230,11 +1229,11 @@ check if there was a reason for that. if (writingDirection == NSWritingDirectionRightToLeft) { - [self moveWordBackward: sender]; + [self moveWordBackward: sender]; } else { - [self moveWordForward: sender]; + [self moveWordForward: sender]; } } @@ -1249,11 +1248,11 @@ check if there was a reason for that. if (writingDirection == NSWritingDirectionRightToLeft) { - [self moveWordBackwardAndModifySelection: sender]; + [self moveWordBackwardAndModifySelection: sender]; } else { - [self moveWordForwardAndModifySelection: sender]; + [self moveWordForwardAndModifySelection: sender]; } } @@ -1285,7 +1284,6 @@ check if there was a reason for that. { NSRange aRange = [self selectedRange]; - aRange = [[_textStorage string] lineRangeForRange: NSMakeRange(aRange.location, 0)]; [self _moveTo: aRange.location @@ -1305,9 +1303,9 @@ check if there was a reason for that. - (void) _moveToEndOfParagraph: (id)sender modify:(BOOL)flag { NSRange aRange; - unsigned newLocation; - unsigned maxRange; - unsigned int cIndex; + NSUInteger newLocation; + NSUInteger maxRange; + NSUInteger cIndex; if (flag) { @@ -1381,7 +1379,7 @@ and layout is left-to-right */ - (void) moveToBeginningOfLine: (id)sender { NSRange range = [self selectedRange]; - unsigned int cIndex = range.location; + NSUInteger cIndex = range.location; [self _moveFrom: cIndex direction: GSInsertionPointMoveLeft @@ -1398,7 +1396,7 @@ and layout is left-to-right */ - (void) moveToEndOfLine: (id)sender { - unsigned int cIndex = NSMaxRange([self selectedRange]); + NSUInteger cIndex = NSMaxRange([self selectedRange]); [self _moveFrom: cIndex direction: GSInsertionPointMoveRight @@ -1421,10 +1419,10 @@ and layout is left-to-right */ */ - (void) _pageDown: (id)sender modify: (BOOL)flag { - float scrollDelta; - float oldOriginY; - float newOriginY; - unsigned int cIndex; + CGFloat scrollDelta; + CGFloat oldOriginY; + CGFloat newOriginY; + NSUInteger cIndex; if (flag) { @@ -1474,10 +1472,10 @@ and layout is left-to-right */ */ - (void) _pageUp: (id)sender modify:(BOOL)flag { - float scrollDelta; - float oldOriginY; - float newOriginY; - unsigned int cIndex; + CGFloat scrollDelta; + CGFloat oldOriginY; + CGFloat newOriginY; + NSUInteger cIndex; if (flag) { @@ -1592,7 +1590,7 @@ and layout is left-to-right */ - (void) selectLine: (id)sender { - unsigned int start, end, cindex; + NSUInteger start, end, cindex; cindex = [self _movementOrigin]; start = [_layoutManager characterIndexMoving: GSInsertionPointMoveLeft