Console Application Input, hints needed :)

Discuss any general programming issues here
Post Reply
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Console Application Input, hints needed :)

Post by Allanon »

Hello guys,
I'm writing a console application that will run mostly on Linux shell, I've already implemented a nice library to handle escape sequences for colored text, cursor movements, message boxes, menu, etc... that I will publish when it will be completed.

I'm having a hard time to find a way to wait for a single character without the need to hit the enter key, which is required by the DebugPrompt()/ConsolePrompt() commands.

I've implemented a GridView and hitting enter after every command is very annoying (for example to scroll down the list line by line).
InKeyStr() can't ne used because Hollywood display is closed, this is a console app :)

Any tips? I'm missing something?
I've thought about opening for input the stdin, but I'm quiet a Linux newby so every hint in that direction is really appreciated :D
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Console Application Input, hints needed :)

Post by airsoftsoftwair »

That's probably not possible at the moment but could be added quite easily if you need it. Manually opening stdin won't work because OpenFile() doesn't support that... the only trick I can think of is starting a shell script which does it and then passes the result back to Hollywood via a temporary file but that's really awkward.
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Console Application Input, hints needed :)

Post by Allanon »

Thank you Andreas for the answer,
well, I'll live with it for now, using a temporary file with another shell doesn't seem a solid way to achieve it.

If you are going to implement this function it could be handy for other people too who want to develop console applications :)
If it's possible an idea could be to add optional parameters to the ConsoleInput/DebugInput like InKeyStr, with type, maxlen and password arguments.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Console Application Input, hints needed :)

Post by airsoftsoftwair »

Allanon wrote: Wed Jan 22, 2020 8:49 am If you are going to implement this function it could be handy for other people too who want to develop console applications :)
If it's possible an idea could be to add optional parameters to the ConsoleInput/DebugInput like InKeyStr, with type, maxlen and password arguments.
Yes, but I think I'll also add some special constants for OpenFile() that allow you to directly open stdin, stdout and stderr. Could be quite useful for several purposes...
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Console Application Input, hints needed :)

Post by Allanon »

Great! :D
Thank you for the efforts!
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Console Application Input, hints needed :)

Post by airsoftsoftwair »

Code: Select all

- New: OpenFile() also accepts the special constants #STDIN, #STDOUT, and #STDERR now to open a program's
  standard input/output/error streams; this can be useful for advanced users
Post Reply