23 pyqtSlot, |
23 pyqtSlot, |
24 ) |
24 ) |
25 from PyQt6.QtGui import QKeySequence, QPixmap |
25 from PyQt6.QtGui import QKeySequence, QPixmap |
26 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget |
26 from PyQt6.QtWidgets import QApplication, QDialog, QMenu, QToolBar, QWidget |
27 |
27 |
28 from eric7 import Preferences, Utilities |
28 from eric7 import Preferences |
29 from eric7.EricGui import EricPixmapCache |
29 from eric7.EricGui import EricPixmapCache |
30 from eric7.EricGui.EricAction import EricAction, createActionGroup |
30 from eric7.EricGui.EricAction import EricAction, createActionGroup |
31 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
31 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
32 from eric7.EricWidgets.EricApplication import ericApp |
32 from eric7.EricWidgets.EricApplication import ericApp |
33 from eric7.Globals import isMacPlatform, recentNameFiles |
33 from eric7.Globals import recentNameFiles |
34 from eric7.QScintilla import Exporters, Lexers |
34 from eric7.QScintilla import Exporters, Lexers |
35 from eric7.QScintilla.APIsManager import APIsManager |
35 from eric7.QScintilla.APIsManager import APIsManager |
36 from eric7.QScintilla.Editor import Editor |
36 from eric7.QScintilla.Editor import Editor |
37 from eric7.QScintilla.EditorAssembly import EditorAssembly |
37 from eric7.QScintilla.EditorAssembly import EditorAssembly |
38 from eric7.QScintilla.Shell import Shell |
38 from eric7.QScintilla.Shell import Shell |
39 from eric7.QScintilla.SpellChecker import SpellChecker |
39 from eric7.QScintilla.SpellChecker import SpellChecker |
40 from eric7.QScintilla.SpellingDictionaryEditDialog import SpellingDictionaryEditDialog |
40 from eric7.QScintilla.SpellingDictionaryEditDialog import SpellingDictionaryEditDialog |
41 from eric7.QScintilla.ZoomDialog import ZoomDialog |
41 from eric7.QScintilla.ZoomDialog import ZoomDialog |
|
42 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
42 from eric7.UI import Config |
43 from eric7.UI import Config |
43 |
44 |
44 |
45 |
45 class ViewManager(QWidget): |
46 class ViewManager(QWidget): |
46 """ |
47 """ |
1730 0, |
1731 0, |
1731 self.editorActGrp, |
1732 self.editorActGrp, |
1732 "vm_edit_move_left_char", |
1733 "vm_edit_move_left_char", |
1733 ) |
1734 ) |
1734 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) |
1735 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFT) |
1735 if isMacPlatform(): |
1736 if OSUtilities.isMacPlatform(): |
1736 act.setAlternateShortcut( |
1737 act.setAlternateShortcut( |
1737 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+B")) |
1738 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+B")) |
1738 ) |
1739 ) |
1739 act.triggered.connect(self.esm.map) |
1740 act.triggered.connect(self.esm.map) |
1740 self.editActions.append(act) |
1741 self.editActions.append(act) |
1745 QKeySequence(QCoreApplication.translate("ViewManager", "Right")), |
1746 QKeySequence(QCoreApplication.translate("ViewManager", "Right")), |
1746 0, |
1747 0, |
1747 self.editorActGrp, |
1748 self.editorActGrp, |
1748 "vm_edit_move_right_char", |
1749 "vm_edit_move_right_char", |
1749 ) |
1750 ) |
1750 if isMacPlatform(): |
1751 if OSUtilities.isMacPlatform(): |
1751 act.setAlternateShortcut( |
1752 act.setAlternateShortcut( |
1752 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+F")) |
1753 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+F")) |
1753 ) |
1754 ) |
1754 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) |
1755 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHT) |
1755 act.triggered.connect(self.esm.map) |
1756 act.triggered.connect(self.esm.map) |
1761 QKeySequence(QCoreApplication.translate("ViewManager", "Up")), |
1762 QKeySequence(QCoreApplication.translate("ViewManager", "Up")), |
1762 0, |
1763 0, |
1763 self.editorActGrp, |
1764 self.editorActGrp, |
1764 "vm_edit_move_up_line", |
1765 "vm_edit_move_up_line", |
1765 ) |
1766 ) |
1766 if isMacPlatform(): |
1767 if OSUtilities.isMacPlatform(): |
1767 act.setAlternateShortcut( |
1768 act.setAlternateShortcut( |
1768 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+P")) |
1769 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+P")) |
1769 ) |
1770 ) |
1770 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) |
1771 self.esm.setMapping(act, QsciScintilla.SCI_LINEUP) |
1771 act.triggered.connect(self.esm.map) |
1772 act.triggered.connect(self.esm.map) |
1777 QKeySequence(QCoreApplication.translate("ViewManager", "Down")), |
1778 QKeySequence(QCoreApplication.translate("ViewManager", "Down")), |
1778 0, |
1779 0, |
1779 self.editorActGrp, |
1780 self.editorActGrp, |
1780 "vm_edit_move_down_line", |
1781 "vm_edit_move_down_line", |
1781 ) |
1782 ) |
1782 if isMacPlatform(): |
1783 if OSUtilities.isMacPlatform(): |
1783 act.setAlternateShortcut( |
1784 act.setAlternateShortcut( |
1784 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+N")) |
1785 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+N")) |
1785 ) |
1786 ) |
1786 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) |
1787 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWN) |
1787 act.triggered.connect(self.esm.map) |
1788 act.triggered.connect(self.esm.map) |
1793 0, |
1794 0, |
1794 0, |
1795 0, |
1795 self.editorActGrp, |
1796 self.editorActGrp, |
1796 "vm_edit_move_left_word_part", |
1797 "vm_edit_move_left_word_part", |
1797 ) |
1798 ) |
1798 if not isMacPlatform(): |
1799 if not OSUtilities.isMacPlatform(): |
1799 act.setShortcut( |
1800 act.setShortcut( |
1800 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Left")) |
1801 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Left")) |
1801 ) |
1802 ) |
1802 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFT) |
1803 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTLEFT) |
1803 act.triggered.connect(self.esm.map) |
1804 act.triggered.connect(self.esm.map) |
1809 0, |
1810 0, |
1810 0, |
1811 0, |
1811 self.editorActGrp, |
1812 self.editorActGrp, |
1812 "vm_edit_move_right_word_part", |
1813 "vm_edit_move_right_word_part", |
1813 ) |
1814 ) |
1814 if not isMacPlatform(): |
1815 if not OSUtilities.isMacPlatform(): |
1815 act.setShortcut( |
1816 act.setShortcut( |
1816 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right")) |
1817 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right")) |
1817 ) |
1818 ) |
1818 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHT) |
1819 self.esm.setMapping(act, QsciScintilla.SCI_WORDPARTRIGHT) |
1819 act.triggered.connect(self.esm.map) |
1820 act.triggered.connect(self.esm.map) |
1845 0, |
1846 0, |
1846 0, |
1847 0, |
1847 self.editorActGrp, |
1848 self.editorActGrp, |
1848 "vm_edit_move_right_word", |
1849 "vm_edit_move_right_word", |
1849 ) |
1850 ) |
1850 if not isMacPlatform(): |
1851 if not OSUtilities.isMacPlatform(): |
1851 act.setShortcut( |
1852 act.setShortcut( |
1852 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Right")) |
1853 QKeySequence(QCoreApplication.translate("ViewManager", "Ctrl+Right")) |
1853 ) |
1854 ) |
1854 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) |
1855 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHT) |
1855 act.triggered.connect(self.esm.map) |
1856 act.triggered.connect(self.esm.map) |
1865 0, |
1866 0, |
1866 0, |
1867 0, |
1867 self.editorActGrp, |
1868 self.editorActGrp, |
1868 "vm_edit_move_first_visible_char", |
1869 "vm_edit_move_first_visible_char", |
1869 ) |
1870 ) |
1870 if not isMacPlatform(): |
1871 if not OSUtilities.isMacPlatform(): |
1871 act.setShortcut( |
1872 act.setShortcut( |
1872 QKeySequence(QCoreApplication.translate("ViewManager", "Home")) |
1873 QKeySequence(QCoreApplication.translate("ViewManager", "Home")) |
1873 ) |
1874 ) |
1874 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) |
1875 self.esm.setMapping(act, QsciScintilla.SCI_VCHOME) |
1875 act.triggered.connect(self.esm.map) |
1876 act.triggered.connect(self.esm.map) |
1981 QKeySequence(QCoreApplication.translate("ViewManager", "PgDown")), |
1982 QKeySequence(QCoreApplication.translate("ViewManager", "PgDown")), |
1982 0, |
1983 0, |
1983 self.editorActGrp, |
1984 self.editorActGrp, |
1984 "vm_edit_move_down_page", |
1985 "vm_edit_move_down_page", |
1985 ) |
1986 ) |
1986 if isMacPlatform(): |
1987 if OSUtilities.isMacPlatform(): |
1987 act.setAlternateShortcut( |
1988 act.setAlternateShortcut( |
1988 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+V")) |
1989 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+V")) |
1989 ) |
1990 ) |
1990 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) |
1991 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWN) |
1991 act.triggered.connect(self.esm.map) |
1992 act.triggered.connect(self.esm.map) |
2065 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Left")), |
2066 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Left")), |
2066 0, |
2067 0, |
2067 self.editorActGrp, |
2068 self.editorActGrp, |
2068 "vm_edit_extend_selection_left_char", |
2069 "vm_edit_extend_selection_left_char", |
2069 ) |
2070 ) |
2070 if isMacPlatform(): |
2071 if OSUtilities.isMacPlatform(): |
2071 act.setAlternateShortcut( |
2072 act.setAlternateShortcut( |
2072 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+B")) |
2073 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+B")) |
2073 ) |
2074 ) |
2074 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) |
2075 self.esm.setMapping(act, QsciScintilla.SCI_CHARLEFTEXTEND) |
2075 act.triggered.connect(self.esm.map) |
2076 act.triggered.connect(self.esm.map) |
2085 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Right")), |
2086 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Right")), |
2086 0, |
2087 0, |
2087 self.editorActGrp, |
2088 self.editorActGrp, |
2088 "vm_edit_extend_selection_right_char", |
2089 "vm_edit_extend_selection_right_char", |
2089 ) |
2090 ) |
2090 if isMacPlatform(): |
2091 if OSUtilities.isMacPlatform(): |
2091 act.setAlternateShortcut( |
2092 act.setAlternateShortcut( |
2092 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+F")) |
2093 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+F")) |
2093 ) |
2094 ) |
2094 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) |
2095 self.esm.setMapping(act, QsciScintilla.SCI_CHARRIGHTEXTEND) |
2095 act.triggered.connect(self.esm.map) |
2096 act.triggered.connect(self.esm.map) |
2101 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Up")), |
2102 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Up")), |
2102 0, |
2103 0, |
2103 self.editorActGrp, |
2104 self.editorActGrp, |
2104 "vm_edit_extend_selection_up_line", |
2105 "vm_edit_extend_selection_up_line", |
2105 ) |
2106 ) |
2106 if isMacPlatform(): |
2107 if OSUtilities.isMacPlatform(): |
2107 act.setAlternateShortcut( |
2108 act.setAlternateShortcut( |
2108 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+P")) |
2109 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+P")) |
2109 ) |
2110 ) |
2110 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPEXTEND) |
2111 self.esm.setMapping(act, QsciScintilla.SCI_LINEUPEXTEND) |
2111 act.triggered.connect(self.esm.map) |
2112 act.triggered.connect(self.esm.map) |
2117 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Down")), |
2118 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Down")), |
2118 0, |
2119 0, |
2119 self.editorActGrp, |
2120 self.editorActGrp, |
2120 "vm_edit_extend_selection_down_line", |
2121 "vm_edit_extend_selection_down_line", |
2121 ) |
2122 ) |
2122 if isMacPlatform(): |
2123 if OSUtilities.isMacPlatform(): |
2123 act.setAlternateShortcut( |
2124 act.setAlternateShortcut( |
2124 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+N")) |
2125 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+N")) |
2125 ) |
2126 ) |
2126 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNEXTEND) |
2127 self.esm.setMapping(act, QsciScintilla.SCI_LINEDOWNEXTEND) |
2127 act.triggered.connect(self.esm.map) |
2128 act.triggered.connect(self.esm.map) |
2235 0, |
2236 0, |
2236 0, |
2237 0, |
2237 self.editorActGrp, |
2238 self.editorActGrp, |
2238 "vm_edit_extend_selection_first_visible_char", |
2239 "vm_edit_extend_selection_first_visible_char", |
2239 ) |
2240 ) |
2240 if not isMacPlatform(): |
2241 if not OSUtilities.isMacPlatform(): |
2241 act.setShortcut( |
2242 act.setShortcut( |
2242 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Home")) |
2243 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+Home")) |
2243 ) |
2244 ) |
2244 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) |
2245 self.esm.setMapping(act, QsciScintilla.SCI_VCHOMEEXTEND) |
2245 act.triggered.connect(self.esm.map) |
2246 act.triggered.connect(self.esm.map) |
2319 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+PgDown")), |
2320 QKeySequence(QCoreApplication.translate("ViewManager", "Shift+PgDown")), |
2320 0, |
2321 0, |
2321 self.editorActGrp, |
2322 self.editorActGrp, |
2322 "vm_edit_extend_selection_down_page", |
2323 "vm_edit_extend_selection_down_page", |
2323 ) |
2324 ) |
2324 if isMacPlatform(): |
2325 if OSUtilities.isMacPlatform(): |
2325 act.setAlternateShortcut( |
2326 act.setAlternateShortcut( |
2326 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+V")) |
2327 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+Shift+V")) |
2327 ) |
2328 ) |
2328 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNEXTEND) |
2329 self.esm.setMapping(act, QsciScintilla.SCI_PAGEDOWNEXTEND) |
2329 act.triggered.connect(self.esm.map) |
2330 act.triggered.connect(self.esm.map) |
2389 QKeySequence(QCoreApplication.translate("ViewManager", "Backspace")), |
2390 QKeySequence(QCoreApplication.translate("ViewManager", "Backspace")), |
2390 0, |
2391 0, |
2391 self.editorActGrp, |
2392 self.editorActGrp, |
2392 "vm_edit_delete_previous_char", |
2393 "vm_edit_delete_previous_char", |
2393 ) |
2394 ) |
2394 if isMacPlatform(): |
2395 if OSUtilities.isMacPlatform(): |
2395 act.setAlternateShortcut( |
2396 act.setAlternateShortcut( |
2396 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+H")) |
2397 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+H")) |
2397 ) |
2398 ) |
2398 else: |
2399 else: |
2399 act.setAlternateShortcut( |
2400 act.setAlternateShortcut( |
2427 QKeySequence(QCoreApplication.translate("ViewManager", "Del")), |
2428 QKeySequence(QCoreApplication.translate("ViewManager", "Del")), |
2428 0, |
2429 0, |
2429 self.editorActGrp, |
2430 self.editorActGrp, |
2430 "vm_edit_delete_current_char", |
2431 "vm_edit_delete_current_char", |
2431 ) |
2432 ) |
2432 if isMacPlatform(): |
2433 if OSUtilities.isMacPlatform(): |
2433 act.setAlternateShortcut( |
2434 act.setAlternateShortcut( |
2434 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+D")) |
2435 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+D")) |
2435 ) |
2436 ) |
2436 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) |
2437 self.esm.setMapping(act, QsciScintilla.SCI_CLEAR) |
2437 act.triggered.connect(self.esm.map) |
2438 act.triggered.connect(self.esm.map) |
2688 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Down")), |
2689 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Down")), |
2689 0, |
2690 0, |
2690 self.editorActGrp, |
2691 self.editorActGrp, |
2691 "vm_edit_extend_rect_selection_down_line", |
2692 "vm_edit_extend_rect_selection_down_line", |
2692 ) |
2693 ) |
2693 if isMacPlatform(): |
2694 if OSUtilities.isMacPlatform(): |
2694 act.setAlternateShortcut( |
2695 act.setAlternateShortcut( |
2695 QKeySequence( |
2696 QKeySequence( |
2696 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+N") |
2697 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+N") |
2697 ) |
2698 ) |
2698 ) |
2699 ) |
2710 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Up")), |
2711 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Up")), |
2711 0, |
2712 0, |
2712 self.editorActGrp, |
2713 self.editorActGrp, |
2713 "vm_edit_extend_rect_selection_up_line", |
2714 "vm_edit_extend_rect_selection_up_line", |
2714 ) |
2715 ) |
2715 if isMacPlatform(): |
2716 if OSUtilities.isMacPlatform(): |
2716 act.setAlternateShortcut( |
2717 act.setAlternateShortcut( |
2717 QKeySequence( |
2718 QKeySequence( |
2718 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+P") |
2719 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+P") |
2719 ) |
2720 ) |
2720 ) |
2721 ) |
2732 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Left")), |
2733 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Left")), |
2733 0, |
2734 0, |
2734 self.editorActGrp, |
2735 self.editorActGrp, |
2735 "vm_edit_extend_rect_selection_left_char", |
2736 "vm_edit_extend_rect_selection_left_char", |
2736 ) |
2737 ) |
2737 if isMacPlatform(): |
2738 if OSUtilities.isMacPlatform(): |
2738 act.setAlternateShortcut( |
2739 act.setAlternateShortcut( |
2739 QKeySequence( |
2740 QKeySequence( |
2740 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+B") |
2741 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+B") |
2741 ) |
2742 ) |
2742 ) |
2743 ) |
2754 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Right")), |
2755 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Ctrl+Right")), |
2755 0, |
2756 0, |
2756 self.editorActGrp, |
2757 self.editorActGrp, |
2757 "vm_edit_extend_rect_selection_right_char", |
2758 "vm_edit_extend_rect_selection_right_char", |
2758 ) |
2759 ) |
2759 if isMacPlatform(): |
2760 if OSUtilities.isMacPlatform(): |
2760 act.setAlternateShortcut( |
2761 act.setAlternateShortcut( |
2761 QKeySequence( |
2762 QKeySequence( |
2762 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+F") |
2763 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+F") |
2763 ) |
2764 ) |
2764 ) |
2765 ) |
2844 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+PgDown")), |
2845 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Shift+PgDown")), |
2845 0, |
2846 0, |
2846 self.editorActGrp, |
2847 self.editorActGrp, |
2847 "vm_edit_extend_rect_selection_down_page", |
2848 "vm_edit_extend_rect_selection_down_page", |
2848 ) |
2849 ) |
2849 if isMacPlatform(): |
2850 if OSUtilities.isMacPlatform(): |
2850 act.setAlternateShortcut( |
2851 act.setAlternateShortcut( |
2851 QKeySequence( |
2852 QKeySequence( |
2852 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+V") |
2853 QCoreApplication.translate("ViewManager", "Meta+Alt+Shift+V") |
2853 ) |
2854 ) |
2854 ) |
2855 ) |
2879 0, |
2880 0, |
2880 0, |
2881 0, |
2881 self.editorActGrp, |
2882 self.editorActGrp, |
2882 "vm_edit_scroll_start_text", |
2883 "vm_edit_scroll_start_text", |
2883 ) |
2884 ) |
2884 if isMacPlatform(): |
2885 if OSUtilities.isMacPlatform(): |
2885 act.setShortcut( |
2886 act.setShortcut( |
2886 QKeySequence(QCoreApplication.translate("ViewManager", "Home")) |
2887 QKeySequence(QCoreApplication.translate("ViewManager", "Home")) |
2887 ) |
2888 ) |
2888 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOSTART) |
2889 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOSTART) |
2889 act.triggered.connect(self.esm.map) |
2890 act.triggered.connect(self.esm.map) |
2896 0, |
2897 0, |
2897 0, |
2898 0, |
2898 self.editorActGrp, |
2899 self.editorActGrp, |
2899 "vm_edit_scroll_end_text", |
2900 "vm_edit_scroll_end_text", |
2900 ) |
2901 ) |
2901 if isMacPlatform(): |
2902 if OSUtilities.isMacPlatform(): |
2902 act.setShortcut( |
2903 act.setShortcut( |
2903 QKeySequence(QCoreApplication.translate("ViewManager", "End")) |
2904 QKeySequence(QCoreApplication.translate("ViewManager", "End")) |
2904 ) |
2905 ) |
2905 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOEND) |
2906 self.esm.setMapping(act, QsciScintilla.SCI_SCROLLTOEND) |
2906 act.triggered.connect(self.esm.map) |
2907 act.triggered.connect(self.esm.map) |
2917 0, |
2918 0, |
2918 0, |
2919 0, |
2919 self.editorActGrp, |
2920 self.editorActGrp, |
2920 "vm_edit_scroll_vertically_center", |
2921 "vm_edit_scroll_vertically_center", |
2921 ) |
2922 ) |
2922 if isMacPlatform(): |
2923 if OSUtilities.isMacPlatform(): |
2923 act.setShortcut( |
2924 act.setShortcut( |
2924 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+L")) |
2925 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+L")) |
2925 ) |
2926 ) |
2926 self.esm.setMapping(act, QsciScintilla.SCI_VERTICALCENTRECARET) |
2927 self.esm.setMapping(act, QsciScintilla.SCI_VERTICALCENTRECARET) |
2927 act.triggered.connect(self.esm.map) |
2928 act.triggered.connect(self.esm.map) |
2934 0, |
2935 0, |
2935 0, |
2936 0, |
2936 self.editorActGrp, |
2937 self.editorActGrp, |
2937 "vm_edit_move_end_next_word", |
2938 "vm_edit_move_end_next_word", |
2938 ) |
2939 ) |
2939 if isMacPlatform(): |
2940 if OSUtilities.isMacPlatform(): |
2940 act.setShortcut( |
2941 act.setShortcut( |
2941 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right")) |
2942 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Right")) |
2942 ) |
2943 ) |
2943 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEND) |
2944 self.esm.setMapping(act, QsciScintilla.SCI_WORDRIGHTEND) |
2944 act.triggered.connect(self.esm.map) |
2945 act.triggered.connect(self.esm.map) |
3012 0, |
3013 0, |
3013 0, |
3014 0, |
3014 self.editorActGrp, |
3015 self.editorActGrp, |
3015 "vm_edit_move_start_document_line", |
3016 "vm_edit_move_start_document_line", |
3016 ) |
3017 ) |
3017 if isMacPlatform(): |
3018 if OSUtilities.isMacPlatform(): |
3018 act.setShortcut( |
3019 act.setShortcut( |
3019 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+A")) |
3020 QKeySequence(QCoreApplication.translate("ViewManager", "Meta+A")) |
3020 ) |
3021 ) |
3021 self.esm.setMapping(act, QsciScintilla.SCI_HOME) |
3022 self.esm.setMapping(act, QsciScintilla.SCI_HOME) |
3022 act.triggered.connect(self.esm.map) |
3023 act.triggered.connect(self.esm.map) |
3278 0, |
3279 0, |
3279 0, |
3280 0, |
3280 self.editorActGrp, |
3281 self.editorActGrp, |
3281 "vm_edit_delete_right_end_next_word", |
3282 "vm_edit_delete_right_end_next_word", |
3282 ) |
3283 ) |
3283 if isMacPlatform(): |
3284 if OSUtilities.isMacPlatform(): |
3284 act.setShortcut( |
3285 act.setShortcut( |
3285 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Del")) |
3286 QKeySequence(QCoreApplication.translate("ViewManager", "Alt+Del")) |
3286 ) |
3287 ) |
3287 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHTEND) |
3288 self.esm.setMapping(act, QsciScintilla.SCI_DELWORDRIGHTEND) |
3288 act.triggered.connect(self.esm.map) |
3289 act.triggered.connect(self.esm.map) |
5746 Public slot to add a filename to the list of recently opened files. |
5747 Public slot to add a filename to the list of recently opened files. |
5747 |
5748 |
5748 @param fn name of the file to be added |
5749 @param fn name of the file to be added |
5749 """ |
5750 """ |
5750 for recent in self.recent[:]: |
5751 for recent in self.recent[:]: |
5751 if Utilities.samepath(fn, recent): |
5752 if FileSystemUtilities.samepath(fn, recent): |
5752 self.recent.remove(recent) |
5753 self.recent.remove(recent) |
5753 self.recent.insert(0, fn) |
5754 self.recent.insert(0, fn) |
5754 maxRecent = Preferences.getUI("RecentNumber") |
5755 maxRecent = Preferences.getUI("RecentNumber") |
5755 if len(self.recent) > maxRecent: |
5756 if len(self.recent) > maxRecent: |
5756 self.recent = self.recent[:maxRecent] |
5757 self.recent = self.recent[:maxRecent] |
5951 creation and a reference to the editor displaying this file |
5952 creation and a reference to the editor displaying this file |
5952 @rtype tuple of (bool, Editor) |
5953 @rtype tuple of (bool, Editor) |
5953 """ |
5954 """ |
5954 newWin = False |
5955 newWin = False |
5955 editor = self.activeWindow() |
5956 editor = self.activeWindow() |
5956 if editor is None or not Utilities.samepath(fn, editor.getFileName()): |
5957 if editor is None or not FileSystemUtilities.samepath(fn, editor.getFileName()): |
5957 for editor in self.editors: |
5958 for editor in self.editors: |
5958 if Utilities.samepath(fn, editor.getFileName()): |
5959 if FileSystemUtilities.samepath(fn, editor.getFileName()): |
5959 break |
5960 break |
5960 else: |
5961 else: |
5961 assembly = EditorAssembly( |
5962 assembly = EditorAssembly( |
5962 self.dbs, |
5963 self.dbs, |
5963 fn, |
5964 fn, |
6004 @param fn filename to look for |
6005 @param fn filename to look for |
6005 @return a reference to the editor displaying this file or None, if |
6006 @return a reference to the editor displaying this file or None, if |
6006 no editor was found |
6007 no editor was found |
6007 """ |
6008 """ |
6008 for editor in self.editors: |
6009 for editor in self.editors: |
6009 if Utilities.samepath(fn, editor.getFileName()): |
6010 if FileSystemUtilities.samepath(fn, editor.getFileName()): |
6010 return editor |
6011 return editor |
6011 |
6012 |
6012 return None |
6013 return None |
6013 |
6014 |
6014 def getOpenEditorCount(self, fn): |
6015 def getOpenEditorCount(self, fn): |
6018 @param fn filename to look for |
6019 @param fn filename to look for |
6019 @return count of editors displaying this file (integer) |
6020 @return count of editors displaying this file (integer) |
6020 """ |
6021 """ |
6021 count = 0 |
6022 count = 0 |
6022 for editor in self.editors: |
6023 for editor in self.editors: |
6023 if Utilities.samepath(fn, editor.getFileName()): |
6024 if FileSystemUtilities.samepath(fn, editor.getFileName()): |
6024 count += 1 |
6025 count += 1 |
6025 return count |
6026 return count |
6026 |
6027 |
6027 def getOpenEditorsForSession(self): |
6028 def getOpenEditorsForSession(self): |
6028 """ |
6029 """ |
6056 |
6057 |
6057 @param fn filename of editor to be saved (string) |
6058 @param fn filename of editor to be saved (string) |
6058 @return flag indicating success (boolean) |
6059 @return flag indicating success (boolean) |
6059 """ |
6060 """ |
6060 for editor in self.editors: |
6061 for editor in self.editors: |
6061 if Utilities.samepath(fn, editor.getFileName()): |
6062 if FileSystemUtilities.samepath(fn, editor.getFileName()): |
6062 break |
6063 break |
6063 else: |
6064 else: |
6064 return True |
6065 return True |
6065 |
6066 |
6066 if not editor.isModified(): |
6067 if not editor.isModified(): |
6234 |
6235 |
6235 for idx, rs in enumerate(self.recent, start=1): |
6236 for idx, rs in enumerate(self.recent, start=1): |
6236 formatStr = "&{0:d}. {1}" if idx < 10 else "{0:d}. {1}" |
6237 formatStr = "&{0:d}. {1}" if idx < 10 else "{0:d}. {1}" |
6237 act = self.recentMenu.addAction( |
6238 act = self.recentMenu.addAction( |
6238 formatStr.format( |
6239 formatStr.format( |
6239 idx, Utilities.compactPath(rs, self.ui.maxMenuFilePathLen) |
6240 idx, FileSystemUtilities.compactPath(rs, self.ui.maxMenuFilePathLen) |
6240 ) |
6241 ) |
6241 ) |
6242 ) |
6242 act.setData(rs) |
6243 act.setData(rs) |
6243 act.setEnabled(pathlib.Path(rs).exists()) |
6244 act.setEnabled(pathlib.Path(rs).exists()) |
6244 |
6245 |
6270 """ |
6271 """ |
6271 self.bookmarkedMenu.clear() |
6272 self.bookmarkedMenu.clear() |
6272 |
6273 |
6273 for rp in self.bookmarked: |
6274 for rp in self.bookmarked: |
6274 act = self.bookmarkedMenu.addAction( |
6275 act = self.bookmarkedMenu.addAction( |
6275 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen) |
6276 FileSystemUtilities.compactPath(rp, self.ui.maxMenuFilePathLen) |
6276 ) |
6277 ) |
6277 act.setData(rp) |
6278 act.setData(rp) |
6278 act.setEnabled(pathlib.Path(rp).exists()) |
6279 act.setEnabled(pathlib.Path(rp).exists()) |
6279 |
6280 |
6280 if len(self.bookmarked): |
6281 if len(self.bookmarked): |
7031 editor = self.getOpenEditor(filename) |
7032 editor = self.getOpenEditor(filename) |
7032 for bookmark in editor.getBookmarks(): |
7033 for bookmark in editor.getBookmarks(): |
7033 bmSuffix = " : {0:d}".format(bookmark) |
7034 bmSuffix = " : {0:d}".format(bookmark) |
7034 act = self.bookmarksMenu.addAction( |
7035 act = self.bookmarksMenu.addAction( |
7035 "{0}{1}".format( |
7036 "{0}{1}".format( |
7036 Utilities.compactPath( |
7037 FileSystemUtilities.compactPath( |
7037 filename, self.ui.maxMenuFilePathLen - len(bmSuffix) |
7038 filename, self.ui.maxMenuFilePathLen - len(bmSuffix) |
7038 ), |
7039 ), |
7039 bmSuffix, |
7040 bmSuffix, |
7040 ) |
7041 ) |
7041 ) |
7042 ) |
7851 # check, if there is an active project and return its path |
7852 # check, if there is an active project and return its path |
7852 elif ericApp().getObject("Project").isOpen(): |
7853 elif ericApp().getObject("Project").isOpen(): |
7853 return ericApp().getObject("Project").ppath |
7854 return ericApp().getObject("Project").ppath |
7854 |
7855 |
7855 else: |
7856 else: |
7856 return Preferences.getMultiProject("Workspace") or Utilities.getHomeDir() |
7857 return Preferences.getMultiProject("Workspace") or OSUtilities.getHomeDir() |
7857 |
7858 |
7858 def _getOpenFileFilter(self): |
7859 def _getOpenFileFilter(self): |
7859 """ |
7860 """ |
7860 Protected method to return the active filename filter for a file open |
7861 Protected method to return the active filename filter for a file open |
7861 dialog. |
7862 dialog. |