Console qustions.

Post

Posted
Rating:
#1 (In Topic #410)
Avatar
Trainee
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 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".
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’

Giorgos said

2) 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:

  Guide della comunità - Gambas-it.org - Wikipedia

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
Hi Giorgos
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
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Trainee
THANKS guys!!!   :D
I'll try them.

For the glorious men, every land is a grave.
Thucydides "Pericles Funeral Oration".
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
Technopeasant is in the usergroup ‘Regular’
 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)]
Online now: No Back to the top
1 guest and 0 members have just viewed this.