[Gambas-user] 2 console questions.
Rolf-Werner Eilert
eilert-sprachen at ...221...
Mon Mar 17 10:20:21 CET 2014
Now I will answer to your original questions:
Am 15.03.2014 01:03, schrieb Γιώργος Κ:
> 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).
There is getch(). Try it and tell me if it's what you're looking for.
>
> 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! :-)
Long time ago, I made something like that for a Linux terminal. Let's
look into Rolf's archive :-)
Ok, maybe this helps. Here is one module I made which is for some screen
functions. In a Linux terminal, you need Esc[ strings to handle this,
and these strings are produced here. What you do is calling the
functions and building the strings into the string you send to the
terminal. If you have more questions, no problem...
Rolf
' Gambas module file
PRIVATE esc AS String = Chr$(27) & "["
PUBLIC CONST Black AS String = "0"
PUBLIC CONST Red AS String = "1"
PUBLIC CONST Green AS String = "2"
PUBLIC CONST Yellow AS String = "3"
PUBLIC CONST Blue AS String = "4"
PUBLIC CONST Magenta AS String = "5"
PUBLIC CONST Cyan AS String = "6"
PUBLIC CONST White AS String = "7"
PUBLIC CONST Foreground AS String = "3"
PUBLIC CONST Background AS String = "4"
PUBLIC FUNCTION Cls() AS String
RETURN esc & "2J" & esc & "H"
END
PUBLIC FUNCTION Normal() AS String
RETURN esc & "0m"
END
PUBLIC FUNCTION Bold() AS String
RETURN esc & "1m"
END
PUBLIC FUNCTION Gray() AS String
RETURN esc & "2m"
END
PUBLIC FUNCTION Underline() AS String
RETURN esc & "4m"
END
PUBLIC FUNCTION Blink() AS String
RETURN esc & "5m"
END
PUBLIC FUNCTION Reverse() AS String
RETURN esc & "7m"
END
PUBLIC FUNCTION MoveTo(row AS Integer, col AS Integer) AS String
IF row < 1 THEN row = 1
IF row > 25 THEN row = 25
IF col < 1 THEN col = 1
IF col > 80 THEN col = 80
RETURN esc & CStr(row) & ";" & CStr(col) & "f"
END
PUBLIC FUNCTION Color(FgBg AS String, Colorvalue AS String) AS String
RETURN esc & FgBg & Colorvalue & "m"
END
More information about the User
mailing list