Solved

changing colour of font and background

Posted on 2000-04-18
1
250 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

22 Experts available now in Live!

Get 1:1 Help Now