Solved

changing colour of font and background

Posted on 2000-04-18
1
253 Views
Last Modified: 2013-12-03
Hi there..

I'm trying to change the colour of the background and font using C in Linux. I was using ncurses  to do this, but if there's an easier way (perhaps using vagal??) I'm interested...

I had something like this:

start_colour();

init_pair(COLORPAIRS-1, COLOR_GREY, COLOR_GREEN);

I know this alone won't do it.. I think I need to use wattrset, but I'm not sure of it's arguments (set to specified window?!). Also, what's the first argument of init_pair for? (couldn't follow the man page..)  Am I on the right track with this? Do I need to use printw instead of printf now for everything?

Also, is it possible to change font size from here?

Cheers,
  Gavin
0
Comment
Question by:teatowel
1 Comment
 
LVL 2

Accepted Solution

by:
fremsley earned 125 total points
ID: 2726882
You could send the control sequences directly to the console / terminal. The easiest way would be to hard-code the ANSI sequences (like <ESC>[42m) into your program, but to stay platform-independent I recommend getting the terminal type from the $TERM variable and parse the corresponding entry in the /etc/termcap (man termcap).

Of couse this is quite a bit of work, on the other hand you do not have to link your applications with a large library when you only need this single functionality.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now