QScintilla/EditorAssembly.py

Sun, 13 Oct 2013 12:21:37 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 13 Oct 2013 12:21:37 +0200
changeset 3011
18292228c724
parent 2768
eab35f6e709f
child 3057
10516539f238
child 3160
209a07d7e401
permissions
-rw-r--r--

Continued to shorten the code lines to max. 79 characters.

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
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1897
diff changeset
3 # Copyright (c) 2011 - 2013 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
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt4.QtCore import QTimer
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtGui import QWidget, QGridLayout, QComboBox
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import UI.PixmapCache
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 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
18 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
19 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
20 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
21 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
22 def __init__(self, dbs, fn=None, vm=None, filetype="", editor=None,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
23 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
24 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param dbs reference to the debug server object
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param fn name of the file to be opened (string). If it is None,
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
29 a new (empty) editor is opened
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
30 @param vm reference to the view manager object
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
31 (ViewManager.ViewManager)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param filetype type of the source file (string)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param editor reference to an Editor object, if this is a cloned view
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param tv reference to the task viewer object
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 super().__init__()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 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
39 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
40 self.__layout.setSpacing(1)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__globalsCombo = QComboBox()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__membersCombo = QComboBox()
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
44 from .Editor import Editor
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__layout.addWidget(self.__globalsCombo, 0, 0)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__layout.addWidget(self.__membersCombo, 0, 1)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__layout.addWidget(self.__editor, 1, 0, 1, -1)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 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
52
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__globalsCombo.activated[int].connect(self.__globalsActivated)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__membersCombo.activated[int].connect(self.__membersActivated)
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
55 self.__editor.cursorLineChanged.connect(self.__editorCursorLineChanged)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 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
58 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
59 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
60 self.__parseTimer.timeout.connect(self.__parseEditor)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 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
62 self.__editor.refreshed.connect(self.__resetParseTimer)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
64 self.__selectedGlobal = ""
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
65 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
66 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
67 self.__membersBoundaries = {}
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
68
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 QTimer.singleShot(0, self.__parseEditor)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
71 def shutdownTimer(self):
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
72 """
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
73 Public method to stop and disconnect the timer.
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
74 """
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
75 self.__parseTimer.stop()
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
76 self.__parseTimer.timeout.disconnect(self.__parseEditor)
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
77 self.__editor.textChanged.disconnect(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
78 self.__editor.refreshed.disconnect(self.__resetParseTimer)
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
79
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 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
81 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Public method to get the reference to the editor widget.
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @return reference to the editor widget (Editor)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 return self.__editor
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
88 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
89 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
90 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
91 populate the members combo box.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @param index index of the selected entry (integer)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
94 @keyparam moveCursor flag indicating to move the editor cursor
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
95 (boolean)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 # 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
98 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
99 if lineno is not None:
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
100 if moveCursor:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
101 txt = self.__editor.text(lineno - 1).rstrip()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
102 pos = len(txt.replace(txt.strip(), ""))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
103 self.__editor.gotoLine(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
104 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
105 self.__editor.setFocus()
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
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
107 # 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 # step 2.0: add module classes
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
119 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
120 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
121 if cl.isPrivate():
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
122 icon = UI.PixmapCache.getIcon("class_private.png")
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
123 elif cl.isProtected():
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
124 icon = UI.PixmapCache.getIcon(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
125 "class_protected.png")
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
126 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
127 icon = UI.PixmapCache.getIcon("class.png")
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
128 items[cl.name] = (icon, cl.lineno, cl.endlineno)
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
129 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
130 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
131 self.__membersCombo.addItem(itm[0], key, itm[1])
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
132 memberIndex += 1
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
133 self.__membersBoundaries[(itm[1], itm[2])] = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
134 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
135 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
136 return
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
137
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
138 # step 2.1: add class methods
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
139 from Utilities.ModuleParser import Function
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
140 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
141 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
142 if meth.modifier == Function.Static:
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
143 icon = UI.PixmapCache.getIcon("method_static.png")
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
144 elif meth.modifier == Function.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
145 icon = UI.PixmapCache.getIcon("method_class.png")
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
146 elif meth.isPrivate():
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
147 icon = UI.PixmapCache.getIcon("method_private.png")
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
148 elif meth.isProtected():
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
149 icon = UI.PixmapCache.getIcon("method_protected.png")
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
150 else:
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
151 icon = UI.PixmapCache.getIcon("method.png")
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
152 items[meth.name] = (icon, meth.lineno, meth.endlineno)
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
153 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
154 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
155 self.__membersCombo.addItem(itm[0], key, itm[1])
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
156 memberIndex += 1
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
157 self.__membersBoundaries[(itm[1], itm[2])] = memberIndex
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
158
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
159 # step 2.2: add class instance attributes
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
160 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
161 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
162 if attr.isPrivate():
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
163 icon = UI.PixmapCache.getIcon("attribute_private.png")
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
164 elif attr.isProtected():
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
165 icon = UI.PixmapCache.getIcon(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
166 "attribute_protected.png")
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
167 else:
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
168 icon = UI.PixmapCache.getIcon("attribute.png")
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
169 items[attr.name] = (icon, attr.lineno)
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
170 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
171 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
172 self.__membersCombo.addItem(itm[0], key, itm[1])
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
173
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
174 # step 2.3: add class attributes
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
175 items = {}
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
176 icon = UI.PixmapCache.getIcon("attribute_class.png")
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
177 for glob in entry.globals.values():
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
178 items[glob.name] = (icon, glob.lineno)
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
179 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
180 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
181 self.__membersCombo.addItem(itm[0], key, itm[1])
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
183 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
184 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 Private method to jump to the line of the selected members entry.
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @param index index of the selected entry (integer)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
188 @keyparam moveCursor flag indicating to move the editor cursor
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
189 (boolean)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 lineno = self.__membersCombo.itemData(index)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
192 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
193 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
194 pos = len(txt.replace(txt.strip(), ""))
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
195 self.__editor.gotoLine(lineno, pos if pos == 0 else pos + 1, True)
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
196 self.__editor.setFocus()
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 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
199 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 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
201 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 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
203 self.__parseTimer.start()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 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
206 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
207 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
208 combo.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
210 from Utilities.ModuleParser import Module, getTypeFromTypeName
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
211
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 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
213 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
214 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
215 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
216 if src:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 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
218 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
219 fn = ""
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 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
221 self.__module.scan(src)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
223 # remember the current selections
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
224 self.__selectedGlobal = self.__globalsCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
225 self.__selectedMember = self.__membersCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
226
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 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
228 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
229 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
230 self.__membersBoundaries = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 self.__globalsCombo.addItem("")
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
233 index = 0
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
235 # step 1: add modules
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
236 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
237 for module in self.__module.modules.values():
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
238 items[module.name] = (UI.PixmapCache.getIcon("module.png"),
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
239 module.lineno, module.endlineno)
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
240 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
241 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
242 self.__globalsCombo.addItem(itm[0], key, itm[1])
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
243 index += 1
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
244 self.__globalsBoundaries[(itm[1], itm[2])] = 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
245
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
246 # step 2: add classes
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
247 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 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
249 if cl.isPrivate():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 icon = UI.PixmapCache.getIcon("class_private.png")
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 elif cl.isProtected():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 icon = UI.PixmapCache.getIcon("class_protected.png")
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 icon = UI.PixmapCache.getIcon("class.png")
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
255 items[cl.name] = (icon, cl.lineno, cl.endlineno)
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
256 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
257 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
258 self.__globalsCombo.addItem(itm[0], key, itm[1])
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
259 index += 1
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
260 self.__globalsBoundaries[(itm[1], itm[2])] = index
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
262 # step 3: add functions
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
263 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 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
265 if func.isPrivate():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 icon = UI.PixmapCache.getIcon("method_private.png")
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 elif func.isProtected():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 icon = UI.PixmapCache.getIcon("method_protected.png")
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 icon = UI.PixmapCache.getIcon("method.png")
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
271 items[func.name] = (icon, func.lineno, func.endlineno)
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
272 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
273 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
274 self.__globalsCombo.addItem(itm[0], key, itm[1])
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
275 index += 1
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
276 self.__globalsBoundaries[(itm[1], itm[2])] = index
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
278 # step 4: add attributes
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
279 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 for glob in self.__module.globals.values():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 if glob.isPrivate():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 icon = UI.PixmapCache.getIcon("attribute_private.png")
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 elif glob.isProtected():
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
284 icon = UI.PixmapCache.getIcon(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
285 "attribute_protected.png")
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 icon = UI.PixmapCache.getIcon("attribute.png")
1667
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
288 items[glob.name] = (icon, glob.lineno)
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
289 for key in sorted(items.keys()):
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
290 itm = items[key]
02ad912c8645 Fixed an issue in the editor assembly causing it to throw an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1609
diff changeset
291 self.__globalsCombo.addItem(itm[0], key, itm[1])
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
292
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
293 # 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
294 # text cursor
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
295 index = self.__globalsCombo.findText(self.__selectedGlobal)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
296 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
297 self.__globalsCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
298 self.__globalsActivated(index, moveCursor=False)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
299 index = self.__membersCombo.findText(self.__selectedMember)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
300 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
301 self.__membersCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
302 self.__membersActivated(index, moveCursor=False)
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
303
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
304 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
305 """
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
306 Private slot handling a line change of the cursor of the editor.
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
307
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
308 @param lineno line number of the cursor (integer)
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
309 """
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
310 lineno += 1 # cursor position is zero based, code info one based
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
311
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
312 # step 1: search in the globals
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
313 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
314 if upper == -1:
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
315 upper = 1000000 # it is the last line
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
316 if lower <= lineno <= upper:
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
317 break
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
318 else:
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
319 index = 0
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
320 self.__globalsCombo.setCurrentIndex(index)
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
321 self.__globalsActivated(index, moveCursor=False)
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
322
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
323 # step 2: search in members
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
324 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
325 if upper == -1:
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
326 upper = 1000000 # it is the last line
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
327 if lower <= lineno <= upper:
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
328 break
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
329 else:
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
330 index = 0
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
331 self.__membersCombo.setCurrentIndex(index)
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
332 self.__membersActivated(index, moveCursor=False)

eric ide

mercurial