Colored text in CLI
Colored text in CLI
As you probably know DOS, Linux and Windows supports colored text in their consoles (16 for foreground and 8 for bg). But how to change text color in CLI in FB?
Re: Colored text in CLI
From the help
Color : Sets the display foreground / background color that is used with console output and graphics output of text
Syntax : Declare Function Color ( ByVal foreground As Integer , ByVal background As Integer ) As Integer
Usage : Color [foreground] [, background]
result = Color [( [foreground] [, background] )]
Parameters
foreground = the foreground color to set
background = the background color to set
Color : Sets the display foreground / background color that is used with console output and graphics output of text
Syntax : Declare Function Color ( ByVal foreground As Integer , ByVal background As Integer ) As Integer
Usage : Color [foreground] [, background]
result = Color [( [foreground] [, background] )]
Parameters
foreground = the foreground color to set
background = the background color to set
Code: Select all
' Sets 320x240 in 32bpp color depth
Screen 14, 32
' Sets orange foreground and dark blue background color
Color RGB(255, 128, 0), RGB(0, 0, 64)
' Clears the screen to the background color
Cls
' Prints "Hello World!" in the middle of the screen
Locate 15, 14
Print "Hello World!"
Sleep
Re: Colored text in CLI
You did not understand my post, right? I want to do it in CLI w/out setting graphic mode (which will also spawn graphics window on Linux/Windows). Purely in CLI, like QBasic had different colors for its menus, etc. or Turbo Pascal had syntax highlight.
Re: Colored text in CLI
COLOR also works in console, you don't need a screen. It's always a good idea to read the wiki.
Code: Select all
Print 1234
Color 3, 0
Print 1234
Sleep
Re: Colored text in CLI
I understood it and my answer was right. Only the example was not corresponding.....I suppose you didn't read carefully the text of the post. But it doesn't matter ;-)darkhog wrote:You did not understand my post, right? .
Re: Colored text in CLI
Sorry. Was very furious when I wrote my 2nd post, because my girlfriend dumped me and that probably affected my judgment and way I wrote previous post. Again, sorry.
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Re: Colored text in CLI
For what it's worth, the documentation page is online at http://www.freebasic.net/wiki/keypgColor. It's easier to see the code in its context there as a not-necessarily-entirely-relevant example.