mattn / go-tty

MIT License
208 stars 18 forks source link

Fix: the unicode from U+2000 to U+2FFF could not be gotten #38

Closed hymkor closed 3 years ago

hymkor commented 4 years ago

I found some characters between U+2000 and U+2FFF which can not be gotten by ReadRune in Windows. For example, and .

We can see the problem as below. (I did on Windows10)

  1. Copy ∞Ⓓ to the clipboard on the web browser.
  2. go run _example/readline.go
  3. Paste those characters from the clipboard by mouse-right-button.
  4. We expect all of them are inserted, but we see no ones are inserted.

( See also https://github.com/zetamatta/nyagos/issues/390 . And https://github.com/judah/haskeline/issues/54 may be the similar problem )

I made the test program and saw the strange data from ReadConsoleInput.

  1. On KeyDown event, the field UnicodeChar is zero. (Why!?)
  2. On KeyUp event, th field UnicodeChar is valid as expected.
  3. In some cases , trash data? may be inserted between two events.

I do not understand the reason that those input are given from ReadConsoleInput. But, I want to fix the problem, so I made the patch for a workaround. ( A better solution may be exist, but I could not find it.)

Would you merge this patch if problems do not exist , @mattn ?

mattn commented 3 years ago

Thank you. Please take me a little time to understand what this fixes.

mattn commented 3 years ago

Is this correctly on Linux?

hymkor commented 3 years ago

For Linux, I have not modified any codes for Linux-dependent and OS-independent part because I considered the codes for Linux do not call ReadConsoleInput directly.

As far as I experimented on WSL-1 of Windows10 now, go-tty looks to work finely when ∞Ⓓ are pasted whether my patch is included or not on Linux .

mattn commented 3 years ago

Thank you

hymkor commented 3 years ago

Thank you for merging. When I know the reason for the behavior of ReadConsoleInput , I would report it or send a better code.