windows-curses icon indicating copy to clipboard operation
windows-curses copied to clipboard

Arrow keys not read by python in integrated terminal of vscode.

Open ChrisIdema opened this issue 3 years ago • 5 comments

windows-curses doesn't work properly in the integrated terminal of vscode. Arrowkeys are not detected. For more details: https://github.com/microsoft/vscode/issues/112405

I think it is an issue with vscode, but they blame it on an extension (even with all extensions disabled). The only thing other than vscode would be the curses library itself. So it would be great if we can get to the bottom of this.

ChrisIdema avatar May 21 '21 13:05 ChrisIdema

Update. Problem still persists. Versions:

  • Python 3.9.6
  • Vscode 1.59.1
  • windows_curses-2.2.0
  • Windows 10

I think the integrated terminal changes key codes and wgetch doesn't capture them correctly. I don't know who is at fault.

ChrisIdema avatar Aug 24 '21 14:08 ChrisIdema

@ChrisIdema are you able to get windows-curses to lint at all in vscode?

Spent hours trying different things. Have no clue why it vscode does not think curses there there. Even though curses code will run. It just does not lint.

boardkeystown avatar Jan 31 '22 06:01 boardkeystown

@boardkeystown It's been a while since I visited this issue (although it is still on my mind). I have no idea how to debug this. I don't know what you mean by lint. Can you explain?

ChrisIdema avatar Jan 31 '22 20:01 ChrisIdema

@ChrisIdema of crouse. I mean the auto complete in vscode. When I import curses the linter does not work. Meaning after

import curses

You do get any dot function drop downs or comments. So you can't figure out what methods you have available to you while you use curse. Meaning I have to keep looking up the documentation... But the script seems to run fine. It's rather annoying

boardkeystown avatar Feb 01 '22 00:02 boardkeystown

Update. Problem still persists. Versions:

Python 3.9.13
Vscode 1.71.2
windows_curses 2.3.0
kconfiglib 14.1.0
Windows 10

How to test? Run python3 snake.py or menuconfig in VSCode integrated terminal. Arrow keys are not processed by windows-curses in VSCode's integrated terminal, but curses under Ubuntu does process it in VSCode's integrated terminal.

I tried building windows-curses so I could debug it, but I get compile errors:

LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
_cursesmodule.obj : error LNK2001: unresolved external symbol __imp__PyUnicode_AsEncodedString

ChrisIdema avatar Sep 25 '22 18:09 ChrisIdema

I'm trying to use curses and I'm having the same problem. I've noticed that shift+arrow keys actually end up printing numbers, which leads me to believe something is broken with how curses+vscode console is reading the state of numlock, and thus falsely thinks that it is on, therefore returning the key values for numpad rather than actual arrows.

AntonBogun avatar Apr 04 '23 00:04 AntonBogun

Update. Problem is fixed! Versions:

Python  3.11.4 
Vscode 1.82.3
windows_curses 2.3.1
kconfiglib 14.1.0
Windows 11

Both python3 snake.py and idf.py menuconfig work in integrated terminal (cmd or powershell) in Vscode. I wonder in which version it was fixed and why it took 2.5 years. But I'm happy I finally have full terminal functionality with arrow keys in Vscode in Windows.

ChrisIdema avatar Oct 05 '23 09:10 ChrisIdema

according to this issue on the vscode github, the issue was caused by vscode's terminal's backend, which is conpty.

apparently, this issue was fixed somewhere inbetween windows 10 and 11. (conpty is shipped with windows)

lokzz avatar Mar 09 '24 14:03 lokzz

@lokzz Thank you for explaining! I was glad the issue was fixed, but it always bugged me that I didn't know what the cause was. I never even heard of conpty.

ChrisIdema avatar Mar 09 '24 20:03 ChrisIdema