Solved

changing colour of font and background

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
shell script working with --daemon 18 96
Chinese chars 2 72
Problem with Frankling Gothic Book font 5 94
how awk substr works and also how index works in inside substr? 4 127
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 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