2014-03-15 2:38 GMT+02:00 Tobias Boege <tabo...@gmail.com>:
> On Sat, 15 Mar 2014, ??????? ? wrote:
>> Hi! :-)
>> Thank you very much for this wonderful project!
>>
>> I just installed it and giving it a try.
>> I have 2 questions, console programming related.
>>
>> 1) Is there any command Input-like, that allows for a specific number
>> of characters input (without pressing Enter)?
>> Eg. lets say, I'm presenting the user a Y or N question. What I
>> expect, is a single character input (with no need, for pressing
>> Enter).
>>
>> 2) Is there any way for coloring the text (eg. presenting a question
>> with red or green letters), other than messing with ncurses?
>> Something closer to BASIC tradition, maybe?
>> Ncurses is more or less complicated! :-)
>>
>
> Ouch! I was already typing the answer: ncurses - then I read your last
> paragraph :-) But maybe we can try without:
>
> 1) There is nothing to do that. Terminal is line-buffered by default, so you
>    will always have to wait for Return and then read the entire line using
>    the Line Input instruction. In the best case, the line will only consist
>    of "y" or "n" or "Y" or "N".
>
>    You can change the behaviour of the terminal but that would either
>    require messing around with struct termios using libc or using ncurses
>    which wraps that for you.
>
> 2) This is easy once you get used to it. You just have to know about escape
>    sequences. If you have a proper man-pages install, "$ man console_codes"
>    is your best friend.
>
>    To switch to, say, green foreground, you write in Gambas:
>
>      Print "\e[32m";
>      Print "This is green foreground"
>
>    of course, you need to switch that off at some point:
>
>      Print "\e[0m";
>      Print "Default rendition again"
>
>    Again, ncurses would wrap that for you.
>
> The Gambas Console (which is built into the IDE to watch a program's stdout
> and stderr) is not a full-featured terminal emulator. It won't interpret
> those escape sequences, so you need to enable the "Use a terminal emulator"
> option in the project options.
>
> Note also that there is already a gb.ncurses component that helps you deal
> with ncurses in the Gambas way (more or less). As you said you are new to
> Gambas, I thought I should let you know... (attached is a project that shows
> how you could have done the stuff with gb.ncurses).
>
> Here[0] is also a tutorial introduction to gb.ncurses which explains the
> setup to run those terminal-fancy programs. Have fun with Gambas!
>
> Regards,
> Tobi
>
> [0] http://gambaswiki.org/wiki/tutorial/ncursestut
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------------------------
>


MANY THANKS Tobi for your help!!! :-)

2) I already read the wiki, but I'm not sure that I understood much things! :-)
Now that you pointed me, at the right direction, everything becomes clearer!

I have to mess with ESC sequences for > 20y! :-)
>From the time, I was entering them at EDLIN, for beautifying my
ANSI.SYS enabled, command prompt.
At recent times, since Bash is configured differently, I never touched
them again.
Yes, I'm familiar with them and now it's the right time for refreshing
my memory I suppose! :-)

1) Creating a custom ncurses wrapper?
Very interesting idea!!!
I'll look at it.

I'll look the example at the morning.
THANKS AGAIN for your really fast and really enlighting help!!!
Giorgos. :-)

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to