src/eric7/QScintilla/EditorAssembly.py

Fri, 02 Aug 2024 14:35:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 02 Aug 2024 14:35:21 +0200
branch
eric7
changeset 10880
2d2dd2c638e8
parent 10849
78d338b6d89f
child 10907
c424150d2ac8
permissions
-rw-r--r--

Changed the logic to setup the initial size of the editor outline widget. Somehow the width of the splitter did not get set correctly in certain situations (see issue 567).

1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
10439
21c28b0f9e41 Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10180
diff changeset
3 # Copyright (c) 2011 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
7 Module implementing the editor assembly widget containing the navigation
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
8 combos and the editor widget.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
11 import contextlib
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
12
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
13 from PyQt6.QtCore import Qt, QTimer
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
14 from PyQt6.QtWidgets import QComboBox, QGridLayout, QSplitter, QWidget
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
9473
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
16 from eric7 import Preferences
3f23dbf37dbe Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9413
diff changeset
17 from eric7.EricGui import EricPixmapCache
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
18 from eric7.EricWidgets.EricApplication import ericApp
9482
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
19 from eric7.Utilities.ModuleParser import Function
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
20
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
21 from .Editor import Editor
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
22 from .EditorButtonsWidget import EditorButtonsWidget
a2bc06a54d9d Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9473
diff changeset
23 from .EditorOutline import EditorOutlineView
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
24
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class EditorAssembly(QWidget):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
28 Class implementing the editor assembly widget containing the navigation
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
29 combos and the editor widget.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
32 def __init__(self, dbs, fn="", vm=None, filetype="", editor=None, tv=None):
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
35
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @param dbs reference to the debug server object
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
37 @type DebugServer
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
38 @param fn name of the file to be opened. If it is None,
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
39 a new (empty) editor is opened.
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
40 @type str
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
41 @param vm reference to the view manager object
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
42 @type ViewManager.ViewManager
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
43 @param filetype type of the source file
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
44 @type str
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @param editor reference to an Editor object, if this is a cloned view
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
46 @type Editor
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @param tv reference to the task viewer object
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
48 @type TaskViewer
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8132
diff changeset
50 super().__init__()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
51
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__layout = QGridLayout(self)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__layout.setContentsMargins(0, 0, 0, 0)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__layout.setSpacing(1)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
55
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
56 self.__showNavigator = Preferences.getEditor("ShowSourceNavigator")
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
57 self.__showOutline = Preferences.getEditor("ShowSourceOutline")
10832
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
58 self.__outlineSortByOccurrence = Preferences.getEditor(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
59 "SourceOutlineListContentsByOccurrence"
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
60 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
61
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
62 self.__editor = Editor(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
63 dbs=dbs,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
64 fn=fn,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
65 vm=vm,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
66 filetype=filetype,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
67 editor=editor,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
68 tv=tv,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
69 assembly=self,
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
70 )
5408
b67e07566aa1 Fix for the new editor button widget on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
71 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__globalsCombo = QComboBox()
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
73 self.__globalsCombo.setDuplicatesEnabled(True)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__membersCombo = QComboBox()
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
75 self.__membersCombo.setDuplicatesEnabled(True)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
76 self.__sourceOutline = EditorOutlineView(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
77 self.__editor, populate=self.__showOutline
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
78 )
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
79 self.__editorSplitter = QSplitter(Qt.Orientation.Horizontal)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
80 self.__editorSplitter.setChildrenCollapsible(False)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
81 self.__editorSplitter.addWidget(self.__editor)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
82 self.__editorSplitter.addWidget(self.__sourceOutline)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
83
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
84 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
85 self.__layout.addWidget(self.__globalsCombo, 0, 1)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
86 self.__layout.addWidget(self.__membersCombo, 0, 2)
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
87 self.__layout.addWidget(self.__editorSplitter, 1, 1, 1, 2)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
88
7343
e0808393413f EditorAssembly: fixed an issue causing the assembly widget handling focus instead of the embedded editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7267
diff changeset
89 self.setFocusProxy(self.__editor)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
90
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__module = None
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
92
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
93 self.__aboutToBeClosedCalled = False
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.__parseTimer = QTimer(self)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__parseTimer.setSingleShot(True)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__parseTimer.setInterval(5 * 1000)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__editor.textChanged.connect(self.__resetParseTimer)
1807
9898a95461f1 Added a signal to the editor showing a refresh has happend and connected the editor assembly to it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1667
diff changeset
98 self.__editor.refreshed.connect(self.__resetParseTimer)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
99
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
100 self.__selectedGlobal = ""
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
101 self.__selectedMember = ""
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
102 self.__globalsBoundaries = {}
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
103 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
104
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
105 self.__activateOutline(self.__showNavigator and self.__showOutline)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
106 self.__activateCombos(self.__showNavigator and not self.__showOutline)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
107
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
108 ericApp().getObject("UserInterface").preferencesChanged.connect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
109 self.__preferencesChanged
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
110 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
111
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
112 def finishSetup(self):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
113 """
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
114 Public method to finish the setup of the assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
115 """
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
116 splitterWidth = (
10880
2d2dd2c638e8 Changed the logic to setup the initial size of the editor outline widget. Somehow the width of the splitter did not get set correctly in certain situations (see issue 567).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10849
diff changeset
117 self.parent().width() - self.__editorSplitter.handleWidth()
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
118 )
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
119 outlineWidth = Preferences.getEditor("SourceOutlineWidth")
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
120 self.__editorSplitter.setSizes([splitterWidth - outlineWidth, outlineWidth])
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
121
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
122 def aboutToBeClosed(self):
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
123 """
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
124 Public method to stop and disconnect the timer and disconnect some signals.
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
125 """
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
126 self.__parseTimer.stop()
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
127 if not self.__aboutToBeClosedCalled:
6317
e9ec47d52ff2 EditorAssembly: added a guard against shutdownTimer() being called multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6297
diff changeset
128 self.__editor.textChanged.disconnect(self.__resetParseTimer)
e9ec47d52ff2 EditorAssembly: added a guard against shutdownTimer() being called multiple times.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6297
diff changeset
129 self.__editor.refreshed.disconnect(self.__resetParseTimer)
9689
b18ad1f984b1 Corrected change 3a240d3f3b8c.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9688
diff changeset
130 ericApp().getObject("UserInterface").preferencesChanged.disconnect(
b18ad1f984b1 Corrected change 3a240d3f3b8c.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9688
diff changeset
131 self.__preferencesChanged
b18ad1f984b1 Corrected change 3a240d3f3b8c.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9688
diff changeset
132 )
9687
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
133
3a240d3f3b8c Fixed an issue caused by a still existing signal slot connection in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9653
diff changeset
134 self.__aboutToBeClosedCalled = True
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
135
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 def getEditor(self):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 Public method to get the reference to the editor widget.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
139
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
140 @return reference to the editor widget
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
141 @rtype Editor
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 return self.__editor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
144
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
145 def __preferencesChanged(self):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
146 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
147 Private slot handling a change of preferences.
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
148 """
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
149 showNavigator = Preferences.getEditor("ShowSourceNavigator")
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
150 showOutline = Preferences.getEditor("ShowSourceOutline")
10832
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
151 outlineSortByOccurrence = Preferences.getEditor(
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
152 "SourceOutlineListContentsByOccurrence"
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
153 )
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
154
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
155 if self.__outlineSortByOccurrence != outlineSortByOccurrence:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
156 self.__outlineSortByOccurrence = outlineSortByOccurrence
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
157 if self.__showOutline:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
158 self.__sourceOutline.repopulate()
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10439
diff changeset
159
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
160 if showOutline != self.__showOutline or showNavigator != self.__showNavigator:
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
161 self.__showOutline = showOutline
9567
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
162 self.__showNavigator = showNavigator
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
163 self.__activateOutline(self.__showNavigator and self.__showOutline)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9482
diff changeset
164 self.__activateCombos(self.__showNavigator and not self.__showOutline)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
165
10849
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
166 self.finishSetup()
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 10832
diff changeset
167
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
168 #######################################################################
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
169 ## Methods dealing with the navigation combos below
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
170 #######################################################################
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
171
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
172 def __activateCombos(self, activate):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
173 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
174 Private slot to activate the navigation combo boxes.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
175
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
176 @param activate flag indicating to activate the combo boxes
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
177 @type bool
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
178 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
179 self.__globalsCombo.setVisible(activate)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
180 self.__membersCombo.setVisible(activate)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
181 if activate:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
182 self.__globalsCombo.activated[int].connect(self.__globalsActivated)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
183 self.__membersCombo.activated[int].connect(self.__membersActivated)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
184 self.__editor.cursorLineChanged.connect(self.__editorCursorLineChanged)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
185 self.__parseTimer.timeout.connect(self.__parseEditor)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
186
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
187 self.__parseEditor()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
188
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
189 line, _ = self.__editor.getCursorPosition()
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
190 self.__editorCursorLineChanged(line)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
191 else:
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
192 with contextlib.suppress(TypeError):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
193 self.__globalsCombo.activated[int].disconnect(self.__globalsActivated)
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
194 self.__membersCombo.activated[int].disconnect(self.__membersActivated)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
195 self.__editor.cursorLineChanged.disconnect(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
196 self.__editorCursorLineChanged
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
197 )
9688
f3817c476a62 Corrected another glitch in EditorAssembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9687
diff changeset
198 with contextlib.suppress(TypeError):
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
199 self.__parseTimer.timeout.disconnect(self.__parseEditor)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
200
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
201 self.__globalsCombo.clear()
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
202 self.__membersCombo.clear()
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
203 self.__globalsBoundaries = {}
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
204 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
205
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
206 def __globalsActivated(self, index, moveCursor=True):
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
208 Private method to jump to the line of the selected global entry and to
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
209 populate the members combo box.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
210
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
211 @param index index of the selected entry
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
212 @type int
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
213 @param moveCursor flag indicating to move the editor cursor
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
214 @type bool
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 # step 1: go to the line of the selected entry
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 lineno = self.__globalsCombo.itemData(index)
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
218 if lineno is not None:
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219 if moveCursor:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
220 txt = self.__editor.text(lineno - 1).rstrip()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
221 pos = len(txt.replace(txt.strip(), ""))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
222 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1, True)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
223 self.__editor.setFocus()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
224
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
225 # step 2: populate the members combo, if the entry is a class
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
226 self.__membersCombo.clear()
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
227 self.__membersBoundaries = {}
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
228 self.__membersCombo.addItem("")
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
229 memberIndex = 0
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
230 entryName = self.__globalsCombo.itemText(index)
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
231 if self.__module:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
232 if entryName in self.__module.classes:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
233 entry = self.__module.classes[entryName]
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
234 elif entryName in self.__module.modules:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
235 entry = self.__module.modules[entryName]
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
236 # step 2.0: add module classes
8089
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
237 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
238 for cl in entry.classes.values():
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
239 if cl.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
240 icon = EricPixmapCache.getIcon("class_private")
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
241 elif cl.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
242 icon = EricPixmapCache.getIcon("class_protected")
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
243 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
244 icon = EricPixmapCache.getIcon("class")
8089
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
245 items.append((icon, cl.name, cl.lineno, cl.endlineno))
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
246 for itm in sorted(items, key=lambda x: (x[1], x[2])):
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
247 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
248 memberIndex += 1
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
249 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
250 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
251 return
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
252
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
253 # step 2.1: add class methods
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
254 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
255 for meth in entry.methods.values():
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
256 if meth.modifier == Function.Static:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
257 icon = EricPixmapCache.getIcon("method_static")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
258 elif meth.modifier == Function.Class:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
259 icon = EricPixmapCache.getIcon("method_class")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
260 elif meth.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
261 icon = EricPixmapCache.getIcon("method_private")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
262 elif meth.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
263 icon = EricPixmapCache.getIcon("method_protected")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
264 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
265 icon = EricPixmapCache.getIcon("method")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
266 items.append((icon, meth.name, meth.lineno, meth.endlineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
267 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
268 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
269 memberIndex += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
270 self.__membersBoundaries[(itm[2], itm[3])] = memberIndex
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
271
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
272 # step 2.2: add class instance attributes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
273 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
274 for attr in entry.attributes.values():
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
275 if attr.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
276 icon = EricPixmapCache.getIcon("attribute_private")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
277 elif attr.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
278 icon = EricPixmapCache.getIcon("attribute_protected")
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
279 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
280 icon = EricPixmapCache.getIcon("attribute")
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
281 items.append((icon, attr.name, attr.lineno))
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
282 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
283 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
284
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
285 # step 2.3: add class attributes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
286 items = []
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
287 icon = EricPixmapCache.getIcon("attribute_class")
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
288 for globalVar in entry.globals.values():
8089
e43bf8d7baf9 EditorAssembly: fixed a few issues not detected by the earlier tests performed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8088
diff changeset
289 items.append((icon, globalVar.name, globalVar.lineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
290 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
291 self.__membersCombo.addItem(itm[0], itm[1], itm[2])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
292
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
293 def __membersActivated(self, index, moveCursor=True):
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 Private method to jump to the line of the selected members entry.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
296
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
297 @param index index of the selected entry
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
298 @type int
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
299 @param moveCursor flag indicating to move the editor cursor
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
300 @type bool
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 lineno = self.__membersCombo.itemData(index)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
303 if lineno is not None and moveCursor:
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
304 txt = self.__editor.text(lineno - 1).rstrip()
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
305 pos = len(txt.replace(txt.strip(), ""))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
306 self.__editor.gotoLine(
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
307 lineno, pos if pos == 0 else pos + 1, firstVisible=True, expand=True
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
308 )
1439
953d3f95ee4d Fixed an issue in the editor assembly widget causing it to produce a trackeback.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1421
diff changeset
309 self.__editor.setFocus()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
310
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 def __resetParseTimer(self):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 Private slot to reset the parse timer.
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 self.__parseTimer.stop()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 self.__parseTimer.start()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
317
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 def __parseEditor(self):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
320 Private method to parse the editor source and repopulate the globals
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
321 combo.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 """
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
323 from eric7.Utilities.ModuleParser import Module, getTypeFromTypeName
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
324
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 self.__module = None
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 sourceType = getTypeFromTypeName(self.__editor.determineFileType())
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 if sourceType != -1:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 src = self.__editor.text()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 if src:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 fn = self.__editor.getFileName()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 if fn is None:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 fn = ""
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 self.__module = Module("", fn, sourceType)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 self.__module.scan(src)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
335
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
336 # remember the current selections
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
337 self.__selectedGlobal = self.__globalsCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
338 self.__selectedMember = self.__membersCombo.currentText()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
339
9691
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
340 self.__globalsCombo.hidePopup()
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
341 self.__membersCombo.hidePopup()
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.__globalsCombo.clear()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 self.__membersCombo.clear()
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
344 self.__globalsBoundaries = {}
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
345 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
346
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.__globalsCombo.addItem("")
10180
3a595df36c9a Simplified some code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9691
diff changeset
348 index = 0 # noqa: Y113
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
349
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
350 # step 1: add modules
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
351 items = []
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
352 for module in self.__module.modules.values():
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
353 items.append(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
354 (
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
355 EricPixmapCache.getIcon("module"),
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
356 module.name,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
357 module.lineno,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
358 module.endlineno,
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
359 )
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
360 )
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
361 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
362 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
363 index += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
364 self.__globalsBoundaries[(itm[2], itm[3])] = index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
365
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
366 # step 2: add classes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
367 items = []
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 for cl in self.__module.classes.values():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 if cl.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
370 icon = EricPixmapCache.getIcon("class_private")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 elif cl.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
372 icon = EricPixmapCache.getIcon("class_protected")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
374 icon = EricPixmapCache.getIcon("class")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
375 items.append((icon, cl.name, cl.lineno, cl.endlineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
376 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
377 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
378 index += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
379 self.__globalsBoundaries[(itm[2], itm[3])] = index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
380
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
381 # step 3: add functions
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
382 items = []
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 for func in self.__module.functions.values():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 if func.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
385 icon = EricPixmapCache.getIcon("method_private")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 elif func.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
387 icon = EricPixmapCache.getIcon("method_protected")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
389 icon = EricPixmapCache.getIcon("method")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
390 items.append((icon, func.name, func.lineno, func.endlineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
391 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
392 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
393 index += 1
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
394 self.__globalsBoundaries[(itm[2], itm[3])] = index
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
395
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
396 # step 4: add attributes
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
397 items = []
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
398 for globalValue in self.__module.globals.values():
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
399 if globalValue.isPrivate():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
400 icon = EricPixmapCache.getIcon("attribute_private")
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
401 elif globalValue.isProtected():
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
402 icon = EricPixmapCache.getIcon("attribute_protected")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
404 icon = EricPixmapCache.getIcon("attribute")
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
405 items.append((icon, globalValue.name, globalValue.lineno))
8088
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
406 for itm in sorted(items, key=lambda x: (x[1], x[2])):
7c454b82b6ed EditorAssembly: changed code of the navigation selectors to allow duplicate entries (e.g. in case of conditionally defined functions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
407 self.__globalsCombo.addItem(itm[0], itm[1], itm[2])
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
408
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
409 # reset the currently selected entries without moving the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
410 # text cursor
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
411 index = self.__globalsCombo.findText(self.__selectedGlobal)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
412 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
413 self.__globalsCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
414 self.__globalsActivated(index, moveCursor=False)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
415 index = self.__membersCombo.findText(self.__selectedMember)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
416 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
417 self.__membersCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
418 self.__membersActivated(index, moveCursor=False)
7175
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
419 else:
9691
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
420 self.__globalsCombo.hidePopup()
12b8fe65c28c Fixed an issue causing the editor navigation selectors to malfunction, when the editor was parsed while a popup was open.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9689
diff changeset
421 self.__membersCombo.hidePopup()
7175
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
422 self.__globalsCombo.clear()
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
423 self.__membersCombo.clear()
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
424 self.__globalsBoundaries = {}
68f83a144355 EditorAssembly: fixed an issue causing the navigation combos not being populated for MicroPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
425 self.__membersBoundaries = {}
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
426
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
427 def __editorCursorLineChanged(self, lineno):
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
428 """
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
429 Private slot handling a line change of the cursor of the editor.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
430
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
431 @param lineno line number of the cursor
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
432 @type int
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
433 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
434 lineno += 1 # cursor position is zero based, code info one based
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
435
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
436 # step 1: search in the globals
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
437 indexFound = 0
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
438 for (lower, upper), index in self.__globalsBoundaries.items():
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
439 if upper == -1:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
440 upper = 1000000 # it is the last line
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
441 if lower <= lineno <= upper:
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
442 indexFound = index
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
443 break
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
444 self.__globalsCombo.setCurrentIndex(indexFound)
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
445 self.__globalsActivated(indexFound, moveCursor=False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
446
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
447 # step 2: search in members
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
448 indexFound = 0
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
449 for (lower, upper), index in self.__membersBoundaries.items():
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
450 if upper == -1:
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
451 upper = 1000000 # it is the last line
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
452 if lower <= lineno <= upper:
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
453 indexFound = index
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
454 break
6188
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
455 self.__membersCombo.setCurrentIndex(indexFound)
5a6ae3be31e6 Fixed some loop related coding issues detected by the extended code style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
456 self.__membersActivated(indexFound, moveCursor=False)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
457
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
458 #######################################################################
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
459 ## Methods dealing with the source outline below
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
460 #######################################################################
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
461
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
462 def __activateOutline(self, activate):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
463 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
464 Private slot to activate the source outline view.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
465
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
466 @param activate flag indicating to activate the source outline view
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
467 @type bool
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
468 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
469 self.__sourceOutline.setActive(activate)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
470
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
471 if activate:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
472 self.__sourceOutline.setVisible(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
473 self.__sourceOutline.isSupportedLanguage(self.__editor.getLanguage())
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
474 )
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
475
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
476 self.__parseTimer.timeout.connect(self.__sourceOutline.repopulate)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
477 self.__editor.languageChanged.connect(self.__editorChanged)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
478 self.__editor.editorRenamed.connect(self.__editorChanged)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
479 else:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
480 self.__sourceOutline.hide()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
481
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8220
diff changeset
482 with contextlib.suppress(TypeError):
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
483 self.__parseTimer.timeout.disconnect(self.__sourceOutline.repopulate)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
484 self.__editor.languageChanged.disconnect(self.__editorChanged)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
485 self.__editor.editorRenamed.disconnect(self.__editorChanged)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
486
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
487 def __editorChanged(self):
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
488 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
489 Private slot handling changes of the editor language or file name.
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
490 """
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
491 supported = self.__sourceOutline.isSupportedLanguage(
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
492 self.__editor.getLanguage()
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
493 )
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
494
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7685
diff changeset
495 self.__sourceOutline.setVisible(supported)

eric ide

mercurial