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