Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Add matching bracket highlighting in the editor#271

Open
mhavard999 wants to merge 2 commits into4clojure:developfrom
mhavard999:develop
Open

Add matching bracket highlighting in the editor#271
mhavard999 wants to merge 2 commits into4clojure:developfrom
mhavard999:develop

Conversation

@mhavard999
Copy link

As discussed in #270, this adds matching bracket highlighting functionality to the editor. When the cursor is next to a parenthesis, square bracket or curly bracket, it bolds the character and its corresponding closing/opening character and highlights them with a light gray color if there is a match. If there is no match, the character gets a light red color.

This was very simple as Code Mirror has an add-on for bracket matching, so it was just a matter of dropping the js file in and adding a few one-liners here and there. The new js file is not minified, but let me know if it needs to be.

The reason I modified the colors in codemirror.css is that by default it turns the matching parens a light green color that is barely visible in every theme.

@amalloy
Copy link
Member

amalloy commented Mar 18, 2015

Where did this matchbrackets.js come from? I can't seem to find it online.

@amalloy
Copy link
Member

amalloy commented Mar 18, 2015

Provided the provenance of matchbrackets.js is okay, I'd also like the highlight re-styled: as they are now, I can't see the cursor anymore when a bracket is highlighted, so I can't tell whether i'm before it or after it, or even which of the two matching brackets the cursor is on. Perhaps something more like Eclipse does, a thin red outline around only one of the brackets (the one your cursor isn't currently on)?

@mhavard999
Copy link
Author

matchbrackets.js is available at the link at the top of this page on code mirror: http://codemirror.net/doc/manual.html#addon_matchbrackets

or here's the direct link: http://codemirror.net/addon/edit/matchbrackets.js

I'll get that style change in there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants