src/eric7/Documentation/Source/eric7.DebugClients.Python.FlexCompleter.html

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8596
d64760b2da50
child 10417
c6011e501282
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.DebugClients.Python.FlexCompleter</title>
4 <meta charset="UTF-8">
5 <link rel="stylesheet" href="styles.css">
6 </head>
7 <body>
8 <a NAME="top" ID="top"></a>
9 <h1>eric7.DebugClients.Python.FlexCompleter</h1>
10
11 <p>
12 Word completion for the eric shell.
13 </p>
14 <p>
15 <h4>NOTE for eric variant</h4>
16 </p>
17 <p>
18 This version is a re-implementation of rlcompleter
19 as found in the Python3 library. It is modified to work with the eric
20 debug clients.
21 </p>
22 <p>
23 <h4>Original rlcompleter documentation</h4>
24 </p>
25 <p>
26 This requires the latest extension to the readline module. The completer
27 completes keywords, built-ins and globals in a selectable namespace (which
28 defaults to __main__); when completing NAME.NAME..., it evaluates (!) the
29 expression up to the last dot and completes its attributes.
30 </p>
31 <p>
32 It's very cool to do "import sys" type "sys.", hit the
33 completion key (twice), and see the list of names defined by the
34 sys module!
35 </p>
36 <p>
37 Tip: to use the tab key as the completion key, call
38 </p>
39 <p>
40 readline.parse_and_bind("tab: complete")
41 </p>
42 <p>
43 <b>Notes</b>:
44 <ul>
45 <li>
46 Exceptions raised by the completer function are *ignored* (and
47 generally cause the completion to fail). This is a feature -- since
48 readline sets the tty device in raw (or cbreak) mode, printing a
49 traceback wouldn't work well without some complicated hoopla to save,
50 reset and restore the tty state.
51 </li>
52 <li>
53 The evaluation of the NAME.NAME... form may cause arbitrary
54 application defined code to be executed if an object with a
55 __getattr__ hook is found. Since it is the responsibility of the
56 application (or the user) to enable this feature, I consider this an
57 acceptable risk. More complicated expressions (e.g. function calls or
58 indexing operations) are *not* evaluated.
59 </li>
60 <li>
61 When the original stdin is not a tty device, GNU readline is never
62 used, and this module (and the readline module) are silently inactive.
63 </li>
64 </ul>
65 </p>
66 <h3>Global Attributes</h3>
67
68 <table>
69 <tr><td>__all__</td></tr>
70 </table>
71 <h3>Classes</h3>
72
73 <table>
74
75 <tr>
76 <td><a href="#Completer">Completer</a></td>
77 <td>Class implementing the command line completer object.</td>
78 </tr>
79 </table>
80 <h3>Functions</h3>
81
82 <table>
83
84 <tr>
85 <td><a href="#get_class_members">get_class_members</a></td>
86 <td>Module function to retrieve the class members.</td>
87 </tr>
88 </table>
89 <hr />
90 <hr />
91 <a NAME="Completer" ID="Completer"></a>
92 <h2>Completer</h2>
93
94 <p>
95 Class implementing the command line completer object.
96 </p>
97 <h3>Derived from</h3>
98 None
99 <h3>Class Attributes</h3>
100
101 <table>
102 <tr><td>None</td></tr>
103 </table>
104 <h3>Class Methods</h3>
105
106 <table>
107 <tr><td>None</td></tr>
108 </table>
109 <h3>Methods</h3>
110
111 <table>
112
113 <tr>
114 <td><a href="#Completer.__init__">Completer</a></td>
115 <td>Constructor</td>
116 </tr>
117 <tr>
118 <td><a href="#Completer._callable_postfix">_callable_postfix</a></td>
119 <td>Protected method to check for a callable.</td>
120 </tr>
121 <tr>
122 <td><a href="#Completer.attr_matches">attr_matches</a></td>
123 <td>Public method to compute matches when text contains a dot.</td>
124 </tr>
125 <tr>
126 <td><a href="#Completer.complete">complete</a></td>
127 <td>Public method to return the next possible completion for 'text'.</td>
128 </tr>
129 <tr>
130 <td><a href="#Completer.global_matches">global_matches</a></td>
131 <td>Public method to compute matches when text is a simple name.</td>
132 </tr>
133 </table>
134 <h3>Static Methods</h3>
135
136 <table>
137 <tr><td>None</td></tr>
138 </table>
139
140 <a NAME="Completer.__init__" ID="Completer.__init__"></a>
141 <h4>Completer (Constructor)</h4>
142 <b>Completer</b>(<i>namespace=None</i>)
143
144 <p>
145 Constructor
146 </p>
147 <p>
148 Completer([namespace]) -> completer instance.
149 </p>
150 <p>
151 If unspecified, the default namespace where completions are performed
152 is __main__ (technically, __main__.__dict__). Namespaces should be
153 given as dictionaries.
154 </p>
155 <p>
156 Completer instances should be used as the completion mechanism of
157 readline via the set_completer() call:
158 </p>
159 <p>
160 readline.set_completer(Completer(my_namespace).complete)
161 </p>
162 <dl>
163
164 <dt><i>namespace</i></dt>
165 <dd>
166 The namespace for the completer.
167 </dd>
168 </dl>
169 <dl>
170
171 <dt>Raises <b>TypeError</b>:</dt>
172 <dd>
173 raised to indicate a wrong data structure of
174 the namespace object
175 </dd>
176 </dl>
177 <a NAME="Completer._callable_postfix" ID="Completer._callable_postfix"></a>
178 <h4>Completer._callable_postfix</h4>
179 <b>_callable_postfix</b>(<i>val, word</i>)
180
181 <p>
182 Protected method to check for a callable.
183 </p>
184 <dl>
185
186 <dt><i>val</i></dt>
187 <dd>
188 value to check (object)
189 </dd>
190 <dt><i>word</i></dt>
191 <dd>
192 word to ammend (string)
193 </dd>
194 </dl>
195 <dl>
196 <dt>Return:</dt>
197 <dd>
198 ammended word (string)
199 </dd>
200 </dl>
201 <a NAME="Completer.attr_matches" ID="Completer.attr_matches"></a>
202 <h4>Completer.attr_matches</h4>
203 <b>attr_matches</b>(<i>text</i>)
204
205 <p>
206 Public method to compute matches when text contains a dot.
207 </p>
208 <p>
209 Assuming the text is of the form NAME.NAME....[NAME], and is
210 evaluatable in self.namespace, it will be evaluated and its attributes
211 (as revealed by dir()) are used as possible completions. (For class
212 instances, class members are are also considered.)
213 </p>
214 <p>
215 <b>WARNING</b>: this can still invoke arbitrary C code, if an object
216 with a __getattr__ hook is evaluated.
217 </p>
218 <dl>
219
220 <dt><i>text</i></dt>
221 <dd>
222 The text to be completed. (string)
223 </dd>
224 </dl>
225 <dl>
226 <dt>Return:</dt>
227 <dd>
228 A list of all matches.
229 </dd>
230 </dl>
231 <a NAME="Completer.complete" ID="Completer.complete"></a>
232 <h4>Completer.complete</h4>
233 <b>complete</b>(<i>text, state</i>)
234
235 <p>
236 Public method to return the next possible completion for 'text'.
237 </p>
238 <p>
239 This is called successively with state == 0, 1, 2, ... until it
240 returns None. The completion should begin with 'text'.
241 </p>
242 <dl>
243
244 <dt><i>text</i></dt>
245 <dd>
246 The text to be completed. (string)
247 </dd>
248 <dt><i>state</i></dt>
249 <dd>
250 The state of the completion. (integer)
251 </dd>
252 </dl>
253 <dl>
254 <dt>Return:</dt>
255 <dd>
256 The possible completions as a list of strings.
257 </dd>
258 </dl>
259 <a NAME="Completer.global_matches" ID="Completer.global_matches"></a>
260 <h4>Completer.global_matches</h4>
261 <b>global_matches</b>(<i>text</i>)
262
263 <p>
264 Public method to compute matches when text is a simple name.
265 </p>
266 <dl>
267
268 <dt><i>text</i></dt>
269 <dd>
270 The text to be completed. (string)
271 </dd>
272 </dl>
273 <dl>
274 <dt>Return:</dt>
275 <dd>
276 A list of all keywords, built-in functions and names currently
277 defined in self.namespace that match.
278 </dd>
279 </dl>
280 <div align="right"><a href="#top">Up</a></div>
281 <hr />
282 <hr />
283 <a NAME="get_class_members" ID="get_class_members"></a>
284 <h2>get_class_members</h2>
285 <b>get_class_members</b>(<i>klass</i>)
286
287 <p>
288 Module function to retrieve the class members.
289 </p>
290 <dl>
291
292 <dt><i>klass</i></dt>
293 <dd>
294 The class object to be analysed.
295 </dd>
296 </dl>
297 <dl>
298 <dt>Return:</dt>
299 <dd>
300 A list of all names defined in the class.
301 </dd>
302 </dl>
303 <div align="right"><a href="#top">Up</a></div>
304 <hr />
305 </body></html>

eric ide

mercurial