[PATCH v3 0/1] Pseudo console support in PTY (v3)
Thomas Wolff
towo@towo.net
Sun Apr 7 21:21:00 GMT 2019
Am 07.04.2019 um 07:05 schrieb Takashi Yano:
> Hi Thomas,
>
> Thank you very much for testing.
You're welcome; I'm very interested in this solution, not only, but also
because the interoperability problems cause a series of problem reports
to mintty.
> On Sat, 6 Apr 2019 23:33:04 +0200 Thomas Wolff wrote:
> ...
>> Terminal reports "\033[6n" and "\033[0c" are apparently emulated and
>> sent in reverse order;
>> response to primary device attribute request is wrong (not what mintty
>> would report).
>> There is no response to secondary device attribute request ("\033[>0c")
>> and others,
>> e.g. '\033[18t' or '\033]10;?\033\' and many others; why can't these
>> requests be passed to the terminal and handled transparently? (You
>> explained something around handles before but I don't get the point.)
> This is not caused by my intercept, but pseudo console itself.
> Unfortunately, pseudo console is not transparent at all. Pseudo
> console interprets VT100 sequences in output and processes them.
> Then, it fowards another VT100 sequences to the pipe associated
> with the pseudo console.
OK, understood. So ConPTY is not only a pty adapter but also a kind of
half-terminal emulator, like tmux or screen.
>
>> Output to alternate screen seems to be forced to the primary screen, mostly;
>> if I try to switch screen in various ways (menu, echo "\033[?1047h" >
>> /dev/pty1, before or while cmd.exe runs),
>> behaviour appears to be inconsistent and not as expected (expected
>> behaviour is that any output goes to the active screen).
> Hmmm, this may be caused by "synchronization". I will also check this.
>
>> Again, I don't see a need that you intercept this at all.
> The patch attached disables all my intercept. It is against v3.
> Please check the output from PTY using script command with this
> patch. You can use your test case for the test. You will find many
> VT100 ESC secuenses you don't write to console. These are written
> by pseudo console itself.
OK, I may find time to analyse that. Meanwhile, my test case for the
above unfortunately still fails with the "disabling" patch:
Start mintty, run `tty`, let's say it says /dev/pty0.
In mintty, run cmd.
In another shell (mintty or not), run echo "\033[?1047h" > /dev/pty0.
In mintty, in cmd, type dir... nothing happens. "dir" will be echoed and
its output shown in unpatched cygwin.
> Also, you can confirm screen layout is broken if you run cygwin
> apps and native console apps alternately. "Synchronization" is
> necessary to avoid this, I think.
I have not observed any "broken" screen layout, but I notice a cleared
screen when starting cmd (does not clear in unpatched cygwin). Other
non-cygwin programs, like java, do not clear the screen. Do you have an
explanation?
> On Sat, 6 Apr 2019 23:33:04 +0200 Thomas Wolff wrote:
>> Character output conversion works with my test program (using
>> WriteConsoleW). Using java, output works too (with proper java encoding
>> option), but non-ASCII input characters are replaced by and echoed as space.
> Indeed... I will fix it.
> Once, I thought I could reproduce, however, I cannot reproduce this
> now. Could you please let me know how you tested.
I'm attaching my Java test program below.
I compile it with javac -encoding UTF-8 and run it with java
-Dfile.encoding=UTF-8. This makes non-ASCII output work in a UTF-8
terminal. Non-ASCII input however is blanked.
Kind regards,
Thomas
import java.io.*;
public class JavaPW
{
 public static void main(String args[]) throws IOException
 {
   System.out.println("Writing Unicode: bäh 3â¬");
   BufferedReader rd = new BufferedReader(new
InputStreamReader(System.in, "UTF-8"));
   System.out.println("Reading input from System.in");
   System.out.println("Please enter your input: ");
   String input = rd.readLine();
   System.out.println("User Input from System.in: " + input);
   Console console = System.console();
   System.out.println("Reading input from console");
   System.out.println("Please enter your input: ");
   input = console.readLine();
   System.out.println("User Input from console: " + input);
   System.out.println("Reading password from Console in Java: ");
   //password will not be echoed to console and stored in char array
   char[] password = console.readPassword();
   System.out.println("Password entered by user: " + new
String(password));
 }
}
More information about the Cygwin-developers
mailing list