diff --git a/AppKit/CPTextView/CPTextContainer.j b/AppKit/CPTextView/CPTextContainer.j index 962d71e79..6b450a37a 100755 --- a/AppKit/CPTextView/CPTextContainer.j +++ b/AppKit/CPTextView/CPTextContainer.j @@ -112,15 +112,38 @@ CPLineMovesUp = 4; _size = someSize; if (oldSize.width != _size.width) - [_layoutManager invalidateLayoutForCharacterRange:CPMakeRange(0,[[_layoutManager textStorage] length]) + { [_layoutManager invalidateLayoutForCharacterRange:CPMakeRange(0,[[_layoutManager textStorage] length]) isSoft:NO actualCharacterRange:NULL]; - + [_layoutManager _validateLayoutAndGlyphs]; + } } +// Controls whether the receiver adjusts the width of its bounding rectangle when its text view is resized. - (void)setWidthTracksTextView:(BOOL)flag { - // fixme: Controls whether the receiver adjusts the width of its bounding rectangle when its text view is resized. + [_textView setPostsFrameChangedNotifications:flag]; + + if (flag) + { + [[CPNotificationCenter defaultCenter] addObserver:self + selector:@selector(textViewFrameChanged:) + name:CPViewFrameDidChangeNotification + object:_textView]; + } + else + { + [[CPNotificationCenter defaultCenter] removeObserver:self + name:CPViewFrameDidChangeNotification + object:_textView]; + } +} + +- (void) textViewFrameChanged:(CPNotification)aNotification +{ + var newSize=CPMakeSize([_textView frame].size.width, _size.height); +debugger + [self setContainerSize:newSize]; } - (void)setTextView:(CPTextView)aTextView diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index f4f770c57..506d7ca43 100755 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -361,7 +361,9 @@ var _sharedSimpleTypesetter = nil; lineOrigin.y += [_currentParagraph lineSpacing]; if (lineOrigin.y > [_currentTextContainer containerSize].height) { - _currentTextContainer = [[_layoutManager textContainers] objectAtIndex: ++_indexOfCurrentContainer]; + _indexOfCurrentContainer++; + _indexOfCurrentContainer=MAX(_indexOfCurrentContainer, [[_layoutManager textContainers] count]-1); + _currentTextContainer = [[_layoutManager textContainers] objectAtIndex: _indexOfCurrentContainer]; } lineOrigin.x = 0; numLines++;