Python Repl Reacts to events like - terminal dimensions and change events - keystrokes Behavior altered by - number of scroll downs that were necessary to render array after each display - initial cursor position outputs: - 2D array to be rendered Ba
| 306 | |
| 307 | |
| 308 | class BaseRepl(Repl): |
| 309 | """Python Repl |
| 310 | |
| 311 | Reacts to events like |
| 312 | - terminal dimensions and change events |
| 313 | - keystrokes |
| 314 | Behavior altered by |
| 315 | - number of scroll downs that were necessary to render array after each |
| 316 | display |
| 317 | - initial cursor position |
| 318 | outputs: |
| 319 | - 2D array to be rendered |
| 320 | |
| 321 | BaseRepl is mostly view-independent state of Repl - but self.width and |
| 322 | self.height are important for figuring out how to wrap lines for example. |
| 323 | Usually self.width and self.height should be set by receiving a window |
| 324 | resize event, not manually set to anything - as long as the first event |
| 325 | received is a window resize event, this works fine. |
| 326 | |
| 327 | Subclasses are responsible for implementing several methods. |
| 328 | """ |
| 329 | |
| 330 | def __init__( |
| 331 | self, |
| 332 | config: Config, |
| 333 | window: CursorAwareWindow, |
| 334 | locals_: dict[str, Any] | None = None, |
| 335 | banner: str | None = None, |
| 336 | interp: Interp | None = None, |
| 337 | orig_tcattrs: list[Any] | None = None, |
| 338 | ): |
| 339 | """ |
| 340 | locals_ is a mapping of locals to pass into the interpreter |
| 341 | config is a bpython config.Struct with config attributes |
| 342 | banner is a string to display briefly in the status bar |
| 343 | interp is an interpreter instance to use |
| 344 | original terminal state, useful for shelling out with normal terminal |
| 345 | """ |
| 346 | |
| 347 | logger.debug("starting init") |
| 348 | self.window = window |
| 349 | |
| 350 | # If creating a new interpreter on undo would be unsafe because initial |
| 351 | # state was passed in |
| 352 | self.weak_rewind = bool(locals_ or interp) |
| 353 | |
| 354 | if interp is None: |
| 355 | interp = Interp(locals=locals_) |
| 356 | interp.write = self.send_to_stdouterr # type: ignore |
| 357 | if config.cli_suggestion_width <= 0 or config.cli_suggestion_width > 1: |
| 358 | config.cli_suggestion_width = 1 |
| 359 | |
| 360 | self.reevaluating = False |
| 361 | self.fake_refresh_requested = False |
| 362 | |
| 363 | self.status_bar = StatusBar( |
| 364 | config, |
| 365 | "", |
nothing calls this directly
no outgoing calls
no test coverage detected