Skip to content

Commit

Permalink
shortcuts frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbautista committed Sep 29, 2024
1 parent 6410fdc commit 6f70a04
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions qtconsole/frontend_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
from qtconsole.base_frontend_mixin import BaseFrontendMixin
from traitlets import Any, Bool, Instance, Unicode, DottedObjectName, default
from traitlets.config.configurable import LoggingConfigurable
from traitlets import Enum, Integer
from traitlets import HasTraits, observe
from traitlets import Enum, Integer, observe
from .bracket_matcher import BracketMatcher
from .call_tip_widget import CallTipWidget
from .history_console_widget import HistoryConsoleWidget
from .pygments_highlighter import PygmentsHighlighter
from .util import import_item, shortcut_manager
from .util import import_item


class FrontendHighlighter(PygmentsHighlighter):
Expand Down Expand Up @@ -145,6 +144,8 @@ def _lexer_default(self):
lexer_class = import_item(self.lexer_class)
return lexer_class()

shortcut_copy_raw = Unicode('Ctrl+Shift+C').tag(config=True)

# Emitted when a user visible 'execute_request' has been submitted to the
# kernel from the FrontendWidget. Contains the code to be executed.
executing = QtCore.Signal(object)
Expand Down Expand Up @@ -193,13 +194,12 @@ def __init__(self, local_kernel=_local_kernel, *args, **kw):
# Configure actions.
action = self._copy_raw_action
action.setEnabled(False)
action.setShortcut(shortcut_manager.shortcut_copy_raw)
action.setShortcut(self.shortcut_copy_raw)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
action.triggered.connect(self.copy_raw)
self.copy_available.connect(action.setEnabled)
self.addAction(action)
self.copy_raw_action = action
shortcut_manager.observe(self.update_shortcuts, names=['shortcut_copy_raw'])

# Connect signal handlers.
document = self._control.document()
Expand All @@ -215,6 +215,7 @@ def __init__(self, local_kernel=_local_kernel, *args, **kw):
# 'ConsoleWidget' public interface
#---------------------------------------------------------------------------

@observe('shortcut_copy_raw')
def update_shortcuts(self, change):
if change['name'] == 'shortcut_copy_raw':
self.copy_raw_action.setShortcut(change['new'])
Expand Down

0 comments on commit 6f70a04

Please sign in to comment.