29
29
from spyderlib.utils import encoding, sourcecode, codeanalysis
30
from spyderlib.baseconfig import get_conf_path, _, STDOUT
30
from spyderlib.baseconfig import get_conf_path, _
31
31
from spyderlib.config import CONF, EDIT_FILTERS, get_filter, EDIT_FILETYPES
32
32
from spyderlib.guiconfig import get_color_scheme
33
33
from spyderlib.utils import programs
34
34
from spyderlib.utils.qthelpers import (get_icon, create_action, add_actions,
35
get_std_icon, get_filetype_icon)
35
get_std_icon, get_filetype_icon,
36
add_shortcut_to_tooltip)
36
37
from spyderlib.widgets.findreplace import FindReplace
37
38
from spyderlib.widgets.status import (ReadWriteStatus, EOLStatus,
38
39
EncodingStatus, CursorPositionStatus)
576
577
default="Ctrl+Alt+P")
577
578
self.addActions([self.toggle_outline_action, self.toggle_project_action])
580
# ---- File menu and toolbar ----
579
581
self.new_action = create_action(self, _("&New file..."),
580
icon='filenew.png', tip=_("Create a new Python script"),
582
icon='filenew.png', tip=_("New file"),
581
583
triggered=self.new)
582
584
self.register_shortcut(self.new_action, context="Editor",
583
585
name="New file", default="Ctrl+N")
586
add_shortcut_to_tooltip(self.new_action, context="Editor",
584
589
self.open_action = create_action(self, _("&Open..."),
585
icon='fileopen.png', tip=_("Open text file"),
590
icon='fileopen.png', tip=_("Open file"),
586
591
triggered=self.load)
592
self.register_shortcut(self.open_action, context="Editor",
593
name="Open file", default="Ctrl+O")
594
add_shortcut_to_tooltip(self.open_action, context="Editor",
587
597
self.revert_action = create_action(self, _("&Revert"),
588
598
icon='revert.png', tip=_("Revert file from disk"),
589
599
triggered=self.revert)
590
self.register_shortcut(self.open_action, context="Editor",
591
name="Open file", default="Ctrl+O")
592
601
self.save_action = create_action(self, _("&Save"),
593
icon='filesave.png', tip=_("Save current file"),
602
icon='filesave.png', tip=_("Save file"),
594
603
triggered=self.save)
595
604
self.register_shortcut(self.save_action, context="Editor",
596
605
name="Save file", default="Ctrl+S")
606
add_shortcut_to_tooltip(self.save_action, context="Editor",
597
609
self.save_all_action = create_action(self, _("Sav&e all"),
598
icon='save_all.png', tip=_("Save all opened files"),
610
icon='save_all.png', tip=_("Save all files"),
599
611
triggered=self.save_all)
600
612
self.register_shortcut(self.save_all_action, context="Editor",
601
613
name="Save all", default="Ctrl+Shift+S")
614
add_shortcut_to_tooltip(self.save_all_action, context="Editor",
602
617
save_as_action = create_action(self, _("Save &as..."), None,
603
618
'filesaveas.png', _("Save current file as..."),
604
619
triggered=self.save_as)
642
658
add_actions(breakpoints_menu, (set_clear_breakpoint_action,
643
659
set_cond_breakpoint_action, None,
644
660
clear_all_breakpoints_action))
661
self.winpdb_action = create_action(self, _("Debug with winpdb"),
662
triggered=self.run_winpdb)
663
self.winpdb_action.setEnabled(WINPDB_PATH is not None)
664
self.register_shortcut(self.winpdb_action, context="Editor",
665
name="Debug with winpdb", default="F7")
646
667
# --- Debug toolbar ---
647
668
debug_action = create_action(self, _("&Debug"), icon='debug.png',
649
670
triggered=self.debug_file)
650
671
self.register_shortcut(debug_action, context="Editor",
651
672
name="Debug", default="Ctrl+F5")
673
add_shortcut_to_tooltip(debug_action, context="Editor", name="Debug")
652
675
debug_next_action = create_action(self, _("Step"),
653
676
icon='arrow-step-over.png', tip=_("Run current line"),
654
677
triggered=lambda: self.debug_command("next"))
655
678
self.register_shortcut(debug_next_action, "_",
656
679
"Debug Step Over", "Ctrl+F10")
680
add_shortcut_to_tooltip(debug_next_action, context="_",
681
name="Debug Step Over")
657
683
debug_continue_action = create_action(self, _("Continue"),
658
icon='arrow-continue.png', tip=_("Continue execution until\n"
684
icon='arrow-continue.png', tip=_("Continue execution until "
659
685
"next breakpoint"),
660
686
triggered=lambda: self.debug_command("continue"))
661
687
self.register_shortcut(debug_continue_action, "_",
662
688
"Debug Continue", "Ctrl+F12")
689
add_shortcut_to_tooltip(debug_continue_action, context="_",
690
name="Debug Continue")
663
692
debug_step_action = create_action(self, _("Step Into"),
664
icon='arrow-step-in.png', tip=_("Step into function, method\n"
665
"or class of current line"),
693
icon='arrow-step-in.png', tip=_("Step into function or method "
666
695
triggered=lambda: self.debug_command("step"))
667
696
self.register_shortcut(debug_step_action, "_",
668
"Debug Step Into", "Ctrl+F11")
697
"Debug Step Into", "Ctrl+F11")
698
add_shortcut_to_tooltip(debug_step_action, context="_",
699
name="Debug Step Into")
669
701
debug_return_action = create_action(self, _("Step Return"),
670
icon='arrow-step-out.png', tip=_("Run until current function\n"
702
icon='arrow-step-out.png', tip=_("Run until current function "
671
703
"or method returns"),
672
704
triggered=lambda: self.debug_command("return"))
673
705
self.register_shortcut(debug_return_action, "_",
674
706
"Debug Step Return", "Ctrl+Shift+F11")
707
add_shortcut_to_tooltip(debug_return_action, context="_",
708
name="Debug Step Return")
675
710
debug_exit_action = create_action(self, _("Exit"),
676
711
icon='stop_debug.png', tip=_("Exit Debug"),
677
712
triggered=lambda: self.debug_command("exit"))
678
713
self.register_shortcut(debug_exit_action, "_",
679
"Debug Exit", "Ctrl+Shift+F12")
714
"Debug Exit", "Ctrl+Shift+F12")
715
add_shortcut_to_tooltip(debug_exit_action, context="_",
680
718
debug_control_menu_actions = [debug_next_action,
681
719
debug_step_action,
682
720
debug_return_action,
698
738
triggered=self.edit_run_configurations)
699
739
self.register_shortcut(configure_action, context="Editor",
700
740
name="Configure", default="F6")
741
add_shortcut_to_tooltip(configure_action, context="Editor",
701
744
re_run_action = create_action(self,
702
745
_("Re-run &last script"), icon='run_again.png',
703
746
tip=_("Run again last file"),
704
747
triggered=self.re_run_file)
705
748
self.register_shortcut(re_run_action, context="Editor",
706
749
name="Re-run last script", default="Ctrl+F6")
750
add_shortcut_to_tooltip(re_run_action, context="Editor",
751
name="Re-run last script")
708
753
run_selected_action = create_action(self, _("Run &selection"),
709
754
icon='run_selection.png',
710
755
tip=_("Run selection"),
711
756
triggered=self.run_selection)
712
757
self.register_shortcut(run_selected_action, context="Editor",
713
758
name="Run selection", default="F9")
714
760
run_cell_action = create_action(self,
715
761
_("Run cell"), icon='run_cell.png',
716
762
shortcut=QKeySequence("Ctrl+Enter"),
717
tip=_("Run current cell \n"\
718
"(see Editor documentation \n"\
719
"for more details on cells)"),
763
tip=_("Run current cell (Ctrl+Enter)\n"
764
"[Use #%% to create cells]"),
720
765
triggered=self.run_cell)
721
767
run_cell_advance_action = create_action(self,
722
768
_("Run cell and advance"),
723
769
icon='run_cell_advance.png',
724
770
shortcut=QKeySequence("Shift+Enter"),
725
tip=_("Run current cell and go to the next one\n"\
726
"(see Editor documentation \n"\
727
"for more details on cells)"),
771
tip=_("Run current cell and go to "
772
"the next one (Shift+Enter)"),
728
773
triggered=self.run_cell_and_advance)
730
775
# --- Source code Toolbar ---
813
858
triggered=self.unindent, context=Qt.WidgetShortcut)
814
859
# ----------------------------------------------------------------------
816
self.winpdb_action = create_action(self, _("Debug with winpdb"),
817
triggered=self.run_winpdb)
818
self.winpdb_action.setEnabled(WINPDB_PATH is not None)
819
self.register_shortcut(self.winpdb_action, context="Editor",
820
name="Debug with winpdb", default="F7")
822
861
self.win_eol_action = create_action(self,
823
862
_("Carriage return and line feed (Windows)"),
824
863
toggled=lambda: self.toggle_eol_chars('nt'))
890
929
self.main.search_menu_actions += self.search_menu_actions
891
930
self.main.search_toolbar_actions += [gotoline_action]
893
# The breakpoints plugin is expecting that
894
# breakpoints_menu will be the first QMenu in run_menu_actions
895
# If breakpoints_menu must be moved below another QMenu in the list
896
# please update the breakpoints plugin accordingly.
897
run_menu_actions = [run_action, debug_action, configure_action,
898
breakpoints_menu, debug_control_menu, None,
899
re_run_action, run_selected_action,
901
run_cell_advance_action, None,
932
# ---- Run menu/toolbar construction ----
933
run_menu_actions = [run_action, run_cell_action,
934
run_cell_advance_action, None, run_selected_action,
935
re_run_action, configure_action, None]
903
936
self.main.run_menu_actions += run_menu_actions
904
937
run_toolbar_actions = [run_action, run_cell_action,
905
938
run_cell_advance_action, re_run_action,
906
939
configure_action]
907
940
self.main.run_toolbar_actions += run_toolbar_actions
942
# ---- Debug menu/toolbar construction ----
943
# The breakpoints plugin is expecting that
944
# breakpoints_menu will be the first QMenu in debug_menu_actions
945
# If breakpoints_menu must be moved below another QMenu in the list
946
# please update the breakpoints plugin accordingly.
947
debug_menu_actions = [debug_action, breakpoints_menu,
948
debug_control_menu, None, self.winpdb_action]
949
self.main.debug_menu_actions += debug_menu_actions
909
950
debug_toolbar_actions = [debug_action, debug_next_action,
910
951
debug_step_action, debug_return_action,
911
952
debug_continue_action, debug_exit_action]
938
979
workdir_action, self.close_action, self.close_all_action,
939
980
self.toggle_comment_action, self.revert_action,
940
981
self.indent_action, self.unindent_action]
941
self.stack_menu_actions = [self.save_action, save_as_action,
942
self.print_action, None, run_action, debug_action,
943
configure_action, None, gotoline_action,
944
workdir_action, None, self.close_action]
982
self.stack_menu_actions = [gotoline_action, workdir_action]
946
984
return self.file_dependent_actions