Chaning color of text using C in CLI mode
hey all,
I am writing a simple text-based fighting game and I would like to know how to change the color of the text to be printed to the screen. I am not using SDL, SVGA-LIB, GTK,ALLEGRO or any of those libraries. I would like to know if it is possible to change the color of text for CLI only. Without using any graphics libraries. Any help is greatly appreciated. |
Yes; you probably want to look into using curses/ncurses so that your code can work in just about any terminal emulator, terminal, console, etc.
|
I will try the ncurses/curses library but.... Is there a way to do it and the program still be portable to Dos?( I know.. I know this is a Linux site.. but I would like to port to Dos... NOT WINDOWS!)
What I'm asking is... is there a way to write the program and display different colors and have the same program able to compile under Dos? |
i dont think curses is available for dos, the only thing i can think of is to write a class that abstracts curses from your actual program and and then write a dos implementation of the same calls, so your code is the same but you have a class that makes the appropriate calls depending on operating system.
|
Re: Chaning color of text using C in CLI mode
Quote:
Code:
#include <stdio.h> Search for ANSI codes. You can do other stuff like bold, underline, blink, etc. |
THANKS! Angelo! That help so much .. :) .
I was just sick and tired of writing boring grey on black programs... but now.... Anyway thanks for the help everyone. P.S. After I'm finished version 0.8beta of the game then I'll post the link to it okay? And anybody who helped me with this problem can download a copy. Cheers, :) :) |
i dont think that'll work on all terminal types there was another thread about this i'll try to find it later.
|
Any linux terminal that supports ISO 6429 sequences should be alright.
|
All times are GMT -5. The time now is 01:56 PM. |