src/eric7/QScintilla/TypingCompleters/CompleterBase.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
16 16
17 class CompleterBase(QObject): 17 class CompleterBase(QObject):
18 """ 18 """
19 Class implementing the base class for all completers. 19 Class implementing the base class for all completers.
20 """ 20 """
21
21 def __init__(self, editor, parent=None): 22 def __init__(self, editor, parent=None):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param editor reference to the editor object (QScintilla.Editor) 26 @param editor reference to the editor object (QScintilla.Editor)
26 @param parent reference to the parent object (QObject) 27 @param parent reference to the parent object (QObject)
27 If parent is None, we set the editor as the parent. 28 If parent is None, we set the editor as the parent.
28 """ 29 """
29 if parent is None: 30 if parent is None:
30 parent = editor 31 parent = editor
31 32
32 super().__init__(parent) 33 super().__init__(parent)
33 34
34 self.editor = editor 35 self.editor = editor
35 self.enabled = False 36 self.enabled = False
36 37
37 def setEnabled(self, enable): 38 def setEnabled(self, enable):
38 """ 39 """
39 Public slot to set the enabled state. 40 Public slot to set the enabled state.
40 41
41 @param enable flag indicating the new enabled state (boolean) 42 @param enable flag indicating the new enabled state (boolean)
42 """ 43 """
43 if enable: 44 if enable:
44 if not self.enabled: 45 if not self.enabled:
45 self.editor.SCN_CHARADDED.connect(self.charAdded) 46 self.editor.SCN_CHARADDED.connect(self.charAdded)
46 else: 47 else:
47 if self.enabled: 48 if self.enabled:
48 self.editor.SCN_CHARADDED.disconnect(self.charAdded) 49 self.editor.SCN_CHARADDED.disconnect(self.charAdded)
49 self.enabled = enable 50 self.enabled = enable
50 51
51 def isEnabled(self): 52 def isEnabled(self):
52 """ 53 """
53 Public method to get the enabled state. 54 Public method to get the enabled state.
54 55
55 @return enabled state (boolean) 56 @return enabled state (boolean)
56 """ 57 """
57 return self.enabled 58 return self.enabled
58 59
59 def charAdded(self, charNumber): 60 def charAdded(self, charNumber):
60 """ 61 """
61 Public slot called to handle the user entering a character. 62 Public slot called to handle the user entering a character.
62 63
63 Note 1: this slot must be overridden by subclasses implementing the 64 Note 1: this slot must be overridden by subclasses implementing the
64 specific behavior for the language. 65 specific behavior for the language.
65 66
66 Note 2: charNumber can be greater than 255 because the editor is 67 Note 2: charNumber can be greater than 255 because the editor is
67 in UTF-8 mode by default. 68 in UTF-8 mode by default.
68 69
69 @param charNumber value of the character entered (integer) 70 @param charNumber value of the character entered (integer)
70 """ 71 """
71 pass # just do nothing 72 pass # just do nothing
72 73
73 def readSettings(self): 74 def readSettings(self):
74 """ 75 """
75 Public slot called to reread the configuration parameters. 76 Public slot called to reread the configuration parameters.
76 77
77 Note: this slot should be overridden by subclasses having 78 Note: this slot should be overridden by subclasses having
78 configurable parameters. 79 configurable parameters.
79 """ 80 """
80 pass # just do nothing 81 pass # just do nothing

eric ide

mercurial