LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-30-2005, 11:13 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Formated output from C


I would like to know if there is any way to create some nice formatted output (like bold text) to the console in C. I have played a little with ncurses before but that creates a new "windows" which is destroyed when the program dies.

Regards.

Last edited by Ephracis; 05-30-2005 at 11:17 AM.
 
Old 05-30-2005, 12:15 PM   #2
kryptonite0110
Member
 
Registered: Mar 2005
Posts: 59

Rep: Reputation: 15
in linux you use escape codes, youse the termios structure and set: c_oflag |= OPOST for output processing, and then (i believe) you can just write your standard escape sequences to stdout:

http://www.faqs.org/docs/Linux-HOWTO...CAPE-SEQUENCES
 
Old 05-30-2005, 12:56 PM   #3
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 50
Wasn't the site at that url just talking about changing the bash prompt? How would I do if I wanted to use something like printf and get output in bold?
 
Old 05-30-2005, 04:07 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Run this program and see if you can learn anything from it:
Code:
#include <stdio.h>

int main(void)
{
  int i, color, attrs[] = { 0, 1, 5, 7 };

  for(i = 0;i < 4;++i)
  {
    printf("\33[0;37m%d | ", attrs[i]);
    for(color = 30;color < 38;++color)
      printf("\33[%d;%dm%d ", attrs[i], color, color);
    printf("\n");
  }

  printf("\33[0;37m");
  return 0;
}
EDIT: A google search on "ansi escape codes" will give you lots of good information about it.

Last edited by itsme86; 05-30-2005 at 04:09 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
deleted, formated, lost . Linux to the rescue! oldstinkyfish Linux - Software 4 08-02-2005 03:26 PM
formated, but can't install linux again AgentDukey Slackware 6 11-02-2004 12:28 PM
lilo stoped working after formated winXP A Cow Mandriva 4 07-11-2004 02:49 PM
Reading cds that were formated with direct cd deepsix Linux - Software 4 09-03-2003 11:19 PM
How do you read a UDF formated CDROM? calimer Linux - Newbie 4 12-29-2002 11:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration