From: James Edward Gray II Date: 2005-05-10T09:34:59+09:00 Subject: Re: HighLine 0.4.0 On May 9, 2005, at 5:24 PM, Vincent Foley wrote: > How did you handle the noecho thing on different platforms? I looked > at the getpass.py Python module, they used a module called msvcrt > which > had a getch() function which reads a character without echoing it. > The > whole Windows function seemed rather hackish in my opinion. I used pretty much what Ryan showed. I'm not too troubled by using the Win32API to character read. That seems pretty solid. I've seen that solution in many places over the years and HighLine was using it even before we started talking passwords and Ryan showed his version. (If you look back, you'll see that I wrote about it in the summary to Ruby Quiz #5.) I'm almost never on Windows, but the couple of times I've tried it there, it worked perfectly. Hunting for a carriage return feels a little more shaky to me, but I would still be doing that if I was using a different getch() routine, right? It too seems to work. Personally, I find the Unix hack more troubling. HighLine has been using the external stty for character reading and still is. I agree with Andre that there's probably a better way. I played with termios quite a bit for this release, but I'm not convinced it's a better solution. Just to give one example, the stty trick works on Mac OS X out of the box, but I believe you can only install termios if you've installed Apple's optional Developer Tools. (I haven't tested that.) Here again, I've never seen the stty "hack" not work. For now at least, I'm calling it good enough. The moral: File a bug report if you have problems. Oh, and be sure it includes your patch it fix it. :) Nothing like releasing code into the wild to see just how much it doesn't work, eh? I really do want HighLine to work (well!) on at least Windows and Unix. I am trying to make the decisions to make that happen with my imperfect information. Feel free to enhance my knowledge at any time! James Edward Gray II