Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jan 2010 21:21:36 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: curses init in one line?
Message-ID:  <20100118212136.95b56398.freebsd@edvax.de>
In-Reply-To: <20100118033426.GA7585@thought.org>
References:  <20100118033426.GA7585@thought.org>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Sun, 17 Jan 2010 19:34:29 -0800, Gary Kline <kline@thought.org> wrote:
> 
> 	this is going to sound a bit off the wall, and it may have only worked
> 	in FBSD [if I wasn't imagining it], but is there a way to get into 
> 	curses/ncurses mode in one short line?  it has been years but I think
> 	somebody sent me the magic code, for either a shell scrippt or a C
> 	program.  

It's quite easy, let me demonstrate it with this
example program:


/* curses_attributes_test.c (-lncurses required) */

#include <curses.h>

int main(void)
{
	initscr();
	cbreak();
	noecho();
	nonl();
	intrflush(stdscr, FALSE);
	keypad(stdscr, TRUE);
	start_color();


	attrset(A_NORMAL);
	printw("Normal display (no highlight)\n");
	printw("\n");

	attrset(A_STANDOUT);
	printw("Best highlighting mode of the terminal.\n");
	printw("\n");

	attrset(A_UNDERLINE);
	printw("Underlining\n");
	printw("\n");

	attrset(A_REVERSE);
	printw("Reverse video\n");
	printw("\n");

	attrset(A_BLINK);
	printw("Blinking\n");
	printw("\n");

	attrset(A_DIM);
	printw("Half bright\n");
	printw("\n");

	attrset(A_BOLD);
	printw("Extra bright or bold\n");
	printw("\n");

	refresh();

	return 0;
}

The initsrc() funtion is the key.



> 	I do not have it anywhere in my C files.  

But in the manpage. :-)




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20100118212136.95b56398.freebsd>