Closed cwenner closed 7 years ago
Hi Cenny,
Thank you for this detailed report, it is really useful!
Firstly, I would recommend for you to read similar issue posted recently for deeper understanding of where I am with Windows support.
When I developed this tool I haven't had Windows in mind at all and never tested it on this system. I currently don't have access to Windows but I will try to download ISO for Windows 10 to play with. I'm happy to merge any patches that actually fix the issues mentioned above and make this tool available for Windows users but this is not my priority.
The plan for the next v0.9.0
release is to:
in
operator to accept array like dataAs you can see this is a bit of a task and until this is done I won't be in position to investigate Windows. Do you have time yourself to help out fixing this stuff?
This library relies heavily on ANSI escape sequences for controlling input/output. I wonder if that's a missing factor in Windows 7 terminal. Could you please install ANSICON utility and see if that fixes the issue? see tutorial
It runs fine when running through the windows linux subsystem, but that of course may not be a suitable choice for many cases.
@kke Would you mind checking master again? I have changed how inputs are read and fixed multibyte characters support. I'm not swearing by it but it seems that this library works fine on regular Windows without linux subsystem according to these tests on Windows box
Passing tests won't prove much in this case I think. The select/multi select things are still not working, no change from #25
I don't have the ansicon thing.
I think the tests prove only that if you have ansi strings support on windows then this library works no problem. I really would need someone to install the ansicon or similar library in console to prove or disprove this theory. Because only then I could add a section in docs to advise people how to use this library. Would you have time to help me out?
It looks a bit worse using ansicon it seems.
Cursor keys still do nothing, not in keypress.rb either.
Pressing enter now correctly clears the menu, without ansicon it didn't, but just threw the prompt to the middle of it:
(it might be that i just don't know how to use ansicon. trying to reboot after ansicon -i now) (update: no effect)
Since the help text and initial option are not highlighted in color, it makes me think that ANSI escape codes are still not recognised. Hence you cannot move up or down but can press enter.
Please have a look a this thread that provides possible fixes for win32 console.
The weird characters in your output are unicode characters that are probably not supported, that would be an easy fix.
Last idea to try out. Could you please install the win32console
gem and require it before tty-prompt
. Looking at the source, the gem rewrites Ruby printing of escape codes with Windows support.
Now ansicon made my dos prompt slower than a 300bps modem so I guess it's loaded and doing something, but the colors are still not there.
win32console requires some native stuff to be compiled, and I don't have any compilers.
Hmm according to https://github.com/symfony/symfony/issues/17499#issuecomment-243481052 windows 10 should not need ansicon.
That's true but you still need to enable flag manually to turn ANSI support on windows 10 on as I think it's off by default.
ENABLE_VIRTUAL_TERMINAL_PROCESSING
to enable ANSI escape sequences
If that worked we could at least say this works in Windows 10.
I think it's a ruby build issue. You would need to compile a ruby with the flag enabled. Maybe they could make it so in the official release.
I think this is a OS flag and you could flip it on through your Ruby code if you directly called out a C function setConsoleMode through Ruby bindings.
Wow, thanks you for the quick and thorough responses. Unfortunately I only have a running Windows partition at work atm and I cannot motivate spending too much time on this - I just thought the library would be perfect for a utility.
If you do not support Windows, it's entirely understandable. I did not see any information about it in the Readme so it seems I jumped the gun by assuming it was meant as a cross-platform utility.
I tested Ansicon (1.66, precompiled x64 bin, then x86 bin for complteness). The issues above change somewhat.
These are the corresponding results of the two screenshots in the initial post:
Before entering name (same as before):
After entering name and pressing enter once (different):
Ie it is still skipping the yes/no question (perhaps due to the carriage return?).
It still overwrites previous lines, though differently.
The secret works significantly better. It no longer beeps and does accept characters which are masked. The masking characters are however gobbled. Unicode issue if I had to guess - the Ansicon readme does not seem to mention anything of relevance. From the secret "abc", the display is:
The arrow keys still do not work for the select.
The select prompt looks different from the Readme examples and from @kke's screenshot above (again unicode?)
Did not notice this before, but both in cmd and in ansicon, pressing non-arrow keys in select
raises an exception ('c', 'j' and 'r' tested):
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/prompt/mask _question.rb:44:in
keypress
: undefined method+
for nil:NilClass (NoMethodEr ror) from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wisper-1.6.1/lib/wisper/broadcasters/send_broadcaster.rb:5:inpublic_send
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wisper-1.6.1/lib/wisper/broadcasters/send_broadcaster.rb:5:inbroadcast
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wisper-1.6.1/lib/wisper/registration/object.rb:16:inbroadcast
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wisper-1.6.1/lib/wisper/publisher.rb:65:inblock in broadcast
from C:/Ruby23-x64/lib/ruby/2.3.0/set.rb:306:ineach_key
from C:/Ruby23-x64/lib/ruby/2.3.0/set.rb:306:ineach
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wisper-1.6.1/lib/wisper/publisher.rb:64:inbroadcast
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/prompt/reader.rb:166:inemit_key_event
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/prompt/reader.rb:79:inblock (3 levels) in read_keypress
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/prompt/reader/mode.rb:36:inraw
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/reader/mode.rb:36:inraw
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/reader.rb:77:inblock (2 levels) in read_keypress
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/reader/mode.rb:24:inecho
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/reader.rb:76:inblock in read_keypress
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/reader.rb:60:inbuffer
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/reader.rb:75:inread_keypress
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/list.rb:167:inrender
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt/list.rb:96:incall
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt.rb:231:ininvoke_select
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/tty-prompt-0.8.0/lib/tty/pro mpt.rb:167:inselect
from tty_test2.rb:10:in<main>
@cwenner This is super helpful. The only thing I would suggest for the future is to test against the master branch as there may be some tiny improvements. I will soon release a new version as well.
Based on these discussion so far I have a few things to look at on Windows:
Any other thoughts what I can investigate that may help to provide basic Windows support?
I've released v0.10.0
that fixes the 'cannot find the path' issue and enables colors on windows. I have finally managed to investigate windows in vm. What appears to be the case is that Ruby really cannot gather character input on Windows. I will need to call to native C apis to get single character input with echo/no echo behaviour. The only thing you can get successfully on Windows is enter, anything else is botched which explains why simple prompts kind of work. This won't be a quick fix but I feel that I stand a chance to make it work on windows!
@cwenner @kke @danielpclark I could do with some help checking Windows. Pretty much all prompts should work as expected apart from mask
. Things I have done:
select
, multi_select
finally work as expectedThis is all available in master branch, I haven't released a new version yet.
select
, multi_select
, ask
, yes?
all seem to work fine from master in a Win10 virtual machine.
I think your windows?
is true for cygwin (or MinTTY which also comes with git for windows). Seems like the windows keyreader does not work under it. (the normal non-windows stuff should work fine)
I use windows xp image in my vm, but I think other people having a go at testing may uncover different things. I'm happy to refine the current windows?
check but I wouldn't want to make this a show stopper. It is obviously a double negative cause when people use cygwin the normal unix mode should be just fine provided this check is fixed.
I'm going to close this ticket as the said issues have been fixed and any future problems like cygwin will warrant a new ticket.
Hi,
not sure if I am missing something obvious here but I get multiple issues when trying TTY::Prompt on Windows 7.
Issues
Specifically, when running the first four examples from the readme - prompt name, like ruby?, secret, destiny - the following happens:
Code tested
Screenshots
Before entering name (the first line is a standard Windows warning and translates to "Cannot find path"/"The system cannot find the path specified."?):
After entering name and pressing enter once (note how second prompt is printed but not queried):
Environment
Additional info
tty-prompt seems like a great tool for making terminal applications otherwise and not sure if others experience this issue. It might just be Windows 7 or the company environment.
Thanks and merry xmas, Cenny