Skip to content
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

Arrow keys not working in python shell #2065

Open
XinliYu opened this issue Feb 17, 2020 · 13 comments
Open

Arrow keys not working in python shell #2065

XinliYu opened this issue Feb 17, 2020 · 13 comments

Comments

@XinliYu
Copy link

XinliYu commented Feb 17, 2020

I use cygwin + python 3.7.5, all latest version.

The cygwin task is

set CHERE_INVOKING=1 & set "PATH=%ConEmuDrive%\cygwin64\bin;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe -new_console:p %ConEmuDrive%\cygwin64\bin\bash.exe --login -i -new_console:C:"%ConEmuDrive%\cygwin64\Cygwin.ico"

The arrow keys works in the terminal and vim, but not the Python or IPYTHON shell,

image

The left key is mapped to '[D', the right key is mapped to '[C', up key mapped to '[A', down key mapped to '[B'.

The python shell in Cygwin's buildin terminal is OK.
Also tried -new_console:p1 and -new_console:p5, both did not work.

@MiXaiLL76
Copy link

i use ConEmuSetup.180206.exe and it work's

@copdips
Copy link

copdips commented May 1, 2020

maybe it's related to the package prompt-toolkit required by ipython.
please try to upgrade ipython, the latest prompt-toolkit version is 3.0.5

@cebaa
Copy link

cebaa commented Jul 10, 2020

@XinliYu Is it working outside of cygwin?

@cebaa
Copy link

cebaa commented Jul 15, 2020

Interestingly enough, removing %ConEmuBaseDirShort%\conemu-cyg-64.exe makes this work. So it's some weird interaction between these. ANSI creeps again... :)

This is with ConEmu 200713 and 3.1.6(0.340/5/3) 2020-07-09 08:20 x86_64 Cygwin on my end.

@Maximus5
Copy link
Owner

From topic-starter screenshot - Python does not look like cygwin's version.
@cebaa What about yours? If you run python, what it shows? For cygwin it should be smth like

image

@cebaa
Copy link

cebaa commented Jul 15, 2020

@Maximus5 Good catch, that's the issue - the non-cygwin one:

$ python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

has issues with arrow keys, the cygwin one:

$ /usr/bin/python3
Python 3.6.9 (default, Jul 21 2019, 14:33:59)
[GCC 7.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.

has no issues with arrow keys. So from ConEmu standpoint expected behavior.

Damn, I envy you for being so patient with 1000s of variations of the same issue :)

@magiblot
Copy link

The issue is the ESC character being eaten up before arriving to the application. I can reproduce with Git Bash 2.29.2 and Turbo Vision:

imatge

Note that Turbo Vision uses the Win32 Console API, which is supported by Git Bash since 2.27.0. I can't reproduce this issue with other Git Bash applications such as Nano.

@Maximus5
Copy link
Owner

Than use Win32 Console API, that's it.
On the screenshot you started the connector, it's not a Win32 API, but posix emulation.
Dont mix bash with terminals.

@Maximus5
Copy link
Owner

Remove connector from your task

@magiblot
Copy link

Hi Maksim,

Dont mix bash with terminals.

I already know that bash is an interpreter and not a terminal. From the Git for Windows changelog:

This release comes with a Git Bash that optionally uses Windows-native pseudo consoles. Meaning: finally, Git Bash can accommodate console programs like node.exe, Python or PHP, without using the winpty helper.

So according to the Git for Windows developers, Git Bash != bash. I am not to be blamed for this confusing terminology.

It's Git Bash that makes that application work. When disabling the Windows-native pseudo console option in Git Bash, Turbo Vision can't start at all. The same happens when running Git Bash from outside ConEmu. But only when running Git Bash in ConEmu, ESC characters are missing. So even if running a Win32 Console API application using the connector is pointless, there seems to be something wrong.

Now, I do not use ConEmu regularly. Another user reported that Turbo Vision was not working for them when using Git Bash within ConEmu, so I tested it and found this issue. I would like to guide them to use Git Bash's bash (C:\Program Files\Git\bin\bash.exe) without the connector, as I think it's what will work best for them, but I don't know how. Can you please provide me with some quick reference on how to do this?

Thank you very much.

@Maximus5
Copy link
Owner

Terminology, terminology...

"Git Bash" could be an executable starting mintty.exe or the bash.exe included in Git-for-Windows distro.

First of all, to compare, we need to run TV from mintty.exe. That is weird, but due to changelog it should work.

Second, when connector is started, ConEmu sends esc-sequences same way, regardless the executable in view. You can see on screenshot the conemu-msys2-64.exe (the connector). Do arrow keys working in bash prompt? I bet they do.

There is an article about Tasks. https://conemu.github.io/en/Tasks.html
They are just an aliases to run command user want to run. If they want to run bash.exe, just put the path in the Task.

Well, I have not thoroughly checked the behavior of git bash from latest versions started without connector. But there were definitely bugs in the past and at least some of them persists.

@Maximus5
Copy link
Owner

BTW, ConEmu implements real switch to Win32 console from posix emulation. I have not checked it with latest git bash but it worked in the past.

https://conemu.github.io/blog/2018/06/17/Build-180617.html

@magiblot
Copy link

magiblot commented Nov 1, 2020

BTW, ConEmu implements real switch to Win32 console from posix emulation. I have not checked it with latest git bash but it worked in the past.

https://conemu.github.io/blog/2018/06/17/Build-180617.html

I can't get this to work. tvedit starts but still does not receive ESC characters. After exiting tvedit, I see this:

imatge

There is an article about Tasks. https://conemu.github.io/en/Tasks.html

This works as expected, both mouse and keyboard:

imatge

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants