Community
Participate
Working Groups
In the example below, the contents of a StyledText control with SWT.WRAP style are not wrapped correctly. The visible problems are (resize shell as needed to reproduce): - Glyphs disappearing partially or fully behind the right border - Words being broken apart at non-7-bit letters - Lines starting with a space In 3.0M7 and earlier versions, the behaviour was as expected. In 3.0M8 and later, it's broken. I did not find any other bug addressing this. Bug 49567 does not look like the same issue to me. --- import org.eclipse.swt.*; import org.eclipse.swt.custom.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class StyledTextWrapTest { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Font font = new Font(display, "Tahoma", 14, SWT.NORMAL); StyledText text = new StyledText(shell, SWT.MULTI | SWT.WRAP); text.setFont(font); text.setText("This is an exãmple têxt. It shoüld wráp corrèctlý."); text.setLayoutData(new GridData(GridData.FILL_BOTH)); shell.setSize(200, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } font.dispose(); display.dispose(); } }
Created attachment 9506 [details] Incorrect wrapping (screenshot)
Moving to FH. Note that running with the latest swt on win2000 I can only make the lines-starting-with-space problem happen when resizing the shell, I don't see the other two listed problems.
We changed StyledText to use platform support to wrap lines (Uniscribe). For some reason uniscribe mark letters with accent (ã,ê,ü, etc) as soft breaks causing lines to wrap at these letters. I can see the same problem happening with Notepad. I believe the accents are causing all this trouble, I will check how we can avoid it.
Created attachment 9539 [details] Another screenshot Please also note that even if the string does not contain any accents, it can still happen that both punctuation characters and the caret are clipped at the right edge of the StyledText bounds (see attachment). BTW, my copy of Notepad does not seem to have any problem with this.
This I can fix more easily (problem shown the second screenshot). The problem with the accents is going te be hard cause the OS returns bogus informatation.
Created attachment 9625 [details] Examples of incorrect wrapping without any accents (screenshot)
Fixed > 20040419 in HEAD. I've fixed all the problems you mentioned except the case: "Iterator and Observer are behavio(u)ral patterns." I think it is okay to break line at symbol "(" or ")", (I tested with other editor). Please, verify this fix using this week integration build (it will be build tomorrow) and reopen this problem reported if necessary.
I have just tried I20040420. It works better now but there are still a few problems. - The width of the caret does not seem to be taken into account when wrapping lines. If the caret is positioned at the end of a line and there is just enough room for the text on that line but not for the caret, the caret will be clipped. The word at the end of the line should be moved to the next line instead (this worked right in 3.0M7). - The new algorithm still causes too many incorrect line breaks to occur. For example, there should be no line breaks in the following places: (| indicates wrong point to break a line) This is a sentence|. I've downloaded this from eclipse|.|org. I repeat|: this will not work. "|Don't break apart quotes and the text enclosed by them|" (|Don't break apart brackets and the text enclosed by them|) Only 60|% of the work has been completed. These are just a few cases that I've tested, there are probably more, I cannot give you a complete list, sorry. I can confirm that all of the above examples are handled correctly in the previous version of StyledText (3.0M7), SWT's native Text control, Notepad, Wordpad and OpenOffice. The old algorithm previously used by StyledText seemed to work right most of the time, at least for natural text written in Western languages, so my suggestion would be to use that as a reference.
I've fixed (>20040422 in HEAD) all the cases: This is a sentence|. I've downloaded this from eclipse|.|org. I repeat|: this will not work. "|Don't break apart quotes and the text enclosed by them|" (|Don't break apart brackets and the text enclosed by them|) Only 60|% of the work has been completed. I still have to fix caret positioning before closing this pr.
Created attachment 11545 [details] Disappearing caret Screenshot illustrating the case left to be fixed
I'm closing this report since the original text-wrapping issues have all been fixed. For the remaining problem (the caret being clipped), a separate and more detailed report has been opened (bug 87774).