From 42b0b2ef67b1c3f8a6d2e4da59557d61f21ed40d Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Wed, 6 Feb 2002 01:39:11 +0000 Subject: [PATCH] Fixed bug when typing enter at the end of text; fixed drawing insertion point when there is no text git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12414 72102866-910b-0410-8b05-ffd578937521 --- Source/GSSimpleLayoutManager.m | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Source/GSSimpleLayoutManager.m b/Source/GSSimpleLayoutManager.m index cc92da340..145de64ca 100644 --- a/Source/GSSimpleLayoutManager.m +++ b/Source/GSSimpleLayoutManager.m @@ -916,7 +916,7 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet) addObject: [_GNULineLayoutInfo lineLayoutWithRange: NSMakeRange (0, 0) rect: NSMakeRect (0, 0, width, 12) - usedRect: NSMakeRect (0, 0, 0, 12)]]; + usedRect: NSMakeRect (0, 0, 1, 12)]]; return NSMakeRange(0,1); } @@ -942,9 +942,10 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet) options: NSLiteralSearch range: para]; - if (eol.length == 0) + if (eol.location == NSNotFound) { eol.location = length; + eol.length = 0; } else { @@ -1066,8 +1067,8 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet) } // line to long - if (usedLineRect.size.width + advanceSize.width > width || - isBuckled) + if (usedLineRect.size.width + advanceSize.width > width + || isBuckled) { // end of line -> word wrap // undo layout of last word @@ -1158,6 +1159,24 @@ scanRange(NSScanner *scanner, NSCharacterSet* aSet) } while ([lScanner isAtEnd] == NO); } + + /* Now test for the special case - there is a newline at the end of + the text? The last newline is not displayed by the previous + engine, so we do it manually. */ + if ([newlines characterIsMember: [allText characterAtIndex: (length - 1)]]) + { + float width = [aTextContainer containerSize].width; + + [_lineLayoutInformation + addObject: [_GNULineLayoutInfo + lineLayoutWithRange: NSMakeRange (length, 0) + rect: NSMakeRect (drawingPoint.x, drawingPoint.y, + width, 12) + usedRect: NSMakeRect (drawingPoint.x, drawingPoint.y, + 1, 12)]]; + } + + // lines actually updated (optimized drawing) return NSMakeRange(aLine, MAX(1, [_lineLayoutInformation count] - aLine));