QScintilla/EditorAssembly.py

Mon, 09 Jan 2017 18:13:40 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 09 Jan 2017 18:13:40 +0100
changeset 5408
b67e07566aa1
parent 5394
b2c6179184f6
child 6048
82ad8ec9548c
permissions
-rw-r--r--

Fix for the new editor button widget on Windows.

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
5389
9b1c800daff3 Updated copyright for 2017.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4891
diff changeset
3 # Copyright (c) 2011 - 2017 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3057
diff changeset
11 from __future__ import unicode_literals
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
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
13 from PyQt5.QtCore import QTimer
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
14 from PyQt5.QtWidgets import QWidget, QGridLayout, QComboBox
1358
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 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
21 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
22 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
23 """
4891
d6e8171d2c02 Fixed an issue causing a crash with latest PyQt5 (5.6).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
24 def __init__(self, dbs, fn="", vm=None, filetype="", editor=None,
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
25 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
26 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @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
30 @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
31 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
32 @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
33 (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
34 @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
35 @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
36 @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
37 """
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
38 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
39
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 = QGridLayout(self)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 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
42 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
43
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
44 from .EditorButtonsWidget import EditorButtonsWidget
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
45 from .Editor import Editor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
46
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
47 self.__editor = Editor(dbs, fn, vm, filetype, editor, tv)
5408
b67e07566aa1 Fix for the new editor button widget on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
48 self.__buttonsWidget = EditorButtonsWidget(self.__editor, self)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 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
50 self.__membersCombo = QComboBox()
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
52 self.__layout.addWidget(self.__buttonsWidget, 1, 0, -1, 1)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
53 self.__layout.addWidget(self.__globalsCombo, 0, 1)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
54 self.__layout.addWidget(self.__membersCombo, 0, 2)
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
55 self.__layout.addWidget(self.__editor, 1, 1, 1, -1)
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.__module = None
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 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
60 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
61 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
62
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 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
64 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
65 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
66 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
67 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
68 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
69
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
70 self.__selectedGlobal = ""
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
71 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
72 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
73 self.__membersBoundaries = {}
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
74
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 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
76
1421
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
77 def shutdownTimer(self):
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
78 """
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
79 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
80 """
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
81 self.__parseTimer.stop()
8fead6686d1c Fixed an issue related to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1358
diff changeset
82 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
83 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
84 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
85
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 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
87 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 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
89
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @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
91 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 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
93
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
94 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
95 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
96 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
97 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
98
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @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
100 @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
101 (boolean)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 # 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
104 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
105 if lineno is not None:
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
106 if moveCursor:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
107 txt = self.__editor.text(lineno - 1).rstrip()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
108 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
109 self.__editor.gotoLine(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
110 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
111 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
112
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
113 # 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124 # 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
125 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
126 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
127 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
128 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
129 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
130 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
131 "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
132 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
133 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
134 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
135 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
136 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
137 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
138 memberIndex += 1
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
139 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
140 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
141 else:
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
142 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
143
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 # step 2.1: add class methods
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 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
164
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
165 # 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
166 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
167 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
168 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
169 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
170 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
171 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
172 "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
173 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
174 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
175 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
176 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
177 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
178 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
179
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
180 # 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
189 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
190 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 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
192
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 @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
194 @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
195 (boolean)
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 lineno = self.__membersCombo.itemData(index)
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
198 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
199 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
200 pos = len(txt.replace(txt.strip(), ""))
1897
4c89af5a756f Little improvement to the editor assembly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1807
diff changeset
201 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
202 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
203
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 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
205 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 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
207 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 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
209 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
210
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 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
212 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
213 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
214 combo.
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
216 from Utilities.ModuleParser import Module, getTypeFromTypeName
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
217
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 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
220 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
221 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
222 if src:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 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
224 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
225 fn = ""
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 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
227 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
228
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
229 # remember the current selections
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
230 self.__selectedGlobal = self.__globalsCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
231 self.__selectedMember = self.__membersCombo.currentText()
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
232
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 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
234 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
235 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
236 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
237
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 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
239 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
240
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
241 # 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
252 # 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
253 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 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
255 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
256 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
257 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
258 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
259 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
268 # 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
269 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 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
271 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
272 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
273 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
274 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
275 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283
1609
b7717f065282 Added the forgotten code to handle Ruby modules to the EditorAssembly widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1567
diff changeset
284 # 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
285 items = {}
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 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
287 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
288 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
289 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
290 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
291 "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
292 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 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
294 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
295 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
296 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
297 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
298
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
299 # 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
300 # text cursor
1567
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
301 index = self.__globalsCombo.findText(self.__selectedGlobal)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
302 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
303 self.__globalsCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
304 self.__globalsActivated(index, moveCursor=False)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
305 index = self.__membersCombo.findText(self.__selectedMember)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
306 if index != -1:
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
307 self.__membersCombo.setCurrentIndex(index)
d03369218b6d Fixed the editor combo box navigation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
308 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
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 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
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 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
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 @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
315 """
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 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
317
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 # 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
319 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
320 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
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328
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 # 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 self.__membersActivated(index, moveCursor=False)

eric ide

mercurial