mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 01:21:05 +00:00
Tidyups, access some ivars directly, and a bug fix for scrolling
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8386 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
91fb1e751e
commit
71f2cc1849
1 changed files with 147 additions and 123 deletions
|
@ -388,8 +388,11 @@ static NSNotificationCenter *nc;
|
||||||
{
|
{
|
||||||
if (_tf.is_rich_text)
|
if (_tf.is_rich_text)
|
||||||
{
|
{
|
||||||
[self setTypingAttributes: [_textStorage attributesAtIndex: range.location
|
NSDictionary *dict;
|
||||||
effectiveRange: NULL]];
|
|
||||||
|
dict = [_textStorage attributesAtIndex: range.location
|
||||||
|
effectiveRange: NULL];
|
||||||
|
[self setTypingAttributes: dict];
|
||||||
}
|
}
|
||||||
// <!>enable caret timed entry
|
// <!>enable caret timed entry
|
||||||
}
|
}
|
||||||
|
@ -398,28 +401,29 @@ static NSNotificationCenter *nc;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Make the selected range visible
|
// Make the selected range visible
|
||||||
[self scrollRangeToVisible: _selected_range];
|
[self scrollRangeToVisible: range];
|
||||||
|
|
||||||
// Redisplay what has changed
|
// Redisplay what has changed
|
||||||
// This does an unhighlight of the old selected region
|
// This does an unhighlight of the old selected region
|
||||||
overlap = NSIntersectionRange(oldRange, _selected_range);
|
overlap = NSIntersectionRange (oldRange, range);
|
||||||
if (overlap.length)
|
if (overlap.length)
|
||||||
{
|
{
|
||||||
// Try to optimize for overlapping ranges
|
// Try to optimize for overlapping ranges
|
||||||
if (range.location != oldRange.location)
|
if (range.location != oldRange.location)
|
||||||
[self setNeedsDisplayInRect:
|
{
|
||||||
[self rectForCharacterRange:
|
NSRange r;
|
||||||
MakeRangeFromAbs(MIN(range.location,
|
r = MakeRangeFromAbs (MIN (range.location, oldRange.location),
|
||||||
oldRange.location),
|
MAX (range.location, oldRange.location));
|
||||||
MAX(range.location,
|
[self setNeedsDisplayInRect: [self rectForCharacterRange: r]];
|
||||||
oldRange.location))]];
|
}
|
||||||
if (NSMaxRange(range) != NSMaxRange(oldRange))
|
if (NSMaxRange (range) != NSMaxRange (oldRange))
|
||||||
[self setNeedsDisplayInRect:
|
{
|
||||||
[self rectForCharacterRange:
|
NSRange r = MakeRangeFromAbs (MIN (NSMaxRange (range),
|
||||||
MakeRangeFromAbs(MIN(NSMaxRange(range),
|
NSMaxRange (oldRange)),
|
||||||
NSMaxRange(oldRange)),
|
MAX (NSMaxRange (range),
|
||||||
MAX(NSMaxRange(range),
|
NSMaxRange (oldRange)));
|
||||||
NSMaxRange (oldRange)))]];
|
[self setNeedsDisplayInRect: [self rectForCharacterRange: r]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -862,14 +866,15 @@ static NSNotificationCenter *nc;
|
||||||
- (void) sizeToFit
|
- (void) sizeToFit
|
||||||
{
|
{
|
||||||
// if we are a field editor we don't have to handle the size.
|
// if we are a field editor we don't have to handle the size.
|
||||||
if ([self isFieldEditor])
|
if (_tf.is_field_editor)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSSize oldSize = _frame.size;
|
NSSize oldSize = _frame.size;
|
||||||
float newWidth = oldSize.width;
|
float newWidth = oldSize.width;
|
||||||
float newHeight = oldSize.height;
|
float newHeight = oldSize.height;
|
||||||
NSRect textRect = [_layoutManager usedRectForTextContainer: [self textContainer]];
|
NSRect textRect = [_layoutManager usedRectForTextContainer:
|
||||||
|
_textContainer];
|
||||||
NSSize newSize;
|
NSSize newSize;
|
||||||
|
|
||||||
if (_tf.is_horizontally_resizable)
|
if (_tf.is_horizontally_resizable)
|
||||||
|
@ -899,7 +904,7 @@ static NSNotificationCenter *nc;
|
||||||
|
|
||||||
NSRange errorRange;
|
NSRange errorRange;
|
||||||
|
|
||||||
errorRange = [sp checkSpellingOfString: [self string]
|
errorRange = [sp checkSpellingOfString: [_textStorage string]
|
||||||
startingAt: NSMaxRange (_selected_range)];
|
startingAt: NSMaxRange (_selected_range)];
|
||||||
|
|
||||||
if (errorRange.length)
|
if (errorRange.length)
|
||||||
|
@ -935,8 +940,7 @@ static NSNotificationCenter *nc;
|
||||||
// This makes things so much simpler and stabler for now.
|
// This makes things so much simpler and stabler for now.
|
||||||
if (_tf.is_field_editor == NO)
|
if (_tf.is_field_editor == NO)
|
||||||
{
|
{
|
||||||
[self scrollRectToVisible: [self rectForCharacterRange:
|
[self scrollRectToVisible: [self rectForCharacterRange: aRange]];
|
||||||
_selected_range]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,13 +979,6 @@ static NSNotificationCenter *nc;
|
||||||
return [super validRequestorForSendType: sendType returnType: returnType];
|
return [super validRequestorForSendType: sendType returnType: returnType];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Methods which should be moved here from NSText
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//- (NSRect) rectForCharacterRange: (NSRange)aRange
|
|
||||||
//- (void) deleteRange: (NSRange)aRange backspace: (BOOL)flag;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NSTextView's specific methods
|
* NSTextView's specific methods
|
||||||
*/
|
*/
|
||||||
|
@ -1112,7 +1109,7 @@ static NSNotificationCenter *nc;
|
||||||
|
|
||||||
- (BOOL) shouldDrawInsertionPoint
|
- (BOOL) shouldDrawInsertionPoint
|
||||||
{
|
{
|
||||||
return (_selected_range.length == 0) && [self isEditable];
|
return (_selected_range.length == 0) && _tf.is_editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawInsertionPointInRect: (NSRect)rect
|
- (void) drawInsertionPointInRect: (NSRect)rect
|
||||||
|
@ -1132,7 +1129,7 @@ static NSNotificationCenter *nc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[self backgroundColor] set];
|
[_background_color set];
|
||||||
NSRectFill(rect);
|
NSRectFill(rect);
|
||||||
// FIXME: We should redisplay the character the cursor was on.
|
// FIXME: We should redisplay the character the cursor was on.
|
||||||
//[self setNeedsDisplayInRect: rect];
|
//[self setNeedsDisplayInRect: rect];
|
||||||
|
@ -1402,8 +1399,7 @@ static NSNotificationCenter *nc;
|
||||||
if (aRange.location == NSNotFound)
|
if (aRange.location == NSNotFound)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (![self shouldChangeTextInRange: aRange
|
if (![self shouldChangeTextInRange: aRange replacementString: nil])
|
||||||
replacementString: nil])
|
|
||||||
return;
|
return;
|
||||||
[_textStorage beginEditing];
|
[_textStorage beginEditing];
|
||||||
[_textStorage setAlignment: alignment
|
[_textStorage setAlignment: alignment
|
||||||
|
@ -1696,14 +1692,15 @@ replacing the selection.
|
||||||
if (_tf.uses_font_panel)
|
if (_tf.uses_font_panel)
|
||||||
{
|
{
|
||||||
NSRange longestRange;
|
NSRange longestRange;
|
||||||
NSFont *currentFont = [_textStorage attribute: NSFontAttributeName
|
NSFontManager *fm = [NSFontManager sharedFontManager];
|
||||||
|
NSFont *currentFont;
|
||||||
|
|
||||||
|
currentFont = [_textStorage attribute: NSFontAttributeName
|
||||||
atIndex: _selected_range.location
|
atIndex: _selected_range.location
|
||||||
longestEffectiveRange: &longestRange
|
longestEffectiveRange: &longestRange
|
||||||
inRange: _selected_range];
|
inRange: _selected_range];
|
||||||
|
[fm setSelectedFont: currentFont
|
||||||
[[NSFontManager sharedFontManager]
|
isMultiple: !NSEqualRanges (longestRange, _selected_range)];
|
||||||
setSelectedFont: currentFont
|
|
||||||
isMultiple: !NSEqualRanges(longestRange, _selected_range)];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1938,14 +1935,16 @@ afterString in order over charRange. */
|
||||||
|
|
||||||
- (void) deleteForward: (id)sender
|
- (void) deleteForward: (id)sender
|
||||||
{
|
{
|
||||||
if (_selected_range.location != [self textLength])
|
unsigned location = _selected_range.location;
|
||||||
|
|
||||||
|
if (location != [self textLength])
|
||||||
{
|
{
|
||||||
/* Not at the end of text -- delete following character */
|
/* Not at the end of text -- delete following character */
|
||||||
[self deleteRange:
|
NSRange delRange = NSMakeRange (location, 1);
|
||||||
[self selectionRangeForProposedRange:
|
|
||||||
NSMakeRange (_selected_range.location, 1)
|
delRange = [self selectionRangeForProposedRange: delRange
|
||||||
granularity: NSSelectByCharacter]
|
granularity: NSSelectByCharacter];
|
||||||
backspace: NO];
|
[self deleteRange: delRange backspace: NO];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2077,7 +2076,7 @@ afterString in order over charRange. */
|
||||||
|
|
||||||
- (BOOL) acceptsFirstResponder
|
- (BOOL) acceptsFirstResponder
|
||||||
{
|
{
|
||||||
if ([self isSelectable])
|
if (_tf.is_selectable)
|
||||||
return YES;
|
return YES;
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -2101,7 +2100,7 @@ afterString in order over charRange. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (([self isEditable])
|
if ((_tf.is_editable)
|
||||||
&& ([_delegate respondsToSelector: @selector(textShouldEndEditing:)])
|
&& ([_delegate respondsToSelector: @selector(textShouldEndEditing:)])
|
||||||
&& ([_delegate textShouldEndEditing: self] == NO))
|
&& ([_delegate textShouldEndEditing: self] == NO))
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -2123,7 +2122,7 @@ afterString in order over charRange. */
|
||||||
|
|
||||||
- (BOOL) becomeFirstResponder
|
- (BOOL) becomeFirstResponder
|
||||||
{
|
{
|
||||||
if ([self isSelectable] == NO)
|
if (_tf.is_selectable == NO)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2155,23 +2154,26 @@ afterString in order over charRange. */
|
||||||
- (void) drawRect: (NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
NSRange drawnRange = [_layoutManager glyphRangeForBoundingRect: rect
|
NSRange drawnRange = [_layoutManager glyphRangeForBoundingRect: rect
|
||||||
inTextContainer: [self textContainer]];
|
inTextContainer: _textContainer];
|
||||||
if (_tf.draws_background)
|
if (_tf.draws_background)
|
||||||
{
|
{
|
||||||
[_layoutManager drawBackgroundForGlyphRange: drawnRange
|
[_layoutManager drawBackgroundForGlyphRange: drawnRange
|
||||||
atPoint: [self textContainerOrigin]];
|
atPoint: _textContainerOrigin];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_layoutManager drawGlyphsForGlyphRange: drawnRange
|
[_layoutManager drawGlyphsForGlyphRange: drawnRange
|
||||||
atPoint: [self textContainerOrigin]];
|
atPoint: _textContainerOrigin];
|
||||||
|
|
||||||
if ([self shouldDrawInsertionPoint] &&
|
if ([self shouldDrawInsertionPoint])
|
||||||
(NSLocationInRange(_selected_range.location, drawnRange) ||
|
|
||||||
_selected_range.location == NSMaxRange(drawnRange)))
|
|
||||||
{
|
{
|
||||||
[self drawInsertionPointAtIndex: _selected_range.location
|
unsigned location = _selected_range.location;
|
||||||
color: _caret_color
|
|
||||||
turnedOn: YES];
|
if (NSLocationInRange (location, drawnRange)
|
||||||
|
|| location == NSMaxRange (drawnRange))
|
||||||
|
{
|
||||||
|
[self drawInsertionPointAtIndex: location color: _caret_color
|
||||||
|
turnedOn: YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2433,32 +2435,46 @@ container, returning the modified location. */
|
||||||
- (NSRange) rangeForUserCharacterAttributeChange
|
- (NSRange) rangeForUserCharacterAttributeChange
|
||||||
{
|
{
|
||||||
if (!_tf.is_editable || !_tf.uses_font_panel)
|
if (!_tf.is_editable || !_tf.uses_font_panel)
|
||||||
return NSMakeRange(NSNotFound, 0);
|
{
|
||||||
|
return NSMakeRange (NSNotFound, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (_tf.is_rich_text)
|
if (_tf.is_rich_text)
|
||||||
// This expects the selection to be already corrected to characters
|
{
|
||||||
return _selected_range;
|
// This expects the selection to be already corrected to characters
|
||||||
|
return _selected_range;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return NSMakeRange(0, [_textStorage length]);
|
{
|
||||||
|
return NSMakeRange (0, [_textStorage length]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRange) rangeForUserParagraphAttributeChange
|
- (NSRange) rangeForUserParagraphAttributeChange
|
||||||
{
|
{
|
||||||
if (!_tf.is_editable || !_tf.uses_ruler)
|
if (!_tf.is_editable || !_tf.uses_ruler)
|
||||||
return NSMakeRange(NSNotFound, 0);
|
{
|
||||||
|
return NSMakeRange (NSNotFound, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (_tf.is_rich_text)
|
if (_tf.is_rich_text)
|
||||||
return [self selectionRangeForProposedRange: _selected_range
|
{
|
||||||
granularity: NSSelectByParagraph];
|
return [self selectionRangeForProposedRange: _selected_range
|
||||||
|
granularity: NSSelectByParagraph];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return NSMakeRange(0, [_textStorage length]);
|
{
|
||||||
|
return NSMakeRange (0, [_textStorage length]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRange) rangeForUserTextChange
|
- (NSRange) rangeForUserTextChange
|
||||||
{
|
{
|
||||||
if (!_tf.is_editable)
|
if (!_tf.is_editable)
|
||||||
return NSMakeRange(NSNotFound, 0);
|
{
|
||||||
|
return NSMakeRange (NSNotFound, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// This expects the selection to be already corrected to characters
|
// This expects the selection to be already corrected to characters
|
||||||
return _selected_range;
|
return _selected_range;
|
||||||
}
|
}
|
||||||
|
@ -2489,16 +2505,16 @@ container, returning the modified location. */
|
||||||
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
|
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Reads the text view's preferred type of data from the pasteboard specified
|
Reads the text view's preferred type of data from the pasteboard
|
||||||
by the pboard parameter. This method
|
specified by the pboard parameter. This method invokes the
|
||||||
invokes the preferredPasteboardTypeFromArray: restrictedToTypesFromArray:
|
preferredPasteboardTypeFromArray: restrictedToTypesFromArray: method
|
||||||
method to determine the text view's
|
to determine the text view's preferred type of data and then reads
|
||||||
preferred type of data and then reads the data using the
|
the data using the readSelectionFromPasteboard: type:
|
||||||
readSelectionFromPasteboard: type: method. Returns YES if the
|
method. Returns YES if the data was successfully read. */
|
||||||
data was successfully read.
|
NSString *type;
|
||||||
*/
|
|
||||||
NSString *type = [self preferredPasteboardTypeFromArray: [pboard types]
|
type = [self preferredPasteboardTypeFromArray: [pboard types]
|
||||||
restrictedToTypesFromArray: [self readablePasteboardTypes]];
|
restrictedToTypesFromArray: [self readablePasteboardTypes]];
|
||||||
|
|
||||||
if (type == nil)
|
if (type == nil)
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -2510,14 +2526,13 @@ data was successfully read.
|
||||||
type: (NSString*)type
|
type: (NSString*)type
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Reads data of the given type from pboard. The new data is placed at the
|
Reads data of the given type from pboard. The new data is placed at
|
||||||
current insertion point, replacing the current selection if one exists.
|
the current insertion point, replacing the current selection if one
|
||||||
Returns YES if the data was successfully read.
|
exists. Returns YES if the data was successfully read.
|
||||||
|
|
||||||
You should override this method to read pasteboard types other than the
|
You should override this method to read pasteboard types other than
|
||||||
default types. Use the rangeForUserTextChange method to obtain the range
|
the default types. Use the rangeForUserTextChange method to obtain
|
||||||
of characters (if any) to be replaced by the new data.
|
the range of characters (if any) to be replaced by the new data. */
|
||||||
*/
|
|
||||||
|
|
||||||
if ([type isEqualToString: NSStringPboardType])
|
if ([type isEqualToString: NSStringPboardType])
|
||||||
{
|
{
|
||||||
|
@ -2525,7 +2540,7 @@ of characters (if any) to be replaced by the new data.
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([self isRichText])
|
if (_tf.is_rich_text)
|
||||||
{
|
{
|
||||||
if ([type isEqualToString: NSRTFPboardType])
|
if ([type isEqualToString: NSRTFPboardType])
|
||||||
{
|
{
|
||||||
|
@ -2565,7 +2580,7 @@ of characters (if any) to be replaced by the new data.
|
||||||
NSRange aRange = [self rangeForUserCharacterAttributeChange];
|
NSRange aRange = [self rangeForUserCharacterAttributeChange];
|
||||||
|
|
||||||
if (aRange.location != NSNotFound)
|
if (aRange.location != NSNotFound)
|
||||||
[self setTextColor: color range: aRange];
|
[self setTextColor: color range: aRange];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -2573,10 +2588,11 @@ of characters (if any) to be replaced by the new data.
|
||||||
// font pasting
|
// font pasting
|
||||||
if ([type isEqualToString: NSFontPboardType])
|
if ([type isEqualToString: NSFontPboardType])
|
||||||
{
|
{
|
||||||
// FIXME - This should use a serializer. To get that working a helper object
|
// FIXME - This should use a serializer. To get that working a
|
||||||
// is needed that implements the NSObjCTypeSerializationCallBack protocol.
|
// helper object is needed that implements the
|
||||||
// We should add this later, currently the NSArchiver is used.
|
// NSObjCTypeSerializationCallBack protocol. We should add this
|
||||||
// Thanks to Richard, for pointing this out.
|
// later, currently the NSArchiver is used. Thanks to Richard,
|
||||||
|
// for pointing this out.
|
||||||
NSData *data = [pboard dataForType: NSFontPboardType];
|
NSData *data = [pboard dataForType: NSFontPboardType];
|
||||||
NSDictionary *dict = [NSUnarchiver unarchiveObjectWithData: data];
|
NSDictionary *dict = [NSUnarchiver unarchiveObjectWithData: data];
|
||||||
|
|
||||||
|
@ -2703,13 +2719,15 @@ other than copy/paste or dragging. */
|
||||||
|
|
||||||
if ([type isEqualToString: NSFontPboardType])
|
if ([type isEqualToString: NSFontPboardType])
|
||||||
{
|
{
|
||||||
NSDictionary *dict = [_textStorage fontAttributesInRange: _selected_range];
|
NSDictionary *dict;
|
||||||
|
|
||||||
|
dict = [_textStorage fontAttributesInRange: _selected_range];
|
||||||
if (dict != nil)
|
if (dict != nil)
|
||||||
{
|
{
|
||||||
// FIXME - This should use a serializer. To get that working a helper object
|
// FIXME - This should use a serializer. To get that
|
||||||
// is needed that implements the NSObjCTypeSerializationCallBack protocol.
|
// working a helper object is needed that implements the
|
||||||
// We should add this later, currently the NSArchiver is used.
|
// NSObjCTypeSerializationCallBack protocol. We should
|
||||||
|
// add this later, currently the NSArchiver is used.
|
||||||
// Thanks to Richard, for pointing this out.
|
// Thanks to Richard, for pointing this out.
|
||||||
[pboard setData: [NSArchiver archivedDataWithRootObject: dict]
|
[pboard setData: [NSArchiver archivedDataWithRootObject: dict]
|
||||||
forType: NSFontPboardType];
|
forType: NSFontPboardType];
|
||||||
|
@ -2719,8 +2737,9 @@ other than copy/paste or dragging. */
|
||||||
|
|
||||||
if ([type isEqualToString: NSRulerPboardType])
|
if ([type isEqualToString: NSRulerPboardType])
|
||||||
{
|
{
|
||||||
NSDictionary *dict = [_textStorage rulerAttributesInRange: _selected_range];
|
NSDictionary *dict;
|
||||||
|
|
||||||
|
dict = [_textStorage rulerAttributesInRange: _selected_range];
|
||||||
if (dict != nil)
|
if (dict != nil)
|
||||||
{
|
{
|
||||||
//FIXME: see NSFontPboardType above
|
//FIXME: see NSFontPboardType above
|
||||||
|
@ -2793,9 +2812,7 @@ other than copy/paste or dragging. */
|
||||||
while ((type = [enumerator nextObject]) != nil)
|
while ((type = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
val = [attributes objectForKey: type];
|
val = [attributes objectForKey: type];
|
||||||
[_textStorage addAttribute: type
|
[_textStorage addAttribute: type value: val range: aRange];
|
||||||
value: val
|
|
||||||
range: aRange];
|
|
||||||
}
|
}
|
||||||
[_textStorage endEditing];
|
[_textStorage endEditing];
|
||||||
[self didChangeText];
|
[self didChangeText];
|
||||||
|
@ -2811,7 +2828,7 @@ other than copy/paste or dragging. */
|
||||||
NSNumber *number;
|
NSNumber *number;
|
||||||
NSDictionary *uiDictionary;
|
NSDictionary *uiDictionary;
|
||||||
|
|
||||||
if (([self isEditable])
|
if ((_tf.is_editable)
|
||||||
&& ([_delegate respondsToSelector:
|
&& ([_delegate respondsToSelector:
|
||||||
@selector(textShouldEndEditing:)])
|
@selector(textShouldEndEditing:)])
|
||||||
&& ([_delegate textShouldEndEditing: self] == NO))
|
&& ([_delegate textShouldEndEditing: self] == NO))
|
||||||
|
@ -2878,8 +2895,7 @@ other than copy/paste or dragging. */
|
||||||
deleteRange = NSMakeRange (MAX (0, aRange.location - 1), 1);
|
deleteRange = NSMakeRange (MAX (0, aRange.location - 1), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![self shouldChangeTextInRange: deleteRange
|
if (![self shouldChangeTextInRange: deleteRange replacementString: @""])
|
||||||
replacementString: @""])
|
|
||||||
return;
|
return;
|
||||||
[_textStorage beginEditing];
|
[_textStorage beginEditing];
|
||||||
[_textStorage deleteCharactersInRange: deleteRange];
|
[_textStorage deleteCharactersInRange: deleteRange];
|
||||||
|
@ -2896,21 +2912,30 @@ other than copy/paste or dragging. */
|
||||||
|
|
||||||
- (unsigned) characterIndexForPoint: (NSPoint) point
|
- (unsigned) characterIndexForPoint: (NSPoint) point
|
||||||
{
|
{
|
||||||
unsigned glyphIndex = [_layoutManager glyphIndexForPoint: point
|
unsigned glyphIndex;
|
||||||
inTextContainer: [self textContainer]];
|
|
||||||
|
glyphIndex = [_layoutManager glyphIndexForPoint: point
|
||||||
|
inTextContainer: _textContainer];
|
||||||
|
|
||||||
return [_layoutManager characterIndexForGlyphAtIndex: glyphIndex];
|
return [_layoutManager characterIndexForGlyphAtIndex: glyphIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Move to NSTextView */
|
- (NSRect) rectForCharacterIndex: (unsigned)index
|
||||||
- (NSRect) rectForCharacterIndex: (unsigned) index
|
|
||||||
{
|
{
|
||||||
NSRange glyphRange = [_layoutManager glyphRangeForCharacterRange: NSMakeRange(index, 1)
|
NSRange charRange;
|
||||||
actualCharacterRange: NULL];
|
NSRange glyphRange;
|
||||||
unsigned glyphIndex = glyphRange.location;
|
unsigned glyphIndex;
|
||||||
NSRect rect = [_layoutManager lineFragmentRectForGlyphAtIndex: glyphIndex
|
NSRect rect;
|
||||||
effectiveRange: NULL];
|
NSPoint loc;
|
||||||
NSPoint loc = [_layoutManager locationForGlyphAtIndex: glyphIndex];
|
|
||||||
|
charRange = NSMakeRange (index, 1);
|
||||||
|
glyphRange = [_layoutManager glyphRangeForCharacterRange: charRange
|
||||||
|
actualCharacterRange: NULL];
|
||||||
|
glyphIndex = glyphRange.location;
|
||||||
|
|
||||||
|
rect = [_layoutManager lineFragmentRectForGlyphAtIndex: glyphIndex
|
||||||
|
effectiveRange: NULL];
|
||||||
|
loc = [_layoutManager locationForGlyphAtIndex: glyphIndex];
|
||||||
|
|
||||||
rect.origin.x += loc.x;
|
rect.origin.x += loc.x;
|
||||||
rect.size.width -= loc.x;
|
rect.size.width -= loc.x;
|
||||||
|
@ -2918,14 +2943,15 @@ other than copy/paste or dragging. */
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Move to NSTextView */
|
|
||||||
- (NSRect) rectForCharacterRange: (NSRange) aRange
|
- (NSRect) rectForCharacterRange: (NSRange) aRange
|
||||||
{
|
{
|
||||||
NSRange glyphRange = [_layoutManager glyphRangeForCharacterRange: aRange
|
NSRange glyphRange;
|
||||||
actualCharacterRange: NULL];
|
|
||||||
|
glyphRange = [_layoutManager glyphRangeForCharacterRange: aRange
|
||||||
|
actualCharacterRange: NULL];
|
||||||
|
|
||||||
return [_layoutManager boundingRectForGlyphRange: glyphRange
|
return [_layoutManager boundingRectForGlyphRange: glyphRange
|
||||||
inTextContainer: [self textContainer]];
|
inTextContainer: _textContainer];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawInsertionPointAtIndex: (unsigned) index
|
- (void) drawInsertionPointAtIndex: (unsigned) index
|
||||||
|
@ -2938,9 +2964,7 @@ other than copy/paste or dragging. */
|
||||||
if (drawRect.size.height == 0)
|
if (drawRect.size.height == 0)
|
||||||
drawRect.size.height = 12;
|
drawRect.size.height = 12;
|
||||||
|
|
||||||
[self drawInsertionPointInRect: drawRect
|
[self drawInsertionPointInRect: drawRect color: color turnedOn: flag];
|
||||||
color: color
|
|
||||||
turnedOn: flag];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -2949,30 +2973,30 @@ other than copy/paste or dragging. */
|
||||||
// This are all the NSTextInput methods that are not implemented on NSTextView
|
// This are all the NSTextInput methods that are not implemented on NSTextView
|
||||||
// or one of its super classes.
|
// or one of its super classes.
|
||||||
|
|
||||||
- (void)setMarkedText:(NSString *)aString selectedRange:(NSRange)selRange
|
- (void) setMarkedText:(NSString *)aString selectedRange:(NSRange)selRange
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)hasMarkedText
|
- (BOOL) hasMarkedText
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unmarkText
|
- (void) unmarkText
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*)validAttributesForMarkedText
|
- (NSArray*) validAttributesForMarkedText
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (long)conversationIdentifier
|
- (long) conversationIdentifier
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect)firstRectForCharacterRange:(NSRange)theRange
|
- (NSRect) firstRectForCharacterRange: (NSRange)theRange
|
||||||
{
|
{
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue