|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' |
|
3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> |
|
4 <html><head> |
|
5 <title>eric4.DebugClients.Python3.FlexCompleter</title> |
|
6 <style> |
|
7 body { |
|
8 background:white; |
|
9 margin: 0em 1em 10em 1em; |
|
10 color: black; |
|
11 } |
|
12 |
|
13 h1 { color: white; background: #4FA4FF; } |
|
14 h2 { color: white; background: #4FA4FF; } |
|
15 h3 { color: white; background: #00557F; } |
|
16 h4 { color: white; background: #00557F; } |
|
17 |
|
18 a { color: #AA5500; } |
|
19 |
|
20 </style> |
|
21 </head> |
|
22 <body><a NAME="top" ID="top"></a> |
|
23 <h1>eric4.DebugClients.Python3.FlexCompleter</h1> |
|
24 <p> |
|
25 Word completion for the eric4 shell |
|
26 </p><p> |
|
27 <h4>NOTE for eric4 variant</h4> |
|
28 </p><p> |
|
29 This version is a re-implementation of rlcompleter |
|
30 as found in the Python3 library. It is modified to work with the eric4 |
|
31 debug clients. |
|
32 </p><p> |
|
33 <h4>Original rlcompleter documentation</h4> |
|
34 </p><p> |
|
35 This requires the latest extension to the readline module. The completer |
|
36 completes keywords, built-ins and globals in a selectable namespace (which |
|
37 defaults to __main__); when completing NAME.NAME..., it evaluates (!) the |
|
38 expression up to the last dot and completes its attributes. |
|
39 </p><p> |
|
40 It's very cool to do "import sys" type "sys.", hit the |
|
41 completion key (twice), and see the list of names defined by the |
|
42 sys module! |
|
43 </p><p> |
|
44 Tip: to use the tab key as the completion key, call |
|
45 </p><p> |
|
46 readline.parse_and_bind("tab: complete") |
|
47 </p><p> |
|
48 <b>Notes</b>: |
|
49 <ul> |
|
50 <li> |
|
51 Exceptions raised by the completer function are *ignored* (and |
|
52 generally cause the completion to fail). This is a feature -- since |
|
53 readline sets the tty device in raw (or cbreak) mode, printing a |
|
54 traceback wouldn't work well without some complicated hoopla to save, |
|
55 reset and restore the tty state. |
|
56 </li> |
|
57 <li> |
|
58 The evaluation of the NAME.NAME... form may cause arbitrary |
|
59 application defined code to be executed if an object with a |
|
60 __getattr__ hook is found. Since it is the responsibility of the |
|
61 application (or the user) to enable this feature, I consider this an |
|
62 acceptable risk. More complicated expressions (e.g. function calls or |
|
63 indexing operations) are *not* evaluated. |
|
64 </li> |
|
65 <li> |
|
66 When the original stdin is not a tty device, GNU readline is never |
|
67 used, and this module (and the readline module) are silently inactive. |
|
68 </li> |
|
69 </ul> |
|
70 </p> |
|
71 <h3>Global Attributes</h3> |
|
72 <table> |
|
73 <tr><td>__all__</td></tr> |
|
74 </table> |
|
75 <h3>Classes</h3> |
|
76 <table> |
|
77 <tr> |
|
78 <td><a href="#Completer">Completer</a></td> |
|
79 <td>Class implementing the command line completer object.</td> |
|
80 </tr> |
|
81 </table> |
|
82 <h3>Functions</h3> |
|
83 <table> |
|
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 /><hr /> |
|
90 <a NAME="Completer" ID="Completer"></a> |
|
91 <h2>Completer</h2> |
|
92 <p> |
|
93 Class implementing the command line completer object. |
|
94 </p> |
|
95 <h3>Derived from</h3> |
|
96 object |
|
97 <h3>Class Attributes</h3> |
|
98 <table> |
|
99 <tr><td>None</td></tr> |
|
100 </table> |
|
101 <h3>Methods</h3> |
|
102 <table> |
|
103 <tr> |
|
104 <td><a href="#Completer.__init__">Completer</a></td> |
|
105 <td>Create a new completer for the command line.</td> |
|
106 </tr><tr> |
|
107 <td><a href="#Completer._callable_postfix">_callable_postfix</a></td> |
|
108 <td>Protected method to check for a callable.</td> |
|
109 </tr><tr> |
|
110 <td><a href="#Completer.attr_matches">attr_matches</a></td> |
|
111 <td>Compute matches when text contains a dot.</td> |
|
112 </tr><tr> |
|
113 <td><a href="#Completer.complete">complete</a></td> |
|
114 <td>Return the next possible completion for 'text'.</td> |
|
115 </tr><tr> |
|
116 <td><a href="#Completer.global_matches">global_matches</a></td> |
|
117 <td>Compute matches when text is a simple name.</td> |
|
118 </tr> |
|
119 </table> |
|
120 <a NAME="Completer.__init__" ID="Completer.__init__"></a> |
|
121 <h4>Completer (Constructor)</h4> |
|
122 <b>Completer</b>(<i>namespace = None</i>) |
|
123 <p> |
|
124 Create a new completer for the command line. |
|
125 </p><p> |
|
126 Completer([namespace]) -> completer instance. |
|
127 </p><p> |
|
128 If unspecified, the default namespace where completions are performed |
|
129 is __main__ (technically, __main__.__dict__). Namespaces should be |
|
130 given as dictionaries. |
|
131 </p><p> |
|
132 Completer instances should be used as the completion mechanism of |
|
133 readline via the set_completer() call: |
|
134 </p><p> |
|
135 readline.set_completer(Completer(my_namespace).complete) |
|
136 </p><dl> |
|
137 <dt><i>namespace</i></dt> |
|
138 <dd> |
|
139 The namespace for the completer. |
|
140 </dd> |
|
141 </dl><a NAME="Completer._callable_postfix" ID="Completer._callable_postfix"></a> |
|
142 <h4>Completer._callable_postfix</h4> |
|
143 <b>_callable_postfix</b>(<i>val, word</i>) |
|
144 <p> |
|
145 Protected method to check for a callable. |
|
146 </p><dl> |
|
147 <dt><i>val</i></dt> |
|
148 <dd> |
|
149 value to check (object) |
|
150 </dd><dt><i>word</i></dt> |
|
151 <dd> |
|
152 word to ammend (string) |
|
153 </dd> |
|
154 </dl><dl> |
|
155 <dt>Returns:</dt> |
|
156 <dd> |
|
157 ammended word (string) |
|
158 </dd> |
|
159 </dl><a NAME="Completer.attr_matches" ID="Completer.attr_matches"></a> |
|
160 <h4>Completer.attr_matches</h4> |
|
161 <b>attr_matches</b>(<i>text</i>) |
|
162 <p> |
|
163 Compute matches when text contains a dot. |
|
164 </p><p> |
|
165 Assuming the text is of the form NAME.NAME....[NAME], and is |
|
166 evaluatable in self.namespace, it will be evaluated and its attributes |
|
167 (as revealed by dir()) are used as possible completions. (For class |
|
168 instances, class members are are also considered.) |
|
169 </p><p> |
|
170 <b>WARNING</b>: this can still invoke arbitrary C code, if an object |
|
171 with a __getattr__ hook is evaluated. |
|
172 </p><dl> |
|
173 <dt><i>text</i></dt> |
|
174 <dd> |
|
175 The text to be completed. (string) |
|
176 </dd> |
|
177 </dl><dl> |
|
178 <dt>Returns:</dt> |
|
179 <dd> |
|
180 A list of all matches. |
|
181 </dd> |
|
182 </dl><a NAME="Completer.complete" ID="Completer.complete"></a> |
|
183 <h4>Completer.complete</h4> |
|
184 <b>complete</b>(<i>text, state</i>) |
|
185 <p> |
|
186 Return the next possible completion for 'text'. |
|
187 </p><p> |
|
188 This is called successively with state == 0, 1, 2, ... until it |
|
189 returns None. The completion should begin with 'text'. |
|
190 </p><dl> |
|
191 <dt><i>text</i></dt> |
|
192 <dd> |
|
193 The text to be completed. (string) |
|
194 </dd><dt><i>state</i></dt> |
|
195 <dd> |
|
196 The state of the completion. (integer) |
|
197 </dd> |
|
198 </dl><dl> |
|
199 <dt>Returns:</dt> |
|
200 <dd> |
|
201 The possible completions as a list of strings. |
|
202 </dd> |
|
203 </dl><a NAME="Completer.global_matches" ID="Completer.global_matches"></a> |
|
204 <h4>Completer.global_matches</h4> |
|
205 <b>global_matches</b>(<i>text</i>) |
|
206 <p> |
|
207 Compute matches when text is a simple name. |
|
208 </p><dl> |
|
209 <dt><i>text</i></dt> |
|
210 <dd> |
|
211 The text to be completed. (string) |
|
212 </dd> |
|
213 </dl><dl> |
|
214 <dt>Returns:</dt> |
|
215 <dd> |
|
216 A list of all keywords, built-in functions and names currently |
|
217 defined in self.namespace that match. |
|
218 </dd> |
|
219 </dl> |
|
220 <div align="right"><a href="#top">Up</a></div> |
|
221 <hr /><hr /> |
|
222 <a NAME="get_class_members" ID="get_class_members"></a> |
|
223 <h2>get_class_members</h2> |
|
224 <b>get_class_members</b>(<i>klass</i>) |
|
225 <p> |
|
226 Module function to retrieve the class members. |
|
227 </p><dl> |
|
228 <dt><i>klass</i></dt> |
|
229 <dd> |
|
230 The class object to be analysed. |
|
231 </dd> |
|
232 </dl><dl> |
|
233 <dt>Returns:</dt> |
|
234 <dd> |
|
235 A list of all names defined in the class. |
|
236 </dd> |
|
237 </dl> |
|
238 <div align="right"><a href="#top">Up</a></div> |
|
239 <hr /> |
|
240 </body></html> |