Documentation/Source/eric4.DebugClients.Python.FlexCompleter.html

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

eric ide

mercurial