Skip to content

Commit

Permalink
Merge pull request #3878 from andfoy/symbolfindershort
Browse files Browse the repository at this point in the history
PR: Add function/class search shortcut, menu and toolbar entries
  • Loading branch information
ccordoba12 authored Jan 10, 2017
2 parents 1168aa7 + dc5e91f commit 138bd23
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
4 changes: 2 additions & 2 deletions spyder/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
'_/quit': "Ctrl+Q",
# -- In plugins/editor
'_/file switcher': 'Ctrl+P',
'_/symbol finder': 'Ctrl+Alt+P',
'_/debug': "Ctrl+F5",
'_/debug step over': "Ctrl+F10",
'_/debug continue': "Ctrl+F12",
Expand Down Expand Up @@ -425,7 +426,6 @@
'editor/run cell and advance': RUN_CELL_AND_ADVANCE_SHORTCUT,
# -- In plugins/editor.py
'editor/show/hide outline': "Ctrl+Alt+O",
'editor/show/hide project explorer': "Ctrl+Alt+P",
# -- In Breakpoints
'_/switch to breakpoints': "Ctrl+Shift+B",
# ---- Consoles (in widgets/shell) ----
Expand Down Expand Up @@ -656,7 +656,7 @@
# or if you want to *rename* options, then you need to do a MAJOR update in
# version, e.g. from 3.0.0 to 4.0.0
# 3. You don't need to touch this value if you're just adding a new option
CONF_VERSION = '31.0.0'
CONF_VERSION = '32.0.0'

# Main configuration instance
try:
Expand Down
40 changes: 27 additions & 13 deletions spyder/plugins/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,25 +614,24 @@ def get_plugin_actions(self):
context=Qt.WidgetWithChildrenShortcut)
self.register_shortcut(self.toggle_outline_action, context="Editor",
name="Show/hide outline")
self.toggle_project_action = create_action(self,
_("Show/hide project explorer"),
triggered=self.show_hide_projects,
context=Qt.WidgetWithChildrenShortcut)
self.register_shortcut(self.toggle_project_action, context="Editor",
name="Show/hide project explorer")
self.addActions([self.toggle_outline_action, self.toggle_project_action])

self.addActions([self.toggle_outline_action])
# ---- File menu and toolbar ----
self.new_action = create_action(self, _("&New file..."),
self.new_action = create_action(
self,
_("&New file..."),
icon=ima.icon('filenew'), tip=_("New file"),
triggered=self.new,
context=Qt.WidgetShortcut)
context=Qt.WidgetShortcut
)
self.register_shortcut(self.new_action, context="Editor",
name="New file", add_sc_to_tip=True)

self.open_last_closed_action = create_action(self, _("O&pen last closed"),
self.open_last_closed_action = create_action(
self,
_("O&pen last closed"),
tip=_("Open last closed"),
triggered=self.open_last_closed)
triggered=self.open_last_closed
)
self.register_shortcut(self.open_last_closed_action, context="Editor",
name="Open last closed")

Expand All @@ -651,6 +650,14 @@ def get_plugin_actions(self):
self.register_shortcut(self.file_switcher_action, context="_",
name="File switcher", add_sc_to_tip=True)

self.symbol_finder_action = create_action(self, _('Symbol finder...'),
icon=ima.icon('symbol_find'),
tip=_('Fast symbol search in file'),
triggered=self.call_symbol_finder,
context=Qt.ApplicationShortcut)
self.register_shortcut(self.symbol_finder_action, context="_",
name="symbol finder", add_sc_to_tip=True)

self.revert_action = create_action(self, _("&Revert"),
icon=ima.icon('revert'), tip=_("Revert file from disk"),
triggered=self.revert)
Expand Down Expand Up @@ -995,6 +1002,7 @@ def get_plugin_actions(self):
self.save_all_action,
save_as_action,
self.file_switcher_action,
self.symbol_finder_action,
self.revert_action,
MENU_SEPARATOR,
print_preview_action,
Expand All @@ -1007,7 +1015,8 @@ def get_plugin_actions(self):
self.main.file_menu_actions += file_menu_actions
file_toolbar_actions = [self.new_action, self.open_action,
self.save_action, self.save_all_action,
self.file_switcher_action]
self.file_switcher_action,
self.symbol_finder_action]
self.main.file_toolbar_actions += file_toolbar_actions

# ---- Find menu/toolbar construction ----
Expand Down Expand Up @@ -1725,6 +1734,11 @@ def call_file_switcher(self):
if self.editorstacks:
self.get_current_editorstack().open_fileswitcher_dlg()

@Slot()
def call_symbol_finder(self):
if self.editorstacks:
self.get_current_editorstack().open_symbolfinder_dlg()

def update_recent_file_menu(self):
"""Update recent file menu"""
recent_files = []
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 @@ -203,6 +203,7 @@
'spyder.autopep8': [('fa.eye',), {}],
'spyder.memory_profiler': [('fa.eye',), {}],
'spyder.line_profiler': [('fa.eye',), {}],
'symbol_find': [('fa.at',), {}]
}


Expand Down
10 changes: 10 additions & 0 deletions spyder/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ def __init__(self, parent, actions):
fileswitcher_action = create_action(self, _("File switcher..."),
icon=ima.icon('filelist'),
triggered=self.open_fileswitcher_dlg)
symbolfinder_action = create_action(self,
_("Find symbols in file..."),
icon=ima.icon('filelist'),
triggered=self.open_symbolfinder_dlg)
copy_to_cb_action = create_action(self, _("Copy path to clipboard"),
icon=ima.icon('editcopy'),
triggered=lambda:
Expand All @@ -356,6 +360,7 @@ def __init__(self, parent, actions):
triggered=self.close_all_but_this)

self.menu_actions = actions + [None, fileswitcher_action,
symbolfinder_action,
copy_to_cb_action, None, close_right,
close_all_but_this]
self.outlineexplorer = None
Expand Down Expand Up @@ -617,6 +622,11 @@ def open_fileswitcher_dlg(self):
self.fileswitcher_dlg.show()
self.fileswitcher_dlg.is_visible = True

@Slot()
def open_symbolfinder_dlg(self):
self.open_fileswitcher_dlg()
self.fileswitcher_dlg.set_search_text('@')

def update_fileswitcher_dlg(self):
"""Synchronize file list dialog box with editor widget tabs"""
if self.fileswitcher_dlg:
Expand Down
3 changes: 3 additions & 0 deletions spyder/widgets/fileswitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ def filter_text(self):
"""Get the normalized (lowecase) content of the filter text."""
return to_text_string(self.edit.text()).lower()

def set_search_text(self, _str):
self.edit.setText(_str)

def save_initial_state(self):
"""Saves initial cursors and initial active editor."""
paths = self.paths
Expand Down

0 comments on commit 138bd23

Please sign in to comment.