[pyzo] 41/68: add run selection and advance
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Sep 28 09:47:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository pyzo.
commit e15e4220dc33570f3f55ca9e47a24005fb6988f5
Author: Almar Klein <almar.klein at gmail.com>
Date: Fri Sep 16 13:26:12 2016 +0200
add run selection and advance
---
pyzo/core/menu.py | 37 ++++++++++++++++++++++++++-----------
pyzo/resources/defaultConfig.ssdf | 1 +
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/pyzo/core/menu.py b/pyzo/core/menu.py
index 9375527..9906d51 100644
--- a/pyzo/core/menu.py
+++ b/pyzo/core/menu.py
@@ -1292,8 +1292,7 @@ class RunMenu(Menu):
icons.run_lines, self._runSelected)
self.addItem(translate("menu", 'Execute cell ::: Execute the current editors\'s cell in the current shell.'),
icons.run_cell, self._runCell)
- self.addItem(translate("menu", 'Execute cell and advance ::: Execute the current editors\'s cell and advance to the next cell.'),
- icons.run_cell, self._runCellAdvance)
+
#In the _runFile calls, the parameter specifies (asScript, mainFile)
self.addItem(translate("menu", 'Execute file ::: Execute the current file in the current shell.'),
icons.run_file, self._runFile,(False, False))
@@ -1302,6 +1301,13 @@ class RunMenu(Menu):
self.addSeparator()
+ self.addItem(translate("menu", 'Execute selection and advance'),
+ icons.run_lines, self._runSelectedAdvance)
+ self.addItem(translate("menu", 'Execute cell and advance ::: Execute the current editors\'s cell and advance to the next cell.'),
+ icons.run_cell, self._runCellAdvance)
+
+ self.addSeparator()
+
self.addItem(translate("menu", 'Help on running code ::: Open the pyzo wizard at the page about running code.'),
icons.information, self._showHelp)
@@ -1341,7 +1347,22 @@ class RunMenu(Menu):
m.exec_()
# Return
return shell, editor
+
+ def _advance(self):
+ # Get editor and shell
+ shell, editor = self._getShellAndEditor('selection')
+ if not shell or not editor:
+ return
+ cursor = editor.textCursor()
+ runCursor = editor.textCursor()
+ cursor.setPosition(runCursor.position())
+ cursor.movePosition(cursor.NextBlock)
+ editor.setTextCursor(cursor)
+
+ def _runSelectedAdvance(self):
+ self._runSelected()
+ self._advance()
def _runSelected(self):
""" Run the selected whole lines in the current shell.
@@ -1383,9 +1404,10 @@ class RunMenu(Menu):
shell.executeCode(code, fname, lineNumber1)
def _runCellAdvance(self):
- self._runCell(True)
+ self._runCell()
+ self._advance()
- def _runCell(self, advance=False):
+ def _runCell(self):
""" Run the code between two cell separaters ('##').
"""
#TODO: ignore ## in multi-line strings
@@ -1444,13 +1466,6 @@ class RunMenu(Menu):
# Get filename and run code
fname = editor.id() # editor._name or editor._filename
shell.executeCode(code, fname, lineNumber, cellName)
-
- # Advance
- if advance:
- cursor = editor.textCursor()
- cursor.setPosition(runCursor.position())
- cursor.movePosition(cursor.NextBlock)
- editor.setTextCursor(cursor)
def _showWhatToExecute(self, editor, runCursor=None):
diff --git a/pyzo/resources/defaultConfig.ssdf b/pyzo/resources/defaultConfig.ssdf
index 1062746..bb1bdc7 100644
--- a/pyzo/resources/defaultConfig.ssdf
+++ b/pyzo/resources/defaultConfig.ssdf
@@ -102,6 +102,7 @@ shortcuts2 = dict:
run__execute_selection = 'Alt+Return,F9'
run__execute_cell = 'Ctrl+Return,Ctrl+Enter'
run__execute_cell_and_advance = 'Ctrl+Shift+Return,Ctrl+Shift+Enter'
+ run__execute_selection_and_advance = 'Shift+F9,Shift+Alt+Return'
run__execute_file = 'Ctrl+E,F5'
run__execute_main_file = 'Ctrl+M,F6'
shell__clear_screen = 'Ctrl+L,'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyzo.git
More information about the debian-science-commits
mailing list