Console qustions.

Post your Gambas programming questions here.
Post Reply
User avatar
Giorgos
Posts: 4
Joined: Tuesday 12th May 2020 12:32pm

Console qustions.

Post 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-)
For the glorious men, every land is a grave.
Thucydides "Pericles Funeral Oration".
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: Console qustions.

Post 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
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Console qustions.

Post 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
Cheers - Quin.
I code therefore I am
User avatar
Giorgos
Posts: 4
Joined: Tuesday 12th May 2020 12:32pm

Re: Console qustions.

Post by Giorgos »

THANKS guys!!! :D
I'll try them.
For the glorious men, every land is a grave.
Thucydides "Pericles Funeral Oration".
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: Console qustions.

Post 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)]
Technical director,
Piga Software
http://icculus.org/piga/
Post Reply