jupyter / qtconsole

Jupyter Qt Console
https://qtconsole.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
418 stars 200 forks source link

Make bracket match highlight style configurable #80

Open airdrik opened 8 years ago

airdrik commented 8 years ago

Currently the style used when highlighting matching brackets is hard-coded to apply a silver background. This style is problematic for light-on-dark color schemes where the cursor and/or bracket colors are close to the silver background that gets applied as they will appear to blend into the highlighting making it hard to tell where the cursor is or what kind of bracket is being matched.

My preference would be to set the style in the pygments style settings so that colors/styles can be chosen which best match the current pygments style. I understand if this is not feasible, in which case setting the style in the jupyter_qtconsole_config.py file would be fine.

roachsinai commented 4 years ago

Any updates?

ccordoba12 commented 4 years ago

@dalthviz, is this still an issue?

dalthviz commented 4 years ago

@ccordoba12 probably not but I'm unsure, will need to check

char101 commented 1 year ago

Other than configurable, I think the bracket matcher could detect the theme color (dark or light) and select appropriate color.

Currently for a d.i.y approach:

Replace silver in https://github.com/jupyter/qtconsole/blob/master/qtconsole/bracket_matcher.py#L30 to #666666.

dalthviz commented 1 year ago

I think that's a good idea :+1: Checking, most probably a call to self._bracket_matcher should be done at https://github.com/jupyter/qtconsole/blob/fa1a7f898e7d402ac9bb64a652db5dc509e1f649/qtconsole/jupyter_widget.py#L595 to a new method of the BracketMatcher class that changes the color of the bracket format (using the self.format.setBackground method) depending on the syntax_style.

The new method could do a validation similar to what is being done when calling self._ansi_processor.set_background_color(self.syntax_style): https://github.com/jupyter/qtconsole/blob/022c8455e15deff1ac33d187b0d78f08abe316da/qtconsole/ansi_code_processor.py#L374

Where the utility function dark_style is used to check if the style is dark or not: https://github.com/jupyter/qtconsole/blob/022c8455e15deff1ac33d187b0d78f08abe316da/qtconsole/styles.py#L84