FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[work in progress] Replacing readline with prompt-toolkit. by jonathanslenders · Pull Request #8597 · ipython/ipython · GitHub

Repository navigation

[work in progress] Replacing readline with prompt-toolkit. - #8597

Closed
jonathanslenders wants to merge 1 commit into
ipython:masterfrom
jonathanslenders:prompt-toolkit
Closed

jonathanslenders wants to merge 1 commit into
ipython:masterfrom
jonathanslenders:prompt-toolkit

Conversation

Copy link
Copy Markdown
Contributor

Pull request that replaces all the readline functionality with prompt-toolkit. This pull request is meant to remove all readline specific stuff, and replace it with prompt-toolkit. That way we have better cross-platform support. (Especially Windows.) It should still provide a very simple command line. (Nice features, like we have in ptpython can be added later on.)

To try:

See: #8489.

To be done:

  • TerminalInteractiveShell.interact needs to be cleaned up. I don't think we still need things like hlen_b4_cell, rl_do_indent, etc...
  • The history integration has to be implemented. Right now we have an in-memory history. (It would be nice if we can make the data format compatible with the one that we already had.
  • Remove or fix _replace_rlhist_multiline.
  • prompt_manager.render(color=False). We don't want to have color=True anymore. The colors are determined by the Pygments color scheme. We don't want prompt_manager to return VT100 terminal escape codes.
  • Remove the parts of the InputSplitter that we don't need anymore.
  • Remove utils/coloransi.py. Use Pygments color schemes and prompt-toolkit instead.
  • Fix core/debugger. It used PyColorize. We should replace that with prompt-toolkit highlighting. (We can also highlight everything on Windows.)
  • Unit tests.
  • core/ultratb should become platform independent as well. (Not using coloransi or PyColorize.)
  • core/oinspect.
  • check every reference for pycolorize.
  • Create Pygments color schemes.
  • every place where we expect to write colored output. Use prompt_toolkit.Interface.print_tokens (https://github.com/jonathanslenders/python-prompt-toolkit/blob/f7bfe0ad1fb3cf48d205f517e8963878528fd31d/prompt_toolkit/interface.py#L440)

Further, this needs to be tested, improved, reviewed, etc...

minrk added this to the 5.0 milestone Jul 1, 2015

minrk commented Jul 1, 2015

Copy link
Copy Markdown
Member

Great to see this. Feel free to ping about any specific questions you have. We'll be pretty focuses on shipping 4.0 for the next little while (and SciPy next week), but I'm excited about this.

Remove utils/coloransi.py

You have no idea how happy that makes me.

Copy link
Copy Markdown
Contributor Author

Yes, I'll ping you. Probably I'll have many questions when I continue. Saturday I leave for three weeks on holiday, so not sure how much time I'll have. But I hope we should be able to finish it this summer.

Copy link
Copy Markdown
Member

I wonder if it might be better to add the prompt_toolkit machinery as a new interface initially, rather than changing TerminalInteractiveShell itself, and then phase out the readline-based TerminalInteractiveShell.

There's some extra complexity that's not visible in this repo, because the terminal frontend for Jupyter kernels (https://github.com/jupyter/jupyter_console ) currently inherits from TerminalInteractiveShell. It probably shouldn't do that, but it was the easiest way to get it up and going. I hope we can get that using prompt_toolkit too, but we should probably break the direct dependency between the two.

Copy link
Copy Markdown
Member

Also, thinking a bit more about the event loop integration stuff:

We currently have two kinds of GUI event loop integration. In the kernel, we hand over to the GUI event loop as the main loop, and trust it to call our own event loop at least every poll_interval seconds (default 0.05). In the terminal, Python's own event loop is the main one, and it calls the GUI loop in small bursts, via inputhook. But with readline we don't have a choice in this matter. If we could give primary control to the GUI event loop in the terminal, we could consolidate our two kinds of integration into one, which would be really nice.

However, the kernel approach ('call me') may not be quick enough for it our event loop to process every keystroke (in the kernel, it only needs to give us control when there's a message to handle). It's worth investigation, though.

Comment thread IPython/core/prompts.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This looks wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, there is actually much more wrong. I hope to find soon some time to continue on this. It is more work than I expected. (Everything related to the terminal and colors is spread all over IPython.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If you do work on this, you should be aware of #8724.

minrk commented Jan 21, 2016

Copy link
Copy Markdown
Member

closing in favor of #9118

minrk closed this Jan 21, 2016
minrk modified the milestones: no action, 5.0 Jan 21, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL