-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPython 8 changes terminal cursor #13472
Comments
This behavior also occurs in VI edit mode where in [ins] mode the cursor changes to I-Beam but in [nav] mode the cursor changes back to Block. exiting in any of the two scenarios will keep the current cursor instead of getting back to the original cursor before opening IPython. Setups:
|
Hum... @jonathanslenders might have an idea ? I don't think we manipulate the cursor in IPython directly. |
It looks like IPython does manipulate the cursor directly, it was done so in this commit to change the cursor for INSERT, VISUAL, etc. modes (in the case where the user has The original author didn't add code to restore the cursor. I made a pull request here to fix that. For now, users can also run echo -en "\x1b[0 q" after exiting IPython to get their cursor back. |
Ah, good point, I forgot about this.
…On Sun, Jan 30, 2022 at 8:47 PM Luke Trujillo ***@***.***> wrote:
It looks like IPython does manipulate the cursor directly, it was done so
in this commit <#12588> to change
the cursor for INSERT, VISUAL, etc. modes (in the case where the user has
vi as their editing mode). That code is using ANSI escape codes to tell
the running terminal what kind of cursor to use.
The original author didn't add code to restore the cursor. I made a pull
request here <#13501> to fix that.
For now, users can also run
echo -en "\x1b[0 q"
after exiting IPython to get their cursor back.
—
Reply to this email directly, view it on GitHub
<#13472 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACR5TYD3EWMWBLAR4RRFR3UYWIT7ANCNFSM5MC3OMHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I think at some point, this functionality should be merged into prompt_toolkit itself, so that all applications can benefit from it. |
@jonathanslenders If you do decide to implement this feature, consider also changing the cursor back when the user does |
@ltrujello : I'll keep that in mind, it should not be an issue. Thanks! |
@ltrujello: Can you check out this PR: prompt-toolkit/python-prompt-toolkit#1558 With these changes, you can remove the custom cursor shape handling in IPython, pass a |
Fixes #13472 by restoring user's terminal cursor after exiting IPython
I'm using version 8.1.0. Now when I exit (Ctrl-D) ipython, I get a block cursor... but it's blinking (normally it is not blinking). This is with xterm and urxvt. Also, when I suspend ipython I still get an I-cursor. |
I'm not sure there is anything we can do for the suspend – I don't know enough about signal. |
@Carreau : See my pull request. This should restore the cursorshape on suspend. Restoring the cursorshape works by rendering Restoring cursorshapes during suspend works because prompt_toolkit configures the terminal in raw mode, which means that c-z doesn't send a |
@ianbrody : Would you be willing to try my pull request and see whether that fixes your issue? |
Now it changes back to a block cursor after suspend, but both after suspend and after quitting, the cursor is blinking. |
Personally, I'd strongly prefer that IPython do nothing whatsoever with the cursor. Even when IPython changes and then restores the cursor as expected, it's still unexpected. No other terminal application I use forcefully modifies the cursor – not even Vim or If I grok this comment from @jonathanslenders above correctly, the only means of disabling IPython's cursor modification at the moment is to forcefully pass either If so, that's better than nothing; at least I have some recourse. Still, changing the cursor without the user's permission only disgruntles users. This should ideally be an opt-in option disabled by default. |
If you'd like to make this configurable, I'd be happy to accept a PR that adds the option. Just make sure to take other PRs that are currently open into account, specifically those open by @jonathanslenders. |
Any updates here? Ipython 8 change my vim cursor when using vim-repl, even vim in NORMAL mode. Thanks. |
According the discussion you either need to make the mentioned modification to IPython or send a PR to make it configurable. But as we have no way to know what the cursor shape is, we can't really restore it. |
@Carreau thanks for quick reply. |
After starting IPython 8.0 and then returning to terminal, the cursor changes from block to I-Beam.
Before:
After:
I need to call
reset
to get the cursor back to block.Setup: XFCE terminal + zsh + starship
The text was updated successfully, but these errors were encountered: