So, I've finally set up a Windows machine to be able to try things out myself.
And my total and complete surprise, this super-simple thing is not working.
I have reduced the test to the bare minimum - and still works in a very bizarre way:
import rdstdin
echo "GOT: " & readLineFromStdin("Write something here:")
On Linux & Mac, this works fine. Meaning: it prints the prompt ( Write something here: ), gets the answer and prints it out too.
On Windows (using MSYS2 - I'm warning you (lol), don't swear that I know what all these one zillion terminal-like things on Win are...), it expects the input straight away (without printing anything at all), and once pressing enter, it shows:
Write something here:GOT: dsdfsd
Seeing the implementation here (https://github.com/nim-lang/Nim/blob/version-1-6/lib/impure/rdstdin.nim#L25), I'm starting to think that the stdout needs "flash"ing before getting the input, but still not sure.
Either way, something so basic should be working for all terminals.
Any ideas?
For reading from stdin I do something like this:
for line in stdin.lines:
echo line
break
On Windows (using MSYS2
it works fine on powershell and CMD
stdout needs "flash"ing before getting the input, but still not sure.
yeah you're right. adding stdout.flushFile after line 29 solves the problem