Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367859 - The conversion from tabulator to whitespace is inconsistent
Summary: The conversion from tabulator to whitespace is inconsistent
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-04 10:28 EST by Andreas Muelder CLA
Modified: 2019-09-14 12:11 EDT (History)
1 user (show)

See Also:


Attachments
Tabs on windows 7 (24.32 KB, image/png)
2012-01-04 10:29 EST, Andreas Muelder CLA
no flags Details
Tabs on Ubuntu (7.81 KB, image/png)
2012-01-04 10:30 EST, Andreas Muelder CLA
no flags Details
Tabs on Mac OSX Lion (30.09 KB, image/png)
2012-01-04 11:37 EST, Alexander Nyßen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Muelder CLA 2012-01-04 10:28:40 EST
Build Identifier: 20110916-0149

The conversion from tabs (\t) to whitespace is different for Text widget, StyledText widget and GC. 
The behaviour changes for different operating systems.





Reproducible: Always

Steps to Reproduce:
public class SWTTabBug {
	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, true));

		FontData fd = shell.getFont().getFontData()[0];
		final Font font = new Font(display, fd.getName(), 60, SWT.BOLD
				| SWT.ITALIC);
		final Image image = new Image(display, 640, 480);
		final Rectangle rect = image.getBounds();
		GC gc = new GC(image);
		gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
		gc.fillOval(rect.x, rect.y, rect.width, rect.height);
		gc.dispose();

		shell.addListener(SWT.Paint, new Listener() {
			public void handleEvent(Event event) {
				GC gc = event.gc;
				gc.drawText("Start\tEnd", 0, 50);
			}
		});

		StyledText styledText = new StyledText(shell, SWT.NONE);
		styledText.setText("Start\tEnd");
		GridData data = new GridData();
		data.grabExcessHorizontalSpace = true;
		data.horizontalAlignment = GridData.FILL;
		styledText.setLayoutData(data);
		Text text = new Text(shell, SWT.NONE);
		text.setText("Start\tTab");
		data = new GridData();
		data.grabExcessHorizontalSpace = true;
		data.horizontalAlignment = GridData.FILL;
		text.setLayoutData(data);
		shell.setSize(shell.computeSize(rect.width / 2, rect.height / 2));
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		image.dispose();
		font.dispose();
		display.dispose();
	}
}
Comment 1 Andreas Muelder CLA 2012-01-04 10:29:21 EST
Created attachment 209013 [details]
Tabs on windows 7
Comment 2 Andreas Muelder CLA 2012-01-04 10:30:39 EST
Created attachment 209014 [details]
Tabs on Ubuntu
Comment 3 Alexander Nyßen CLA 2012-01-04 11:37:58 EST
Created attachment 209024 [details]
Tabs on Mac OSX Lion

The following sreenshot shows how the snippet behaves on MacOSX.
Comment 4 Eclipse Genie CLA 2019-09-14 12:11:48 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.