Adopted to changes in header

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6595 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2000-05-13 14:28:02 +00:00
parent 4d71078d84
commit 2cd62b8b5f
2 changed files with 160 additions and 112 deletions

View file

@ -1330,6 +1330,7 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
_tf.draws_background = YES; _tf.draws_background = YES;
[self setBackgroundColor: [NSColor textBackgroundColor]]; [self setBackgroundColor: [NSColor textBackgroundColor]];
[self setTextColor: [NSColor textColor]]; [self setTextColor: [NSColor textColor]];
ASSIGN(_caret_color, [NSColor blackColor]);
_default_font = RETAIN([NSFont userFontOfSize: 12]); _default_font = RETAIN([NSFont userFontOfSize: 12]);
// sets up the contents object // sets up the contents object
[self setString: @""]; [self setString: @""];
@ -1343,7 +1344,10 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
RELEASE(_background_color); RELEASE(_background_color);
RELEASE(_default_font); RELEASE(_default_font);
RELEASE(_text_color); RELEASE(_text_color);
RELEASE(_caret_color);
RELEASE(_textStorage); RELEASE(_textStorage);
RELEASE(_typingAttributes);
RELEASE(_layoutManager);
[super dealloc]; [super dealloc];
} }
@ -2301,7 +2305,7 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
[self drawSelectionAsRange: chosenRange]; [self drawSelectionAsRange: chosenRange];
else if (chosenRange.length == 0) else if (chosenRange.length == 0)
[self drawInsertionPointAtIndex: chosenRange.location [self drawInsertionPointAtIndex: chosenRange.location
color: [NSColor blackColor] turnedOn: YES]; color: _caret_color turnedOn: YES];
// remember for column stable cursor up/down // remember for column stable cursor up/down
_currentCursor = [self rectForCharacterIndex: chosenRange.location].origin; _currentCursor = [self rectForCharacterIndex: chosenRange.location].origin;
@ -2516,7 +2520,7 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
// { // {
// [self lockFocus]; // [self lockFocus];
// [self drawInsertionPointAtIndex: _selected_range.location // [self drawInsertionPointAtIndex: _selected_range.location
// color: [NSColor blackColor] turnedOn: YES]; // color: _caret_color turnedOn: YES];
// [self unlockFocus]; // [self unlockFocus];
// //<!> restart timed entry // //<!> restart timed entry
// } // }
@ -2577,28 +2581,34 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _delegate]; [aCoder encodeConditionalObject: _delegate];
[aCoder encodeObject: _textStorage]; [aCoder encodeObject: _textStorage];
[aCoder encodeValueOfObjCType: "I" at: &_alignment]; flag = _tf.is_field_editor;
flag = _tf.is_editable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_rich_text; flag = _tf.is_editable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_selectable; flag = _tf.is_selectable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_rich_text;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.imports_graphics; flag = _tf.imports_graphics;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.uses_font_panel; flag = _tf.draws_background;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_horizontally_resizable; flag = _tf.is_horizontally_resizable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_vertically_resizable; flag = _tf.is_vertically_resizable;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.uses_font_panel;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.uses_ruler;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_ruler_visible; flag = _tf.is_ruler_visible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _tf.is_field_editor; flag = _tf.smart_insert_delete;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
[aCoder encodeValueOfObjCType: "I" at: &_alignment];
[aCoder encodeObject: _background_color]; [aCoder encodeObject: _background_color];
[aCoder encodeObject: _text_color]; [aCoder encodeObject: _text_color];
[aCoder encodeObject: _default_font]; [aCoder encodeObject: _default_font];
@ -2611,28 +2621,34 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
_delegate = [aDecoder decodeObject]; _delegate = [aDecoder decodeObject];
_textStorage = [aDecoder decodeObject]; _textStorage = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: "I" at: &_alignment]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_field_editor = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_editable = flag; _tf.is_editable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_rich_text = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_selectable = flag; _tf.is_selectable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_rich_text = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.imports_graphics = flag; _tf.imports_graphics = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.uses_font_panel = flag; _tf.draws_background = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_horizontally_resizable = flag; _tf.is_horizontally_resizable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_vertically_resizable = flag; _tf.is_vertically_resizable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.uses_font_panel = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.uses_ruler = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_ruler_visible = flag; _tf.is_ruler_visible = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_tf.is_field_editor = flag; _tf.smart_insert_delete = flag;
[aDecoder decodeValueOfObjCType: "I" at: &_alignment];
_background_color = [aDecoder decodeObject]; _background_color = [aDecoder decodeObject];
_text_color = RETAIN([aDecoder decodeObject]); _text_color = RETAIN([aDecoder decodeObject]);
_default_font = RETAIN([aDecoder decodeObject]); _default_font = RETAIN([aDecoder decodeObject]);
@ -3206,7 +3222,7 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
drawRect.size.height = 12; drawRect.size.height = 12;
if (flag && color == nil) if (flag && color == nil)
color = [NSColor blackColor]; color = _caret_color;
[self drawInsertionPointInRect: drawRect [self drawInsertionPointInRect: drawRect
color: color color: color
@ -3269,7 +3285,7 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet)
else else
{ {
[self drawInsertionPointAtIndex: aRange.location [self drawInsertionPointAtIndex: aRange.location
color: [NSColor blackColor] color: _caret_color
turnedOn: YES]; turnedOn: YES];
} }
} }

View file

@ -89,103 +89,92 @@
- (id) initWithFrame: (NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
textStorage = [[NSTextStorage alloc] init]; NSTextContainer *aTextContainer =
[[NSTextContainer alloc] initWithContainerSize: frameRect.size];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
layoutManager = [[NSLayoutManager alloc] init]; [layoutManager addTextContainer: aTextContainer];
RELEASE(aTextContainer);
[textStorage addLayoutManager: layoutManager]; _textStorage = [[NSTextStorage alloc] init];
[_textStorage addLayoutManager: layoutManager];
RELEASE(layoutManager); RELEASE(layoutManager);
textContainer return [self initWithFrame: frameRect textContainer: aTextContainer];
= [[NSTextContainer alloc] initWithContainerSize: frameRect.size];
[layoutManager addTextContainer: textContainer];
RELEASE(textContainer);
return [self initWithFrame: frameRect textContainer: textContainer];
} }
- (void) setTextContainer: (NSTextContainer*)aTextContainer - (void) setTextContainer: (NSTextContainer*)aTextContainer
{ {
ASSIGN(textContainer, aTextContainer); ASSIGN(_textContainer, aTextContainer);
} }
- (NSTextContainer*) textContainer - (NSTextContainer*) textContainer
{ {
return textContainer; return _textContainer;
} }
- (void) replaceTextContainer: (NSTextContainer*)aTextContainer - (void) replaceTextContainer: (NSTextContainer*)aTextContainer
{ {
// Notify layoutManager of change? // Notify layoutManager of change?
ASSIGN(textContainer, aTextContainer); ASSIGN(_textContainer, aTextContainer);
} }
- (void) setTextContainerInset: (NSSize)inset - (void) setTextContainerInset: (NSSize)inset
{ {
textContainerInset = inset; _textContainerInset = inset;
} }
- (NSSize) textContainerInset - (NSSize) textContainerInset
{ {
return textContainerInset; return _textContainerInset;
} }
- (NSPoint) textContainerOrigin - (NSPoint) textContainerOrigin
{ {
// use bounds, inset, and used rect. return _textContainerOrigin;
NSRect bRect = [self bounds];
return NSZeroPoint;
} }
- (void) invalidateTextContainerOrigin - (void) invalidateTextContainerOrigin
{ {
tv_resetTextContainerOrigin = YES; // recompute the textContainerOrigin
// use bounds, inset, and used rect.
NSRect bRect = [self bounds];
} }
- (NSLayoutManager*) layoutManager - (NSLayoutManager*) layoutManager
{ {
return [textContainer layoutManager]; return [_textContainer layoutManager];
} }
- (NSTextStorage*) textStorage - (NSTextStorage*) textStorage
{ {
return textStorage; return _textStorage;
} }
- (void) setBackgroundColor: (NSColor*)aColor - (void) setBackgroundColor: (NSColor*)aColor
{ {
ASSIGN(tv_backGroundColor, aColor); ASSIGN(_background_color, aColor);
} }
- (NSColor*) backgroundColor - (NSColor*) backgroundColor
{ {
return tv_backGroundColor; return _background_color;
} }
- (void) setDrawsBackground: (BOOL)flag - (void) setDrawsBackground: (BOOL)flag
{ {
tv_drawsBackground = flag; _tf.draws_background = flag;
} }
- (BOOL) drawsBackground - (BOOL) drawsBackground
{ {
return tv_drawsBackground; return _tf.draws_background;
} }
- (void) setNeedsDisplayInRect: (NSRect)aRect - (void) setNeedsDisplayInRect: (NSRect)aRect
avoidAdditionalLayout: (BOOL)flag avoidAdditionalLayout: (BOOL)flag
{ {
/*
NSRange glyphsToDraw;
glyphsToDraw = [layoutManager glyphRangeForTextContainer: textContainer];
[self lockFocus];
[layoutManager drawGlyphsForGlyphRange: glyphsToDraw
atPoint: [self frame].origin];
[self unlockFocus];
*/
} }
/* We override NSView's setNeedsDisplayInRect: */ /* We override NSView's setNeedsDisplayInRect: */
@ -197,7 +186,7 @@
- (BOOL) shouldDrawInsertionPoint - (BOOL) shouldDrawInsertionPoint
{ {
return tv_shouldDrawInsertionPoint; return [super shouldDrawInsertionPoint];
} }
- (void) drawInsertionPointInRect: (NSRect)aRect - (void) drawInsertionPointInRect: (NSRect)aRect
@ -240,90 +229,90 @@
- (void) setEditable: (BOOL)flag - (void) setEditable: (BOOL)flag
{ {
if (flag) if (flag)
tv_selectable = flag; _tf.is_selectable = flag;
tv_editable = flag; _tf.is_editable = flag;
} }
- (BOOL) isEditable - (BOOL) isEditable
{ {
return tv_editable; return _tf.is_editable;
} }
- (void) setSelectable: (BOOL)flag - (void) setSelectable: (BOOL)flag
{ {
tv_selectable = flag; _tf.is_selectable = flag;
} }
- (BOOL) isSelectable - (BOOL) isSelectable
{ {
return tv_selectable; return _tf.is_selectable;
} }
- (void) setFieldEditor: (BOOL)flag - (void) setFieldEditor: (BOOL)flag
{ {
tv_fieldEditor = flag; _tf.is_field_editor = flag;
} }
- (BOOL) isFieldEditor - (BOOL) isFieldEditor
{ {
return tv_fieldEditor; return _tf.is_field_editor;
} }
- (void) setRichText: (BOOL)flag - (void) setRichText: (BOOL)flag
{ {
if (!flag) if (!flag)
tv_acceptDraggedFiles = flag; _tf.imports_graphics = flag;
tv_richText = flag; _tf.is_rich_text = flag;
} }
- (BOOL) isRichText - (BOOL) isRichText
{ {
return tv_richText; return _tf.is_rich_text;
} }
- (void) setImportsGraphics: (BOOL)flag - (void) setImportsGraphics: (BOOL)flag
{ {
if (flag) if (flag)
tv_richText = flag; _tf.is_rich_text = flag;
tv_acceptDraggedFiles = flag; _tf.imports_graphics = flag;
} }
- (BOOL) importsGraphics - (BOOL) importsGraphics
{ {
return tv_acceptDraggedFiles; return _tf.imports_graphics;
} }
- (void) setUsesFontPanel: (BOOL)flag - (void) setUsesFontPanel: (BOOL)flag
{ {
tv_usesFontPanel = flag; _tf.uses_font_panel = flag;
} }
- (BOOL) usesFontPanel - (BOOL) usesFontPanel
{ {
return tv_usesFontPanel; return _tf.uses_font_panel;
} }
- (void) setUsesRuler: (BOOL)flag - (void) setUsesRuler: (BOOL)flag
{ {
tv_usesRuler = flag; _tf.uses_ruler = flag;
} }
- (BOOL) usesRuler - (BOOL) usesRuler
{ {
return tv_usesRuler; return _tf.uses_ruler;
} }
- (void) setRulerVisible: (BOOL)flag - (void) setRulerVisible: (BOOL)flag
{ {
tv_rulerVisible = flag; _tf.is_ruler_visible = flag;
} }
- (BOOL) isRulerVisible - (BOOL) isRulerVisible
{ {
return tv_rulerVisible; return _tf.is_ruler_visible;
} }
- (void) setSelectedRange: (NSRange)charRange - (void) setSelectedRange: (NSRange)charRange
@ -334,7 +323,7 @@
postNotificationName: NSTextViewDidChangeSelectionNotification postNotificationName: NSTextViewDidChangeSelectionNotification
object: self]; object: self];
*/ */
tv_selectedRange = charRange; _selected_range = charRange;
[self setSelectionGranularity: NSSelectByCharacter]; [self setSelectionGranularity: NSSelectByCharacter];
// Also removes the marking from // Also removes the marking from
@ -343,7 +332,7 @@
- (NSRange) selectedRange - (NSRange) selectedRange
{ {
return tv_selectedRange; return _selected_range;
} }
- (void) setSelectedRange: (NSRange)charRange - (void) setSelectedRange: (NSRange)charRange
@ -352,7 +341,7 @@
{ {
NSDebugLLog(@"NSText", @"setSelectedRange stillSelecting."); NSDebugLLog(@"NSText", @"setSelectedRange stillSelecting.");
tv_selectedRange = charRange; _selected_range = charRange;
[self setSelectionGranularity: NSSelectByCharacter]; [self setSelectionGranularity: NSSelectByCharacter];
// FIXME, more. // FIXME, more.
@ -360,44 +349,44 @@
- (NSSelectionAffinity) selectionAffinity - (NSSelectionAffinity) selectionAffinity
{ {
return tv_selectionAffinity; return _selectionAffinity;
} }
- (void) setSelectionGranularity: (NSSelectionGranularity)granularity - (void) setSelectionGranularity: (NSSelectionGranularity)granularity
{ {
tv_selectionGranularity = granularity; _selectionGranularity = granularity;
} }
- (NSSelectionGranularity) selectionGranularity - (NSSelectionGranularity) selectionGranularity
{ {
return tv_selectionGranularity; return _selectionGranularity;
} }
- (void) setInsertionPointColor: (NSColor*)aColor - (void) setInsertionPointColor: (NSColor*)aColor
{ {
ASSIGN(tv_caretColor, aColor); ASSIGN(_caret_color, aColor);
} }
- (NSColor*) insertionPointColor - (NSColor*) insertionPointColor
{ {
return tv_caretColor; return _caret_color;
} }
- (void) updateInsertionPointStateAndRestartTimer: (BOOL)flag - (void) updateInsertionPointStateAndRestartTimer: (BOOL)flag
{ {
// tv_caretLocation = // _caretLocation =
// restart blinking timer. // restart blinking timer.
} }
- (void) setSelectedTextAttributes: (NSDictionary*)attributes - (void) setSelectedTextAttributes: (NSDictionary*)attributes
{ {
ASSIGN(tv_selectedTextAttributes, attributes); ASSIGN(_selectedTextAttributes, attributes);
} }
- (NSDictionary*) selectedTextAttributes - (NSDictionary*) selectedTextAttributes
{ {
return tv_selectedTextAttributes; return _selectedTextAttributes;
} }
- (NSRange) markedRange - (NSRange) markedRange
@ -409,18 +398,19 @@
- (void) setMarkedTextAttributes: (NSDictionary*)attributes - (void) setMarkedTextAttributes: (NSDictionary*)attributes
{ {
ASSIGN(tv_markedTextAttributes, attributes); ASSIGN(_markedTextAttributes, attributes);
} }
- (NSDictionary*) markedTextAttributes - (NSDictionary*) markedTextAttributes
{ {
return tv_markedTextAttributes; return _markedTextAttributes;
} }
- (NSString*) preferredPasteboardTypeFromArray: (NSArray*)availableTypes - (NSString*) preferredPasteboardTypeFromArray: (NSArray*)availableTypes
restrictedToTypesFromArray: (NSArray*)allowedTypes restrictedToTypesFromArray: (NSArray*)allowedTypes
{ {
// No idea. // No idea.
return nil;
} }
- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard - (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard
@ -457,11 +447,13 @@ of characters (if any) to be replaced by the new data.
- (NSArray*) readablePasteboardTypes - (NSArray*) readablePasteboardTypes
{ {
// get default types, what are they? // get default types, what are they?
return nil;
} }
- (NSArray*) writablePasteboardTypes - (NSArray*) writablePasteboardTypes
{ {
// the selected text can be written to the pasteboard with which types. // the selected text can be written to the pasteboard with which types.
return nil;
} }
- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard - (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard
@ -496,7 +488,7 @@ other than copy/paste or dragging. */
- (void) alignJustified: (id)sender - (void) alignJustified: (id)sender
{ {
/* /*
if (!tv_richText) if (!_tf.is_rich_text)
// if plain all text is jsutified. // if plain all text is jsutified.
else else
// selected range is fully justified. // selected range is fully justified.
@ -529,12 +521,12 @@ alignment. alignment is one of:
{ {
// more? // more?
ASSIGN(tv_typingAttributes, attributes); ASSIGN(_typingAttributes, attributes);
} }
- (NSDictionary*) typingAttributes - (NSDictionary*) typingAttributes
{ {
return tv_typingAttributes; return _typingAttributes;
} }
- (void) useStandardKerning: (id)sender - (void) useStandardKerning: (id)sender
@ -545,7 +537,7 @@ alignment. alignment is one of:
- (void) lowerBaseline: (id)sender - (void) lowerBaseline: (id)sender
{ {
/* /*
if (tv_richText) if (_tf.is_rich_text)
// lower baseline by one point for selected text // lower baseline by one point for selected text
else else
// lower baseline for entire document. // lower baseline for entire document.
@ -555,7 +547,7 @@ alignment. alignment is one of:
- (void) raiseBaseline: (id)sender - (void) raiseBaseline: (id)sender
{ {
/* /*
if (tv_richText) if (_tf.is_rich_text)
// raise baseline by one point for selected text // raise baseline by one point for selected text
else else
// raise baseline for entire document. // raise baseline for entire document.
@ -565,7 +557,7 @@ alignment. alignment is one of:
- (void) turnOffKerning: (id)sender - (void) turnOffKerning: (id)sender
{ {
/* /*
if (tv_richText) if (_tf.is_rich_text)
// turn off kerning in selection. // turn off kerning in selection.
else else
// turn off kerning document wide. // turn off kerning document wide.
@ -575,7 +567,7 @@ alignment. alignment is one of:
- (void) loosenKerning: (id)sender - (void) loosenKerning: (id)sender
{ {
/* /*
if (tv_richText) if (_tf.is_rich_text)
// loosen kerning in selection. // loosen kerning in selection.
else else
// loosen kerning document wide. // loosen kerning document wide.
@ -585,7 +577,7 @@ alignment. alignment is one of:
- (void) tightenKerning: (id)sender - (void) tightenKerning: (id)sender
{ {
/* /*
if (tv_richText) if (_tf.is_rich_text)
// tighten kerning in selection. // tighten kerning in selection.
else else
// tighten kerning document wide. // tighten kerning document wide.
@ -647,6 +639,7 @@ replacing the selection.
- (NSArray*) acceptableDragTypes - (NSArray*) acceptableDragTypes
{ {
return nil;
} }
- (void) updateDragTypeRegistration - (void) updateDragTypeRegistration
@ -675,22 +668,22 @@ replacing the selection.
- (NSRange) rangeForUserCharacterAttributeChange - (NSRange) rangeForUserCharacterAttributeChange
{ {
if (!tv_editable || !tv_usesFontPanel) if (!_tf.is_editable || !_tf.uses_font_panel)
return NSMakeRange(NSNotFound, 0); return NSMakeRange(NSNotFound, 0);
if (tv_richText) if (_tf.is_rich_text)
return tv_selectedRange; return _selected_range;
else else
return NSMakeRange(NSNotFound, 0); // should be entire contents. return NSMakeRange(NSNotFound, 0); // should be entire contents.
} }
- (NSRange) rangeForUserParagraphAttributeChange - (NSRange) rangeForUserParagraphAttributeChange
{ {
if (!tv_editable) if (!_tf.is_editable)
return NSMakeRange(NSNotFound, 0); return NSMakeRange(NSNotFound, 0);
if (tv_richText) if (_tf.is_rich_text)
return [self selectionRangeForProposedRange: tv_selectedRange return [self selectionRangeForProposedRange: _selected_range
granularity: NSSelectByParagraph]; granularity: NSSelectByParagraph];
else else
return NSMakeRange(NSNotFound, 0); // should be entire contents. return NSMakeRange(NSNotFound, 0); // should be entire contents.
@ -698,10 +691,10 @@ replacing the selection.
- (NSRange) rangeForUserTextChange - (NSRange) rangeForUserTextChange
{ {
if (!tv_editable || !tv_usesRuler) if (!_tf.is_editable || !_tf.uses_ruler)
return NSMakeRange(NSNotFound, 0); return NSMakeRange(NSNotFound, 0);
return tv_selectedRange; return _selected_range;
} }
- (BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange - (BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange
@ -733,12 +726,12 @@ the affected range or replacement string before beginning changes, pass
- (void) setSmartInsertDeleteEnabled: (BOOL)flag - (void) setSmartInsertDeleteEnabled: (BOOL)flag
{ {
tv_smartInsertDelete = flag; _tf.smart_insert_delete = flag;
} }
- (BOOL) smartInsertDeleteEnabled - (BOOL) smartInsertDeleteEnabled
{ {
return tv_smartInsertDelete; return _tf.smart_insert_delete;
} }
- (NSRange) smartDeleteRangeForProposedRange: (NSRange)proposedCharRange - (NSRange) smartDeleteRangeForProposedRange: (NSRange)proposedCharRange
@ -820,10 +813,10 @@ read from the pasteboard; otherwise returns nil.
- (int) spellCheckerDocumentTag - (int) spellCheckerDocumentTag
{ {
/* /*
if (!tv_spellTag) if (!_spellCheckerDocumentTag)
tv_spellTag = [[NSSpellingServer sharedServer] uniqueSpellDocumentTag]; _spellCheckerDocumentTag = [[NSSpellingServer sharedServer] uniqueSpellDocumentTag];
*/ */
return tv_spellTag; return _spellCheckerDocumentTag;
} }
- (void) rulerView: (NSRulerView*)aRulerView - (void) rulerView: (NSRulerView*)aRulerView
@ -851,6 +844,11 @@ and notifications, and only invokes this method if permission is granted.
*/ */
} }
- (void)rulerView:(NSRulerView *)ruler
didAddMarker:(NSRulerMarker *)marker
{
}
- (void) rulerView: (NSRulerView*)aRulerView - (void) rulerView: (NSRulerView*)aRulerView
handleMouseDown: (NSEvent*)theEvent handleMouseDown: (NSEvent*)theEvent
{ {
@ -953,15 +951,15 @@ container, returning the modified location. */
attributes: [self typingAttributes]]; attributes: [self typingAttributes]];
AUTORELEASE(aString); AUTORELEASE(aString);
// [textStorage replaceRange: NSMakeRange(0, [string length]) // [_textStorage replaceRange: NSMakeRange(0, [string length])
// withString: aString]; // withString: aString];
[textStorage setAttributedString: aString]; [_textStorage setAttributedString: aString];
//replaceCharactersInRange: NSMakeRange(0, [string length]) //replaceCharactersInRange: NSMakeRange(0, [string length])
// withAttributedString: aString]; // withAttributedString: aString];
// [textStorage insertAttributedString: aString atIndex: 0]; // [_textStorage insertAttributedString: aString atIndex: 0];
} }
- (void) setText: (NSString*)string - (void) setText: (NSString*)string
@ -977,7 +975,7 @@ container, returning the modified location. */
aString = [[NSAttributedString alloc] initWithString: aString aString = [[NSAttributedString alloc] initWithString: aString
attributes: [self typingAttributes]]; attributes: [self typingAttributes]];
[textStorage replaceCharactersInRange: [self selectedRange] [_textStorage replaceCharactersInRange: [self selectedRange]
withAttributedString: (NSAttributedString*)aString]; withAttributedString: (NSAttributedString*)aString];
[self sizeToFit]; // ScrollView interaction [self sizeToFit]; // ScrollView interaction
@ -988,7 +986,7 @@ container, returning the modified location. */
[self display]; [self display];
[_window update]; [_window update];
NSLog(@"%@", [textStorage string]); NSLog(@"%@", [_textStorage string]);
/* /*
* broadcast notification * broadcast notification
*/ */
@ -1005,13 +1003,14 @@ container, returning the modified location. */
- (void) drawRect: (NSRect)aRect - (void) drawRect: (NSRect)aRect
{ {
NSRange glyphRange; NSRange glyphRange;
NSLayoutManager *layoutManager = [self layoutManager];
if (tv_backGroundColor) if (_background_color != nil)
{ {
[tv_backGroundColor set]; [_background_color set];
NSRectFill(aRect); NSRectFill(aRect);
} }
glyphRange = [layoutManager glyphRangeForTextContainer: textContainer]; glyphRange = [layoutManager glyphRangeForTextContainer: _textContainer];
if (glyphRange.length > 0) if (glyphRange.length > 0)
{ {
[layoutManager drawGlyphsForGlyphRange: glyphRange [layoutManager drawGlyphsForGlyphRange: glyphRange
@ -1020,3 +1019,36 @@ container, returning the modified location. */
} }
@end @end
@implementation NSTextView(NSTextInput)
// This are all the NSTextInput methods that are not implemented on NSTextView
// or one of its super classes.
- (void)setMarkedText:(NSString *)aString selectedRange:(NSRange)selRange
{
}
- (BOOL)hasMarkedText
{
return NO;
}
- (void)unmarkText
{
}
- (NSArray*)validAttributesForMarkedText
{
return nil;
}
- (long)conversationIdentifier
{
return 0;
}
- (NSRect)firstRectForCharacterRange:(NSRange)theRange
{
return NSZeroRect;
}
@end