[Bluej-discuss] Moe Editor: Indentation & Block Actions
mpp8 at kent.ac.uk
mpp8 at kent.ac.uk
Sun Dec 30 17:07:39 GMT 2007
> On 30 Dec 2007, at 14:54, <mpp8 at kent.ac.uk> wrote:
>
> IndentAction, if I remember correctly, is not used for the
> "Indent
> More" block-action, but for "indent", which is bound to the TAB key.
>
> "indent" does two things: If the current caret position is
> before the
> indent of the line above, it indents to the same level as the
> line
> above. If the indent is already at that level or beyond, it
> indents to
> the next TAB stop.
>
Ah, that does make more sense now I look at it knowing it's bound to the TAB key.
>
> > Secondly, when performing a block action, the code
> specifically
> > selects the entirety of all the lines included in the action.
> The
> > default action would be to keep the selection as it is before,
> which
> > would seem to me to be a more natural way of working - I find
> it
> > annoying when I change the indentation, then go to type
> something in
> > where the caret was before, only to find that that replaces
> the
> > whole line, as it has been entirely selected for no apparent
> reason.
> > Is there a reason for this?
>
> No, not really. Only that block actions, such as "Indent More"
> apply
> to complete lines of every line of which at least a part is
> included
> in the current selection. But I think that could be done
> without
> actually selecting the whole line.
>
>
> > (This second point is the feature that I was looking in the
> code to
> > investigate - I had assumed that it selected all the lines
> involved
> > because it would be too difficult to keep track of where
> the
> > selection had been before, but I've now found out that it has
> been
> > specifically programmed to act like that.) I notice that other
> IDEs/
> > editors also work in a similar ways (I last noticed it in
> either
> > Eclipse or TextWrangler; I can't remember) - is BlueJ made to
> fit
> > with a convention, or is there some other reason?
>
> It was not done to fit the convention. It was just that I
> thought that
> the function applies to the complete line, and to make that
> clear, the
> complete line gets selected. (Block function always apply to
> multiples
> of lines.) But after what you said, I agree that it might be
> better to
> leave the selection as it was.
To leave the selection as it was, just the two following lines need to be removed from the blockAction method in MoeActions.java:
textPane.setCaretPosition(text.getElement(firstLineIndex).getStartOffset());
textPane.moveCaretPosition(text.getElement(lastLineIndex).getEndOffset());
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20071230/62443ac2/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpp8.vcf
Type: text/x-vcard
Size: 171 bytes
Desc: Card for <mpp8 at kent.ac.uk>
Url : http://lists.bluej.org/pipermail/bluej-discuss/attachments/20071230/62443ac2/attachment.vcf
More information about the bluej-discuss
mailing list