From: Peter G. <pe...@ar...> - 2002-07-04 03:00:40
|
Tonight's 0.15.3+ development snapshot is up: http://armedbear.org/j.zip (source) http://armedbear.org/j-jar.zip (just j.jar) In response to Feature Request 577186, you can now set things up so that, when your caret is on (or just past) a brace, bracket, or parenthesis, j will highlight the matching brace, bracket, or parenthesis (if possible). To enable this feature, add this line to ~/.j/prefs: highlightMatchingBracket = true And you may need to add a line like this to your theme (or ~/.j/prefs): color.matchingBracketBackground = 255 204 102 I've added a reasonable matching bracket background color to Kodiak and to j's default built-in theme (which are basically one and the same). I didn't do exactly what Mike suggested, and the other editors I looked at are all over the map when it comes to implementing this feature. J's current implementation allows you to specify a single background color which is used for brackets, braces and parentheses. Mike suggested color.braceMatch, color.bracketMatch, and color.parenMatch, which I assume are meant to be foreground rather than background colors. You could do it that way, but I think having a uniform way of highlighting the other end of the current scope (so to speak) presents a more useful visual cue than having different colors for the different characters. (Besides, it's hard enough to come up with one color that fits in a theme, let alone three.) And doing the foreground colors would make the implementation more complicated, so I'd like to see how folks like the background color approach first. If, after a while, there's some sort of consensus that we need to do the foreground colors, so be it. For what it's worth, most other editors use the background color approach; the only notable exception is jEdit, which draws a rectangle around the matching character. The other issue is just how to do the matching. As I've been reviled for doing on other occasions, I'm slavishly emulating xemacs here. (After all, highlighting matching parentheses is REALLY important to Lisp guys.) When the vertical bar caret is before (i.e. to the left of) an opening bracket (for example), j highlights the corresponding closing bracket. When the vertical bar caret is after (to the right of) the closing bracket, j highlights the corresponding opening bracket. The best argument I can find for this somewhat inconsistent approach is that if you're just typing along, when you type ')', for example, the act of typing the ')' will leave the corresponding '(' highlighted, so you can see at a glance what opening parenthesis you've just closed. Both xemacs and nedit take this approach with closing parentheses; nedit, to be consistent, also requires the caret to be after the opening parenthesis before it will highlight its match. jEdit tries to be permissive, which I normally like, but in this case I think being permissive gets confusing when you've got a lot of parentheses close together: if (find(getChar())) or some such. So j is not permissive and tries to work like xemacs. I'm open to your complaints. In the meantime I'm going to change the status of this Feature Request from "Open" to "Pending"; I'll close it when it becomes clear that everything is working correctly. Thanks for your support. -Peter |