PDCursesMod icon indicating copy to clipboard operation
PDCursesMod copied to clipboard

VT issues on Windows cmd?

Open GitMensch opened this issue 3 years ago • 2 comments

When executing the following code:

initscr ();
mousemask (ALL_MOUSE_EVENTS, NULL);
has_mouse ();
longname ();
endwin ();

The following is shown on cmd:

←[?47h←7←8←[m←[?47l←[80;1H←8←[m←[?47l←[1 q←[80;1H

Originally reported at https://sourceforge.net/p/gnucobol/discussion/help/thread/8dff85cf8f

So I guess there may be some sequence missing - or is this not expected to work on conhost->cmd?

GitMensch avatar Dec 08 '21 11:12 GitMensch

I've never had a great deal of success in getting VT to work on Windows. (At the time I started working on the VT platform, Microsoft didn't support anything VT-related; Windows support for PDCursesMod/VT was something of an afterthought.)

My suspicion is that it's in the mousemask() call. I don't think our friends at Microsoft have implemented all of the xterm sequences for mouse movements or for SGR position reporting (the format you need to use for terminals more than 223 columns wide or rows high). I probably need to add in some #ifdef _WIN32 lines to say "if you're running under Windows, don't output the following control sequences; just accept the fact that mouse input won't work on really large windows, and you won't receive certain types of mouse events."

I'll investigate (no Windows machine handy right now, and Wine doesn't handle these sequences too well either.)

Bill-Gray avatar Dec 08 '21 23:12 Bill-Gray

Just did a little digging in to this. The two issues that jumped out at me were the inability to find or set the terminal size, and the lack of RGB coloring. The Microsoft documentation of command sequences confirms that neither is currently supported in Windows. You can set the terminal width to anything you like, as long as it's 132 or 80 columns. You can't set the terminal height at all. And, as you initially noted, the mouse is only "sort of" supported.

It does not appear that Microsoft is particularly serious about supporting VT sequences. I would urge anyone building PDCurses on Windows platforms to use WinGUI or WinCon. I can't come up with any good reason to use VT on Windows; it is only barely supported by Microsoft, and only on Win10 and Win11.

I've modified the README.md for the VT platform to warn people away from VT use on Windows (commit d6e517eb36ebb298b792fcc4d).

Bill-Gray avatar Jan 12 '22 15:01 Bill-Gray

Since it seems Microsoft isn't going to support terminal control sequences to any real degree, I'll close this as "can't fix". (Sadly. It'd be rather nice if we could switch over to use of the VT port in the Windows console.)

Bill-Gray avatar Sep 12 '22 00:09 Bill-Gray

Since it seems Microsoft isn't going to support terminal control sequences to any real degree, I'll close this as "can't fix".

How do you come to this conclusion? The implementation started (I guess) with Windows 10, then was extended with the Anniversary Update and seems to be extended more in Windows 11 already.

You can set the terminal width to anything you like, as long as it's 132 or 80 columns. You can't set the terminal height at all. And, as you initially noted, the mouse is only "sort of" supported.

I agree that these are definitely drawbacks. I'm not sure so far if deprecation is necessary. For example given the part of the initial issue - that can be worked around be wrapping some of the mouse (and maybe other code) into #ifndef _WIN32 or similar (I guess there are also "alternative" terminals out there for win32 that actually implement the codes, but I don't know).

GitMensch avatar Sep 12 '22 12:09 GitMensch