Skip to content

Commit

Permalink
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
@@ -389,6 +389,8 @@
'editor/go to line': 'Ctrl+L',
'editor/go to previous file': 'Ctrl+Shift+Tab',
'editor/go to next file': 'Ctrl+Tab',
'editor/cycle to previous file': 'Ctrl+PgUp',
'editor/cycle to next file': 'Ctrl+PgDown',
'editor/new file': "Ctrl+N",
'editor/open last closed':"Ctrl+Shift+T",
'editor/open file': "Ctrl+O",
7 changes: 3 additions & 4 deletions spyder/plugins/shortcuts.py
Original file line number Diff line number Diff line change
@@ -447,10 +447,9 @@ def validate_sequence(self):
self.key_text = [k.upper() for k in self.key_text]

# Fix Backtab, Tab issue
if os.name == 'nt':
if Qt.Key_Backtab in self.key_non_modifiers:
idx = self.key_non_modifiers.index(Qt.Key_Backtab)
self.key_non_modifiers[idx] = Qt.Key_Tab
if Qt.Key_Backtab in self.key_non_modifiers:
idx = self.key_non_modifiers.index(Qt.Key_Backtab)
self.key_non_modifiers[idx] = Qt.Key_Tab

if len(self.key_modifiers) == 0:
# Filter single key allowed
8 changes: 7 additions & 1 deletion spyder/widgets/editor.py
Original file line number Diff line number Diff line change
@@ -641,6 +641,12 @@ def create_shortcuts(self):
name='Go to previous file', parent=self)
tabshift = config_shortcut(self.tab_navigation_mru, context='Editor',
name='Go to next file', parent=self)
prevtab = config_shortcut(lambda: self.tabs.tab_navigate(-1),
context='Editor',
name='Cycle to previous file', parent=self)
nexttab = config_shortcut(lambda: self.tabs.tab_navigate(1),
context='Editor',
name='Cycle to next file', parent=self)
run_selection = config_shortcut(self.run_selection, context='Editor',
name='Run selection', parent=self)
new_file = config_shortcut(lambda : self.sig_new_file[()].emit(),
@@ -743,7 +749,7 @@ def create_shortcuts(self):
close_file_1, close_file_2, run_cell, run_cell_and_advance,
go_to_next_cell, go_to_previous_cell, re_run_last_cell,
prev_warning, next_warning, split_vertically,
split_horizontally, close_split]
split_horizontally, close_split, prevtab, nexttab]

def get_shortcut_data(self):
"""
20 changes: 10 additions & 10 deletions spyder/widgets/tabs.py
Original file line number Diff line number Diff line change
@@ -385,6 +385,16 @@ def keyPressEvent(self, event):
handled = True
if not handled:
QTabWidget.keyPressEvent(self, event)

def tab_navigate(self, delta=1):
"""Ctrl+Tab"""
if delta > 0 and self.currentIndex() == self.count()-1:
index = delta-1
elif delta < 0 and self.currentIndex() == 0:
index = self.count()+delta
else:
index = self.currentIndex()+delta
self.setCurrentIndex(index)

def set_close_function(self, func):
"""Setting Tabs close function
@@ -435,16 +445,6 @@ def __init__(self, parent, actions=None, menu=None,
config_shortcut(lambda: self.sig_close_tab.emit(self.currentIndex()),
context='editor', name='close file 2', parent=parent)

def tab_navigate(self, delta=1):
"""Ctrl+Tab"""
if delta > 0 and self.currentIndex() == self.count()-1:
index = delta-1
elif delta < 0 and self.currentIndex() == 0:
index = self.count()+delta
else:
index = self.currentIndex()+delta
self.setCurrentIndex(index)

@Slot(int, int)
def move_tab(self, index_from, index_to):
"""Move tab inside a tabwidget"""

0 comments on commit c926054

Please sign in to comment.