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: Add possibility to disable history logging #9858

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
31 changes: 31 additions & 0 deletions spyder/plugins/ipythonconsole/widgets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def __init__(self, plugin, id_,
self.options_button = options_button
self.stop_button = None
self.reset_button = None
self.enable_history_button = None
self.stop_icon = ima.icon('stop')
self.history_icon = ima.icon('history')
self.history_disabled_icon = ima.icon('history_disabled')
self.history = []
self.allow_rename = True
self.stderr_dir = None
Expand Down Expand Up @@ -403,6 +406,21 @@ def get_toolbar_buttons(self):
"""Return toolbar buttons list."""
buttons = []

# Code to add the history enable/disable button
if self.enable_history_button is None:
self.enable_history_button = create_toolbutton(
self,
text=_("Enable/disable history"),
icon=self.history_icon,
tip="",
toggled=self.history_button_toggle_handler)
self.enable_history_button.setChecked(True)
if is_dark_interface():
self.enable_history_button.setStyleSheet(
"QToolButton{padding: 3px;}")
if self.enable_history_button is not None:
buttons.append(self.enable_history_button)

# Code to add the stop button
if self.stop_button is None:
self.stop_button = create_toolbutton(
Expand Down Expand Up @@ -600,6 +618,19 @@ def reset_namespace(self):
self.shellwidget.reset_namespace(warning=self.reset_warning,
message=True)

@Slot(bool)
def history_button_toggle_handler(self, checked):
"""Handle history logging button toggles."""
self.history_enabled = checked
if checked:
self.enable_history_button.setToolTip(
_("History logging enabled"))
self.enable_history_button.setIcon(self.history_icon)
else:
self.enable_history_button.setToolTip(
_("History logging disabled"))
self.enable_history_button.setIcon(self.history_disabled_icon)

def update_history(self):
self.history = self.shellwidget._history

Expand Down
1 change: 1 addition & 0 deletions spyder/utils/icon_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
'pythonpath': [('spyder.python-logo-up', 'spyder.python-logo-down'), {'options': [{'color': '#3775a9'}, {'color': '#ffd444'}]}],
'findf': [('fa.file-o', 'fa.search'), {'options': [{'scale_factor': 1.0, 'color': MAIN_FG_COLOR}, {'scale_factor': 0.6, 'color': MAIN_FG_COLOR}]}],
'history': [('fa.history',), {'color': MAIN_FG_COLOR}],
'history_disabled': [('fa.history',), {'color': 'gray'}],
'help': [('fa.question-circle',), {'color': MAIN_FG_COLOR}],
'lock': [('fa.lock',), {'color': MAIN_FG_COLOR}],
'lock_open': [('fa.unlock-alt',), {'color': MAIN_FG_COLOR}],
Expand Down
5 changes: 5 additions & 0 deletions spyder/widgets/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,8 @@ class SaveHistoryMixin(object):

append_to_history = None

history_enabled = True

def __init__(self, history_filename=''):
self.history_filename = history_filename
self.create_history_filename()
Expand All @@ -1298,6 +1300,9 @@ def create_history_filename(self):

def add_to_history(self, command):
"""Add command to history"""
if not self.history_enabled:
return

command = to_text_string(command)
if command in ['', '\n'] or command.startswith('Traceback'):
return
Expand Down