magiblot / tvision

A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Other
2k stars 151 forks source link

TVedit does not work from git-bash MINGW console #25

Closed alexey-vostrikov closed 3 years ago

alexey-vostrikov commented 3 years ago

TVedit does not work from git-bash MINGW console image

magiblot commented 3 years ago

Hi Alexey!

You are right. Turbo Vision uses the Win32 Console API, and the MINGW console has traditionally not supported it.

However, since Git for Windows 2.27.0, the Git Bash console has had support for Windows-native pseudo consoles. So I suggest you to check if you already have the latest version of Git Bash or if you need to enable this feature manually.

If that still doesn't work, all I could do would be to pop up a native console automatically. So you would be able to use Turbo Vision applications, but not directly from a MINGW console.

magiblot commented 3 years ago

Make sure to enable this option during setup:

Anotación 2020-10-26 175159

This is what I get:

Anotación 2020-10-26 175750

Unfortunately, mouse does not seem to be supported :(.

alexey-vostrikov commented 3 years ago

Can tvision detect winpty console and support it? To make applications written using t vision work on any consoles.

magiblot commented 3 years ago

Can tvision detect winpty console and support it?

How can I do it?

alexey-vostrikov commented 3 years ago

I am not a developer, but i think you could read something like https://stackoverflow.com/questions/48199794/winpty-and-git-bash

alexey-vostrikov commented 3 years ago

https://github.com/msys2/MINGW-packages/pull/2675 python3: Use is_cygpty() to detect a terminal

alexey-vostrikov commented 3 years ago

https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/

magiblot commented 3 years ago

Okay, thanks for investigating.

Turbo Vision prints the error you show in the image when the system calls needed to interact with the console fail. What the commit you shared seems to do is add a clause to an if statement so that Python doesn't refuse to interact with the terminal. So in the case of Turbo Vision, it would be useless to add a check like is_cygpty if the system calls for console interaction will fail anyway.

In theory, or at least as I understand it, winpty is exactly what is needed: a compatibility bridge between terminals using VT sequences and applications using the Win32 console API. Thus, I would expect Turbo Vision to work out of the box. But in practice, it doesn't work. I can't even get winpty cmd to work on Git Bash. So I guess I'll have to ask the winpty developers.

If none if this works, the only solution will be to implement terminal I/O with VT sequences. The most reasonable way would be to support Ncurses on Windows, since the code handling Ncurses interaction is already there. I can't promise I will implement this anytime soon. If you or anyone else wants to give it a try, I encourage you to contribute to the project.

Cheers.

alexey-vostrikov commented 3 years ago

Thanks for your attention, i just looking for console text editor for using with git-bash in windows. So it seemed to me that tvedit or turbo are the best candidates.

magiblot commented 3 years ago

Okay. Thanks for your interest :)

magiblot commented 3 years ago

I tried spawning a native console instead of printing that error message and exiting, but it didn't work, I don't understand why.

So I tried the latest Git Bash on ConEmu and the application started just fine. However, there is an issue with input. I found a related ConEmu bug report and commented there: https://github.com/Maximus5/ConEmu/issues/2065#issuecomment-719993061.

magiblot commented 3 years ago

After having talked with the author of ConEmu, I suggest you to create a Task that just invokes the bash shell directly, so that the native console host is used instead of mintty:

imatge

With this Turbo Vision should work out of the box:

imatge

alexey-vostrikov commented 3 years ago

image

alexey-vostrikov commented 3 years ago

but if i change dir to bin it works

magiblot commented 3 years ago

Segmentation fault

I think this happens when startup doesn't fail but still is unable to get the console dimensions. This could have been fixed by a previous commit. Can you upgrade to the latest commit and recompile?

but if i change dir to bin it works

Do you mean this?

cd bin
./tvedit.exe

That's strange. Do all the demo applications crash?

magiblot commented 3 years ago

This now sort of works with a workaround. When ran in Git Bash without pseudoconsole support, the application will spawn a separate terminal and run in it. This may not be what you were expecting, but it works.