Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 298698 - Form Feed (\f) and VT make StyledText go crazy
Summary: Form Feed (\f) and VT make StyledText go crazy
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Scott Kovatch CLA
QA Contact: Felipe Heidrich CLA
URL:
Whiteboard:
Keywords:
: 325052 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-01 06:50 EST by Markus Keller CLA
Modified: 2010-10-21 17:36 EDT (History)
4 users (show)

See Also:


Attachments
partial patch (24.65 KB, patch)
2010-09-17 11:58 EDT, Scott Kovatch CLA
no flags Details | Diff
Fix (6.28 KB, patch)
2010-09-21 18:19 EDT, Scott Kovatch CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-01-01 06:50:54 EST
I20091217-0819 Cocoa

Follow-up to bug 273354, see that bug and attachment in bug 273354 comment 0 for steps to reproduce.

The FF no longer makes the following lines right-aligned, but it makes the lines after the FF move upwards by one when the caret is moved to after the FF. The effect can more easily be seen when you select characters with Shift+Arrow_Right.
Comment 1 Markus Keller CLA 2010-09-13 05:00:00 EDT
*** Bug 325052 has been marked as a duplicate of this bug. ***
Comment 2 Dani Megert CLA 2010-09-13 10:01:38 EDT
*** Bug 325052 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2010-09-13 11:58:13 EDT
*** Bug 325052 has been marked as a duplicate of this bug. ***
Comment 4 Markus Keller CLA 2010-09-14 15:46:07 EDT
This is also visible in java.io.PrintStream#println() from "1.6.0_20-b02-279" (default VM on my system). The bad character is just before that method.
Comment 5 Felipe Heidrich CLA 2010-09-15 09:06:43 EDT
Scott, do you know anything about this problem ?
Comment 6 Scott Kovatch CLA 2010-09-15 13:23:13 EDT
I did some searching on NSFormFeedCharacter and found this post:

http://www.cocoabuilder.com/archive/cocoa/184477-dynamically-sized-text-container.html

which hints that NSLayoutManager (and eventually, NSTypesetter) treats a form feed as a page break. The method actionForControlCharacter was mentioned:

http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTypesetter_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTypesetter/actionForControlCharacterAtIndex:

Can you override the typesetter to return NSTypesetterLineBreakAction when you have a form feed or line feed?
Comment 7 Scott Kovatch CLA 2010-09-17 11:55:06 EDT
(In reply to comment #6)
> http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTypesetter_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTypesetter/actionForControlCharacterAtIndex:
> 
> Can you override the typesetter to return NSTypesetterLineBreakAction when you
> have a form feed or line feed?

I did some work with this yesterday -- I'll attach my work in progress. In TextLayout, if I make an NSATSTypesetter subclass and override actionForControlCharacterAtIndex: to return NSTypesetterZeroAdvancementAction the bug described here goes away, but then the entire view is shifted over to the right about 40 characters. I didn't try applying the same typesetter to all of the places we use NSLayoutManager; that's probably needed too.
Comment 8 Scott Kovatch CLA 2010-09-17 11:58:25 EDT
Created attachment 179130 [details]
partial patch

Patch for TextLayout. OS.java and the bridgesupport files have a lot of other stuff from other work I'm doing.
Comment 9 Scott Kovatch CLA 2010-09-21 18:15:35 EDT
Bizarrely enough, this web page:

http://rosscarter.com/category/cocoa/page/2

and Apple's TextSizingExample gives me a much simpler solution. Typically the max size of a text container should be 1.0e7, but there are some circumstances under which even that is too big, and text will no longer lay out correctly. Setting the text container size to 0.5e7 instead of Float.MAX_VALUE fixes the problem completely, without additional overriding.
Comment 10 Scott Kovatch CLA 2010-09-21 18:19:05 EDT
Created attachment 179348 [details]
Fix

Applied the described change to all places we create an NSTextContainer.
Comment 11 Scott Kovatch CLA 2010-09-21 18:19:32 EDT
Fixed > 20100921.