Page 1 of 1

Console qustions.

Posted: Friday 15th May 2020 2:08pm
by Giorgos
Hi! :D

I was trying to familiarize myself with Gambas, so I'm in the process of porting some older console programs of other langs to Gambas.

I now have these questions:

1) What about some putting some color at program's console output.
I think, since at console there's no GUI, a colored text is an effective way to attract user's attention to something important.

Maybe ncurses is the answer to the above question?

2) What about sound output?
Nothing complicated. A single console's beep - notification, is enough for me.
I think it's complimentary to colored text (for attracting attention).

3) What about, some more advanced keyboard control?
Maybe something like the old GW commands Inkey or On Key (for setting a global shortcut)?

I already read the related forum post viewtopic.php?p=736#p736.
Maybe ncurses is a different approach to the same problem.

TIA! 8-)

Re: Console qustions.

Posted: Friday 15th May 2020 10:09pm
by vuott
Giorgos wrote: Friday 15th May 2020 2:08pm2) What about sound output?
My answer is relevant to your question about sound in Gambas.
I suggest you this specific and wide section of the wiki of Italian forum:

https://www.gambas-it.org/wiki/index.ph ... file_audio

Re: Console qustions.

Posted: Friday 15th May 2020 10:32pm
by Quincunxian
Hi Giorgos
Sound
Try this ALSA based command - it will need a bit of tweeking but it made some noise from my command line.
$( speaker-test -t sine -f 1000 )& pid=$! ; sleep 2.0s ; kill -9

Found the above solution Here at StackExchange.

Colour

I 'sort of ' remember doing something this back in my old Dos days when writing Autoexec.bat menu commands.
echo -e "\e[1;31m This is red text \e[0m"

Found this solution ( and a lot of other command line stuff) Here at O'Reilly.com

Re: Console qustions.

Posted: Monday 18th May 2020 12:28am
by Giorgos
THANKS guys!!! :D
I'll try them.

Re: Console qustions.

Posted: Friday 10th July 2020 12:25am
by Technopeasant
For reference, you can also get it to beep using ncurses.

Screen.Beep

As for colour, it can be done rather simply.

Window.Print("String ", X, Y, Attr.Normal, Pair[Color.Red, Color.Green])

Where the first of the pair is foreground and the second is background.

The whole window can be done using the foreground and background properties.

Window.Background = Color.Bue

I have also generated noise with this command.

Exec ["play", "-n", "synth", "1", "sine", Rnd(1, 500)]