Community
Participate
Working Groups
I first noticed this problem in a 3rd party plugin editor (Oxygen). However it turns out to be a user interface problem in Eclipse's Java editor, its plain text editor, its Ant editor, and indeed every editor that uses the standard text pane. here it is: It is extremely difficult to click the mouse in the proper position to place the cursor before the first character on a line. This is not so noticeable in the Java editor because usually every line begins with one or two characters at least of white space, and consequently you rarely want to put the cursor there. However, it's very noticeable when editing non-indented plain text or XML or HTML. If you look at third party text editors such as BBEdit or even Microsoft Word you'll notice they have roughly an em's worth of white space in the left margin of the window where the text doesn't appear but where you can click the mouse to position the cursor at the beginning of the line. I didn;t realize how important this was until in Eclipse I didn't have it. I kept setting breakpoints or folding blocks, or doing whatever action was done by clicking in the left bar instead. I've only tested this on the Mac and Eclipse 3.1.2 but I suspect it's a cross-platform issue and probably occurs in 3.2 as well.
Need to determine whether the problem is in StyledText or Text.
This is not a Mac issue. Multiline StyledText has no left and write margins on all platforms.
the left and right margin have always been zero, the only case it is not zero is when bidi=true (because of the bidi caret). Anyhow, to place the caret in the begging of the line you just need to click in the left half of the first charcters of the that line. If I change this people will complain so I'll mark as duplicate of Bug 56342. *** This bug has been marked as a duplicate of 56342 ***
Clicking in the left of the first character is simply too difficult. Try clicking in the left half of an "i" sometime. This is why good text editors provide extra clickable margin by default. Possibly the component should not set a default margin. I'm not sure. However the specific instance of the styled text component used for Eclipse's java, plain text, and other editors absolutely should set a reasonable left margin by default. Thus this bug may depend on 56342, but I don't think it's the same thing. That bug says it should be possible to set a margin on a styled text component. This bug says that once 56342 is fixed, we should indeed set a left margin in the StyledText used for the Java and other editors.
StyledText offers the support you need. Now it is up to Text Editors in Eclipse to allow the user to specify margins around the editor.
Note that StyledText already has a 2px margin on the left in bidi mode (when an RTL keyboard language is installed). I would just always do 'styledText.setLeftMargin(2);' in AbstractTextEditor#createPartControl(..), which is a no-op for bidi systems but a great aid for others.
I've been running my target with the following version of TextViewer#createTextWidget(..) for about a month now (mostly without the bidi caret), and I think we should just go ahead and release this now: protected StyledText createTextWidget(Composite parent, int styles) { StyledText styledText= new StyledText(parent, styles); styledText.setLeftMargin(Math.max(styledText.getLeftMargin(), 2)); return styledText; }
Agree with comment 7. Fixed in HEAD. Available in builds > N20091101-2000.