Console qustions.
Posted
#1
(In Topic #410)
Trainee
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 https://forum.gambas.one/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".
Thucydides "Pericles Funeral Oration".
Posted
Regular

My answer is relevant to your question about sound in Gambas.Giorgos said
2) What about sound output?
I suggest you this specific and wide section of the wiki of Italian forum:
Guide della comunità - Gambas-it.org - Wikipedia
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Expert

Sound
Try this ALSA based command - it will need a bit of tweeking but it made some noise from my command line.
$<COLOR color="#008000">( speaker-test -t sine -f 1000 )& pid=$! ; sleep 2.0s ; kill -9 </COLOR>
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.
<COLOR color="#008000">echo -e "\e[1;31m This is red text \e[0m"</COLOR>
Found this solution ( and a lot of other command line stuff) Here at O'Reilly.com
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Trainee
I'll try them.
For the glorious men, every land is a grave.
Thucydides "Pericles Funeral Oration".
Thucydides "Pericles Funeral Oration".
Posted
Regular

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)]
1 guest and 0 members have just viewed this.


