src/eric7/QScintilla/Editor.py

branch
eric7
changeset 10473
f45fd45cb11d
parent 10465
56a3364150b1
child 10474
c18ca679259d
equal deleted inserted replaced
10472:3aecfec97f7c 10473:f45fd45cb11d
9 9
10 import bisect 10 import bisect
11 import collections 11 import collections
12 import contextlib 12 import contextlib
13 import difflib 13 import difflib
14 import enum
14 import os 15 import os
15 import pathlib 16 import pathlib
16 import re 17 import re
17 18
18 import editorconfig 19 import editorconfig
65 ReferencesListID = 3 66 ReferencesListID = 3
66 67
67 ReferenceItem = collections.namedtuple( # noqa: U200 68 ReferenceItem = collections.namedtuple( # noqa: U200
68 "ReferenceItem", ["modulePath", "codeLine", "line", "column"] 69 "ReferenceItem", ["modulePath", "codeLine", "line", "column"]
69 ) 70 )
71
72
73 class EditorIconId(enum.IntEnum):
74 """
75 Class defining the completion icon IDs.
76 """
77
78 Class = 1
79 ClassProtected = 2
80 ClassPrivate = 3
81 Method = 4
82 MethodProtected = 5
83 MethodPrivate = 6
84 Attribute = 7
85 AttributeProtected = 8
86 AttributePrivate = 9
87 Enum = 10
88 Keywords = 11
89 Module = 12
90
91 FromDocument = 99
92 TemplateImage = 100
70 93
71 94
72 class Editor(QsciScintillaCompat): 95 class Editor(QsciScintillaCompat):
73 """ 96 """
74 Class implementing the editor component of the eric IDE. 97 Class implementing the editor component of the eric IDE.
151 WarningPython = 2 174 WarningPython = 2
152 WarningStyle = 3 175 WarningStyle = 3
153 WarningInfo = 4 176 WarningInfo = 4
154 WarningError = 5 177 WarningError = 5
155 178
156 # TODO: convert to an enum.IntEnum (also in Assistant plugin)
157 # Autocompletion icon definitions
158 ClassID = 1
159 ClassProtectedID = 2
160 ClassPrivateID = 3
161 MethodID = 4
162 MethodProtectedID = 5
163 MethodPrivateID = 6
164 AttributeID = 7
165 AttributeProtectedID = 8
166 AttributePrivateID = 9
167 EnumID = 10
168 KeywordsID = 11
169 ModuleID = 12
170
171 FromDocumentID = 99
172
173 TemplateImageID = 100
174
175 # Cooperation related definitions 179 # Cooperation related definitions
176 Separator = "@@@" 180 Separator = "@@@"
177 181
178 StartEditToken = "START_EDIT" 182 StartEditToken = "START_EDIT"
179 EndEditToken = "END_EDIT" 183 EndEditToken = "END_EDIT"
655 Private method to register images for autocompletion lists. 659 Private method to register images for autocompletion lists.
656 """ 660 """
657 # finale size of the completion images 661 # finale size of the completion images
658 imageSize = QSize(22, 22) 662 imageSize = QSize(22, 22)
659 663
660 self.registerImage(self.ClassID, EricPixmapCache.getPixmap("class", imageSize))
661 self.registerImage( 664 self.registerImage(
662 self.ClassProtectedID, 665 EditorIconId.Class,
666 EricPixmapCache.getPixmap("class", imageSize),
667 )
668 self.registerImage(
669 EditorIconId.ClassProtected,
663 EricPixmapCache.getPixmap("class_protected", imageSize), 670 EricPixmapCache.getPixmap("class_protected", imageSize),
664 ) 671 )
665 self.registerImage( 672 self.registerImage(
666 self.ClassPrivateID, EricPixmapCache.getPixmap("class_private", imageSize) 673 EditorIconId.ClassPrivate,
674 EricPixmapCache.getPixmap("class_private", imageSize),
667 ) 675 )
668 self.registerImage( 676 self.registerImage(
669 self.MethodID, EricPixmapCache.getPixmap("method", imageSize) 677 EditorIconId.Method,
678 EricPixmapCache.getPixmap("method", imageSize),
670 ) 679 )
671 self.registerImage( 680 self.registerImage(
672 self.MethodProtectedID, 681 EditorIconId.MethodProtected,
673 EricPixmapCache.getPixmap("method_protected", imageSize), 682 EricPixmapCache.getPixmap("method_protected", imageSize),
674 ) 683 )
675 self.registerImage( 684 self.registerImage(
676 self.MethodPrivateID, EricPixmapCache.getPixmap("method_private", imageSize) 685 EditorIconId.MethodPrivate,
686 EricPixmapCache.getPixmap("method_private", imageSize),
677 ) 687 )
678 self.registerImage( 688 self.registerImage(
679 self.AttributeID, EricPixmapCache.getPixmap("attribute", imageSize) 689 EditorIconId.Attribute,
690 EricPixmapCache.getPixmap("attribute", imageSize),
680 ) 691 )
681 self.registerImage( 692 self.registerImage(
682 self.AttributeProtectedID, 693 EditorIconId.AttributeProtected,
683 EricPixmapCache.getPixmap("attribute_protected", imageSize), 694 EricPixmapCache.getPixmap("attribute_protected", imageSize),
684 ) 695 )
685 self.registerImage( 696 self.registerImage(
686 self.AttributePrivateID, 697 EditorIconId.AttributePrivate,
687 EricPixmapCache.getPixmap("attribute_private", imageSize), 698 EricPixmapCache.getPixmap("attribute_private", imageSize),
688 ) 699 )
689 self.registerImage(self.EnumID, EricPixmapCache.getPixmap("enum", imageSize))
690 self.registerImage( 700 self.registerImage(
691 self.KeywordsID, EricPixmapCache.getPixmap("keywords", imageSize) 701 EditorIconId.Enum,
702 EricPixmapCache.getPixmap("enum", imageSize),
692 ) 703 )
693 self.registerImage( 704 self.registerImage(
694 self.ModuleID, EricPixmapCache.getPixmap("module", imageSize) 705 EditorIconId.Keywords,
695 ) 706 EricPixmapCache.getPixmap("keywords", imageSize),
696 707 )
697 self.registerImage( 708 self.registerImage(
698 self.FromDocumentID, EricPixmapCache.getPixmap("editor", imageSize) 709 EditorIconId.Module,
710 EricPixmapCache.getPixmap("module", imageSize),
699 ) 711 )
700 712
701 self.registerImage( 713 self.registerImage(
702 self.TemplateImageID, EricPixmapCache.getPixmap("templateViewer", imageSize) 714 EditorIconId.FromDocument,
715 EricPixmapCache.getPixmap("editor", imageSize),
716 )
717
718 self.registerImage(
719 EditorIconId.TemplateImage,
720 EricPixmapCache.getPixmap("templateViewer", imageSize),
703 ) 721 )
704 722
705 def addClone(self, editor): 723 def addClone(self, editor):
706 """ 724 """
707 Public method to add a clone to our list. 725 Public method to add a clone to our list.
8602 return 8620 return
8603 elif len(templateNames) > 1: 8621 elif len(templateNames) > 1:
8604 self.showUserList( 8622 self.showUserList(
8605 TemplateCompletionListID, 8623 TemplateCompletionListID,
8606 [ 8624 [
8607 "{0}?{1:d}".format(t, self.TemplateImageID) 8625 "{0}?{1:d}".format(t, EditorIconId.TemplateImage)
8608 for t in templateNames 8626 for t in templateNames
8609 ], 8627 ],
8610 ) 8628 )
8611 return 8629 return
8612 8630

eric ide

mercurial