Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:40 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Change Text Color

Author Message
frnno967
Senior Member

Joined: 02/10/2020
Location: United States
Posts: 104
Posted: 08:43pm 11 Oct 2020
Copy link to clipboard 
Print this post

I couldn't understand from reading the CMM2 manual how to change the color of text on the VGA console. Is there a command to change it on the fly? Like if I want:

TEXT ONE to be White on Black background
TEXT TWO to be Green

Thank you.
Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 08:55pm 11 Oct 2020
Copy link to clipboard 
Print this post

Off the top of my head it is the final two parameters to the TEXT command, check the manual.

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:56pm 11 Oct 2020
Copy link to clipboard 
Print this post

Two methods depending on how you are printing the text

  Quote  CLS
PRINT "TEXT ONE to be White on Black background"
COLOUR RGB(GREEN), RGB(BLACK)
PRINT "TEXT TWO to be Green"

TEXT 200,200,"RED", cm,5,1,RGB(RED)



Jim
VK7JH
MMedit
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 09:01pm 11 Oct 2020
Copy link to clipboard 
Print this post

Hi
how about this (s. manual):
COLOUR fore [, back]
or
COLOR fore [, back]

Sets the default colour for commands (PRINT, etc) that display on the on the
VGA monitor. 'fore' is the foreground colour, 'back' is the background
colour. The background is optional and if not specified will default to black.

or this?
TEXT x, y, string$
[,alignment$] [, font] [, scale]
[, c] [, bc]

Displays a string on the VGA monitor starting at 'x' and 'y'.
‘string$’ is the string to be displayed. Numeric data should be converted to a
string and formatted using the Str$() function.
' alignment$' is a string expression or string variable consisting of 0, 1 or 2
letters where the first letter is the horizontal alignment around 'x' and can be
L, C or R for LEFT, CENTER, RIGHT and the second letter is the vertical
alignment around 'y' and can be T, M or B for TOP, MIDDLE, BOTTOM.
The default alignment is left/top.
A third letter can be used in the alignment string to indicate the rotation of
the text. This can be 'N' for normal orientation, 'V' for vertical text with each
character under the previous running from top to bottom, 'I' the text will be
inverted (ie, upside down), 'U' the text will be rotated counter clockwise by
90º and 'D' the text will be rotated clockwise by 90º
'font' and 'scale' are optional and default to that set by the FONT command.
'c' is the drawing colour and 'bc' is the background colour. They are optional
and default to the current foreground and background colours.

See the chapter "Basic Drawing Commands" for a definition of the colours
and graphics coordinates.



causality ≠ correlation ≠ coincidence
 
frnno967
Senior Member

Joined: 02/10/2020
Location: United States
Posts: 104
Posted: 09:11pm 11 Oct 2020
Copy link to clipboard 
Print this post

That worked perfect, thanks!

I'm trying to figure out how to change text color on the fly for the ANSI colors in the terminal program I'm working on. I guess text will have to be printed one character at a time so that the color can be changed? but this is a great start, much appreciated!
Jay Crutti: Ham Radio Operator, K5JCJ. Computer Enthusiast. Musician. Engineer.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:35pm 11 Oct 2020
Copy link to clipboard 
Print this post

Whenever you receive the esc[ nnn m sequence you set the appropriate colour or attribute

The sequence can have multiple nnn separated by semicolons, usually when you want to set foreground and background at the same time.

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025