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