From 4f467bb3facca62f8a288830f085d4cd6ec0e68a Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Sat, 19 Nov 2022 08:55:33 +0100 Subject: [PATCH 1/2] Add Wrap lines checkbox to source menu by @arteagac --- spyder/plugins/editor/plugin.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py index ef07a264fd4..50d5f8210a1 100644 --- a/spyder/plugins/editor/plugin.py +++ b/spyder/plugins/editor/plugin.py @@ -950,6 +950,9 @@ def get_plugin_actions(self): _("Underline errors and warnings"), 'underline_errors', 'set_underline_errors_enabled') + wrap_lines_action = self._create_checkable_action( + _("Wrap lines"), 'wrap', 'set_wrap_enabled') + self.checkable_actions = { 'blank_spaces': showblanks_action, 'scroll_past_end': scrollpastend_action, @@ -958,7 +961,8 @@ def get_plugin_actions(self): 'show_class_func_dropdown': show_classfunc_dropdown_action, 'pycodestyle': show_codestyle_warnings_action, 'pydocstyle': show_docstring_warnings_action, - 'underline_errors': underline_errors} + 'underline_errors': underline_errors, + 'wrap': wrap_lines_action} fixindentation_action = create_action(self, _("Fix indentation"), tip=_("Replace tab characters by space characters"), @@ -1172,6 +1176,7 @@ def get_plugin_actions(self): show_codestyle_warnings_action, show_docstring_warnings_action, underline_errors, + wrap_lines_action, MENU_SEPARATOR, self.todo_list_action, self.warning_list_action, From 9898772c62f194dbbda7470cf72a4dbc5b4964b3 Mon Sep 17 00:00:00 2001 From: Florian Maurer Date: Sat, 19 Nov 2022 08:57:00 +0100 Subject: [PATCH 2/2] Add Shortcut Alt+Z to wrap lines action --- spyder/config/main.py | 1 + spyder/plugins/editor/plugin.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/spyder/config/main.py b/spyder/config/main.py index 3f2eaa76279..402d8dca99f 100644 --- a/spyder/config/main.py +++ b/spyder/config/main.py @@ -492,6 +492,7 @@ 'editor/close split panel': "Alt+Shift+W", 'editor/docstring': "Ctrl+Alt+D", 'editor/autoformatting': "Ctrl+Alt+I", + 'editor/wrap lines': "Alt+Z", 'editor/show in external file explorer': '', # -- Internal console -- 'console/inspect current object': "Ctrl+I", diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py index 50d5f8210a1..5fb5b2ee9d7 100644 --- a/spyder/plugins/editor/plugin.py +++ b/spyder/plugins/editor/plugin.py @@ -951,7 +951,8 @@ def get_plugin_actions(self): 'underline_errors', 'set_underline_errors_enabled') wrap_lines_action = self._create_checkable_action( - _("Wrap lines"), 'wrap', 'set_wrap_enabled') + _("Wrap lines"), 'wrap', 'set_wrap_enabled', + shortcut=CONF.get_shortcut('editor', 'wrap lines')) self.checkable_actions = { 'blank_spaces': showblanks_action, @@ -1359,7 +1360,12 @@ def set_ancestor(self, ancestor): except RuntimeError: pass - def _create_checkable_action(self, text, conf_name, method=''): + def _create_checkable_action( + self, + text, + conf_name, + method='', + shortcut=None): """Helper function to create a checkable action. Args: @@ -1373,7 +1379,7 @@ def toogle(checked): self.switch_to_plugin() self._toggle_checkable_action(checked, method, conf_name) - action = create_action(self, text, toggled=toogle) + action = create_action(self, text, toggled=toogle, shortcut=shortcut) action.blockSignals(True) if conf_name not in ['pycodestyle', 'pydocstyle']: