QScintilla/EditorAssembly.py

Mon, 08 Jul 2013 22:36:10 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 08 Jul 2013 22:36:10 +0200
branch
Py2 comp.
changeset 2791
a9577f248f04
parent 2525
8b507a9a2d40
parent 2768
eab35f6e709f
child 3057
10516539f238
permissions
-rw-r--r--

Merge with default branch.

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 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the editor assembly widget containing the navigation combos and
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 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
9 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
11 from __future__ import unicode_literals # __IGNORE_WARNING__
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
12
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 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
14 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
15
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 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
17
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 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
20 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing the editor assembly widget containing the navigation combos and
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 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
23 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, dbs, fn=None, vm=None, filetype="", editor=None, tv=None):
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 Constructor
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @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
29 @param fn name of the file to be opened (string). If it is None,
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 a new (empty) editor is opened
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param vm reference to the view manager object (ViewManager.ViewManager)
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 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
36 super(EditorAssembly, self).__init__()
1358
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 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 Private method to jump to the line of the selected global entry and to populate
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 the members combo box.
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)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
94 @keyparam moveCursor flag indicating to move the editor cursor (boolean)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 # 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
97 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
98 if lineno is not None:
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
99 if moveCursor:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
100 txt = self.__editor.text(lineno - 1).rstrip()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
101 pos = len(txt.replace(txt.strip(), ""))
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
102 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
103 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
104
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
105 # 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
106 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
107 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
108 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
109 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
110 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
111 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
112 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
113 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
114 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
115 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
116 # 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
117 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
118 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
119 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
120 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
121 elif cl.isProtected():
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_protected.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 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
124 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
125 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
126 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
127 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
128 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
129 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
130 self.__membersBoundaries[(itm[1], itm[2])] = 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
131 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
132 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
133
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
134 # step 2.1: add class methods
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154
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
155 # 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
156 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
157 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
158 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
159 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
160 elif attr.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
161 icon = UI.PixmapCache.getIcon("attribute_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
162 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
163 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
164 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
165 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
166 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
167 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
168
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
169 # 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
178 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
179 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 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
181
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 @param index index of the selected entry (integer)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
183 @keyparam moveCursor flag indicating to move the editor cursor (boolean)
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 lineno = self.__membersCombo.itemData(index)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
186 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
187 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
188 pos = len(txt.replace(txt.strip(), ""))
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
189 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
190 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
191
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 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
193 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 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
195 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 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
197 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
198
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 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
200 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 Private method to parse the editor source and repopulate the globals combo.
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
203 from Utilities.ModuleParser import Module, getTypeFromTypeName
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
204
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 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
206 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
207 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
208 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
209 if src:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 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
211 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
212 fn = ""
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 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
214 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
215
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
216 # remember the current selections
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
217 self.__selectedGlobal = self.__globalsCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
218 self.__selectedMember = self.__membersCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
219
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 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
221 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
222 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
223 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
224
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 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
226 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
227
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
228 # 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
239 # 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
240 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 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
242 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
243 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
244 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
245 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
246 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254
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 # 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
256 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 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
258 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
259 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
260 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
261 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
262 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 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
264 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
265 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
266 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
267 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
268 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
269 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
270
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
271 # 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
272 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 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
274 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
275 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
276 elif glob.isProtected():
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 icon = UI.PixmapCache.getIcon("attribute_protected.png")
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 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
280 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
281 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
282 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
283 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
284
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
285 # reset the currently selected entries without moving the text cursor
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
286 index = self.__globalsCombo.findText(self.__selectedGlobal)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
287 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
288 self.__globalsCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
289 self.__globalsActivated(index, moveCursor=False)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
290 index = self.__membersCombo.findText(self.__selectedMember)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
291 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
292 self.__membersCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
293 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
294
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
295 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
296 """
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
297 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
298
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
299 @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
300 """
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
301 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
302
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 # 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
304 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
305 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
306 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
307 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
308 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
309 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
310 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
311 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
312 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
313
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 # 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 self.__membersActivated(index, moveCursor=False)

eric ide

mercurial