DebugClients/Python/FlexCompleter.py

changeset 3591
2f2a4a76dd22
parent 3043
71f5c524d427
child 3621
15f23ed3f216
equal deleted inserted replaced
3590:5280e37405b8 3591:2f2a4a76dd22
108 """ 108 """
109 Class implementing the command line completer object. 109 Class implementing the command line completer object.
110 """ 110 """
111 def __init__(self, namespace=None): 111 def __init__(self, namespace=None):
112 """ 112 """
113 Create a new completer for the command line. 113 Constructor
114 114
115 Completer([namespace]) -> completer instance. 115 Completer([namespace]) -> completer instance.
116 116
117 If unspecified, the default namespace where completions are performed 117 If unspecified, the default namespace where completions are performed
118 is __main__ (technically, __main__.__dict__). Namespaces should be 118 is __main__ (technically, __main__.__dict__). Namespaces should be
138 self.use_main_ns = 0 138 self.use_main_ns = 0
139 self.namespace = namespace 139 self.namespace = namespace
140 140
141 def complete(self, text, state): 141 def complete(self, text, state):
142 """ 142 """
143 Return the next possible completion for 'text'. 143 Public method to return the next possible completion for 'text'.
144 144
145 This is called successively with state == 0, 1, 2, ... until it 145 This is called successively with state == 0, 1, 2, ... until it
146 returns None. The completion should begin with 'text'. 146 returns None. The completion should begin with 'text'.
147 147
148 @param text The text to be completed. (string) 148 @param text The text to be completed. (string)
162 except IndexError: 162 except IndexError:
163 return None 163 return None
164 164
165 def global_matches(self, text): 165 def global_matches(self, text):
166 """ 166 """
167 Compute matches when text is a simple name. 167 Public method to compute matches when text is a simple name.
168 168
169 @param text The text to be completed. (string) 169 @param text The text to be completed. (string)
170 @return A list of all keywords, built-in functions and names currently 170 @return A list of all keywords, built-in functions and names currently
171 defined in self.namespace that match. 171 defined in self.namespace that match.
172 """ 172 """
183 matches.append(word) 183 matches.append(word)
184 return matches 184 return matches
185 185
186 def attr_matches(self, text): 186 def attr_matches(self, text):
187 """ 187 """
188 Compute matches when text contains a dot. 188 Public method to compute matches when text contains a dot.
189 189
190 Assuming the text is of the form NAME.NAME....[NAME], and is 190 Assuming the text is of the form NAME.NAME....[NAME], and is
191 evaluatable in self.namespace, it will be evaluated and its attributes 191 evaluatable in self.namespace, it will be evaluated and its attributes
192 (as revealed by dir()) are used as possible completions. (For class 192 (as revealed by dir()) are used as possible completions. (For class
193 instances, class members are are also considered.) 193 instances, class members are are also considered.)

eric ide

mercurial