[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

changing colour of font and background

Posted on 2000-04-18
1
Medium Priority
?
296 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 375 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

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 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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

834 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