MCPcopy Index your code
hub / github.com/RustPython/RustPython / Reader

Class Reader

Lib/_pyrepl/reader.py:169–816  ·  view source on GitHub ↗

The Reader class implements the bare bones of a command reader, handling such details as editing and cursor motion. What it does not support are such things as completion or history support - these are implemented elsewhere. Instance variables of note include: * buffer:

Source from the content-addressed store, hash-verified

167
168@dataclass(slots=True)
169class Reader:
170 """The Reader class implements the bare bones of a command reader,
171 handling such details as editing and cursor motion. What it does
172 not support are such things as completion or history support -
173 these are implemented elsewhere.
174
175 Instance variables of note include:
176
177 * buffer:
178 A *list* (*not* a string at the moment :-) containing all the
179 characters that have been entered.
180 * console:
181 Hopefully encapsulates the OS dependent stuff.
182 * pos:
183 A 0-based index into `buffer' for where the insertion point
184 is.
185 * screeninfo:
186 Ahem. This list contains some info needed to move the
187 insertion point around reasonably efficiently.
188 * cxy, lxy:
189 the position of the insertion point in screen ...
190 * syntax_table:
191 Dictionary mapping characters to `syntax class'; read the
192 emacs docs to see what this means :-)
193 * commands:
194 Dictionary mapping command names to command classes.
195 * arg:
196 The emacs-style prefix argument. It will be None if no such
197 argument has been provided.
198 * dirty:
199 True if we need to refresh the display.
200 * kill_ring:
201 The emacs-style kill-ring; manipulated with yank & yank-pop
202 * ps1, ps2, ps3, ps4:
203 prompts. ps1 is the prompt for a one-line input; for a
204 multiline input it looks like:
205 ps2> first line of input goes here
206 ps3> second and further
207 ps3> lines get ps3
208 ...
209 ps4> and the last one gets ps4
210 As with the usual top-level, you can set these to instances if
211 you like; str() will be called on them (once) at the beginning
212 of each command. Don't put really long or newline containing
213 strings here, please!
214 This is just the default policy; you can change it freely by
215 overriding get_prompt() (and indeed some standard subclasses
216 do).
217 * finished:
218 handle1 will set this to a true value if a command signals
219 that we're done.
220 """
221
222 console: console.Console
223
224 ## state
225 buffer: list[str] = field(default_factory=list)
226 pos: int = 0

Callers

nothing calls this directly

Calls 1

fieldFunction · 0.90

Tested by

no test coverage detected