Skip to content

Commit

Permalink
Merge pull request #6256 from csabella/issue6235
Browse files Browse the repository at this point in the history
PR: Preserve color scheme on kernel restart
  • Loading branch information
ccordoba12 authored Jan 27, 2018
2 parents 09a9431 + 416455a commit 27fbfff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 8 additions & 8 deletions spyder/widgets/ipythonconsole/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ def configure_shellwidget(self, give_focus=True):
self.shellwidget.executed.connect(self.shellwidget.get_cwd)

# To apply style
if not create_qss_style(self.shellwidget.syntax_style)[1]:
self.shellwidget.silent_execute("%colors linux")
else:
self.shellwidget.silent_execute("%colors lightbg")
self.set_color_scheme(self.shellwidget.syntax_style, reset=False)

# To hide the loading page
self.shellwidget.sig_prompt_ready.connect(self._hide_loading_page)
Expand Down Expand Up @@ -432,9 +429,9 @@ def set_infowidget_font(self):
font = get_font(option='rich_font')
self.infowidget.set_font(font)

def set_color_scheme(self, color_scheme):
def set_color_scheme(self, color_scheme, reset=True):
"""Set IPython color scheme."""
self.shellwidget.set_color_scheme(color_scheme)
self.shellwidget.set_color_scheme(color_scheme, reset)

def shutdown(self):
"""Shutdown kernel"""
Expand All @@ -455,7 +452,7 @@ def interrupt_kernel(self):
@Slot()
def restart_kernel(self):
"""
Restart the associanted kernel
Restart the associated kernel.
Took this code from the qtconsole project
Licensed under the BSD license
Expand All @@ -480,7 +477,10 @@ def restart_kernel(self):
before_prompt=True
)
else:
sw.reset(clear=True)
# For issue 6235. IPython was changing the setting of
# %colors on windows by assuming it was using a dark
# background. This corrects it based on the scheme.
self.set_color_scheme(sw.syntax_style)
sw._append_html(_("<br>Restarting kernel...\n<hr><br>"),
before_prompt=False)
else:
Expand Down
5 changes: 3 additions & 2 deletions spyder/widgets/ipythonconsole/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ def set_bracket_matcher_color_scheme(self, color_scheme):
mpcolor = bsh.get_matched_p_color()
self._bracket_matcher.format.setBackground(mpcolor)

def set_color_scheme(self, color_scheme):
def set_color_scheme(self, color_scheme, reset=True):
"""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()
self._syntax_style_changed()
self.reset(clear=True)
if reset:
self.reset(clear=True)
if not dark_color:
self.silent_execute("%colors linux")
else:
Expand Down

0 comments on commit 27fbfff

Please sign in to comment.