开发者

How to disable stdin echo in windows console

开发者 https://www.devze.com 2023-01-22 15:23 出处:网络
I\'m writting a Ruby program for windows, and I need to read user input from keyboard (stdin). However, it\'s ne开发者_StackOverflow社区eded that the user key-presses are not automatically displayed

I'm writting a Ruby program for windows, and I need to read user input from keyboard (stdin).

However, it's ne开发者_StackOverflow社区eded that the user key-presses are not automatically displayed in the windows console, and behave like "silent key presses"

This problem in Ruby over linux, can be solved using the "stty" linux command:

%x{stty -icanon -echo} 

because it is the linux terminal who automatically outputs the user-keys into the terminal, so running the "stty" command tells the terminal to stop showing the user-key-presses.

But my program must run in windows, so I tried searching for a "stty" equivalent command for windows console, but still found nip...

?any suggestions, pointers ?


Look at Highline gem. To clarify, look at ask method and provide a block to silence it's output. It is well exemplified in their documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消