Open rebolbot opened 16 years ago
Submitted by: BrianH
This might not get fixed in the Windows console - we might have to wait for the GUI console. However, chat could use this for passwords, so if it's doable we should.
Submitted by: manum
/hide disappear from input implementation, but it is used at ask source
>> source ask
ask: make function! [[
"Ask the user for input."
question [series!] "Prompt to user"
/hide "mask input with *"
][
prin question
trim either hide [input/hide] [input]
]]
When Rebol connects to a source of input like stdin
, there is no (standard) way in C to suppress the input being echoed to the screen. So the /HIDE feature is simply not possible then.
The Windows console implementation of R3-Alpha uses a kind of "black box" which does line-based Unicode input, and handles things like cursoring around and deleting. Without using a lower level set of console APIs and taking responsibility for everything, it's extremely limited in what it can do. The line input doesn't let you even do things like intercept the escape key and respond to it--much less overwrite the visibility of characters. It can't intercept clipboard pastes and do any processing on the input either, which means if the clipboard lacks carriage returns and only newlines, the data gets smooshed:
https://stackoverflow.com/questions/52912349/intercept-clipboard-paste-event-in-console-application
When using the <termios.h>
facilities in POSIX, there's more flexibility which could implement this feature. Unlike in the Windows build which just makes one function call to get a line, the termios build actually implements all of the logic for responding to key events and editing the line--in C. This is one of the things someone could figure out how to do, if there was a way established to pass the "/HIDE" flag to it. But again, you'd have to build with a "smart" console that did termios vs. stdin.
A Rebol GUI which interacts with the message pump and can draw anything it wants or get any keystroke it wants clearly has full control, and would have few barriers to implementing this.
What would be more ideal would be if the console://
device were made abstracted across POSIX and Windows console and the GUI to offer up individual key events. Then the line editing code in C from the termios build could become Rebol code and work across both platforms (or any platform that implemented console key eventing and I/O, including some kind of dialect for color changes and cursor movement...telling the program the width and height of the screen, etc.)
input/hide
can be implemented using SetConsoleMode
on Windows and tcsetattr
on Posix.
http://forums.codeguru.com/showthread.php?466009-Reading-from-stdin-(without-echo)&p=1786376#post1786376
@hostilefork some kind of dialect <= there is such a dialect used for ages - ANSI escape sequences.. but I know that you don't like them.
Problem with my above commit is, that not all POSIX terminals seems to support these 2 ASNI sequences. And of course, that it does not display asterix chars, but that can be considered as more secure, because it does not reveal information, how many chars has the secret something.
Submitted by: Jerry
I can still see what I am typing.
CC - Data [ Version: alpha 31 Type: Bug Platform: All Category: Unspecified Reproduce: Always Fixed-in:none ]