Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Make highlighting colors in the IPython Console match those used in the Spyder Editor #4813

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions spyder/utils/ipython/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def give_font_style(is_italic):
in_prompt_color = 'lime'
out_prompt_color = 'red'
background_color = color_scheme['background']
selection_background_color = '#ccc'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have to remove this as part of this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just saw you mentioned the reason in your description :-)

error_color = 'red'
in_prompt_number_font_weight = 'bold'
out_prompt_number_font_weight = 'bold'
Expand All @@ -59,7 +58,6 @@ def give_font_style(is_italic):
sheet = """QPlainTextEdit, QTextEdit, ControlWidget {{
color: {} ;
background-color: {};
selection-background-color: {}
}}
.error {{ color: {}; }}
.in-prompt {{ color: {}; }}
Expand All @@ -70,7 +68,6 @@ def give_font_style(is_italic):
"""

sheet_formatted = sheet.format(font_color, background_color,
selection_background_color,
error_color,
in_prompt_color, in_prompt_color,
in_prompt_number_font_weight,
Expand Down
10 changes: 10 additions & 0 deletions spyder/widgets/ipythonconsole/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from spyder.config.gui import config_shortcut
from spyder.py3compat import to_text_string
from spyder.utils import programs
from spyder.utils import syntaxhighlighters as sh
from spyder.utils.ipython.style import create_qss_style, create_style_class
from spyder.widgets.ipythonconsole import (ControlWidget, DebuggingWidget,
HelpWidget, NamepaceBrowserWidget,
Expand Down Expand Up @@ -70,6 +71,9 @@ def __init__(self, ipyclient, additional_options, interpreter_versions,
# To save kernel replies in silent execution
self._kernel_reply = None

color_scheme = kw['config']['JupyterWidget']['syntax_style']
self.set_bracket_matcher_color_scheme(color_scheme)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this two lines could be replaced by something like

self.set_bracket_matcher_color_scheme(self.syntax_style)

What do you guys think @jnsebgosselin @ccordoba12 ?

Also, please add a comment above, something like # To set the color of the matched parentheses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right and this works. I didn't see it because it is not obvious where this is inherited.


#---- Public API ----------------------------------------------------------
def set_exit_callback(self):
"""Set exit callback for this shell."""
Expand Down Expand Up @@ -110,9 +114,15 @@ def get_cwd(self):
return
else:
self.silent_exec_method(code)

def set_bracket_matcher_color_scheme(self, color_scheme):
bsh = sh.BaseSH(parent=self, color_scheme=color_scheme)
mpcolor = bsh.get_matched_p_color()
self._bracket_matcher.format.setBackground(mpcolor)

def set_color_scheme(self, color_scheme):
"""Set color scheme of the shell."""
self.set_bracket_matcher_color_scheme(color_scheme)
self.style_sheet, dark_color = create_qss_style(color_scheme)
self.syntax_style = color_scheme
self._style_sheet_changed()
Expand Down