Programmer's Guide to nCurses

Programmer's Guide to nCurses

Dan Gookin

Language: English

Pages: 579

ISBN: 0470107596

Format: PDF / Kindle (mobi) / ePub


Programming the console in UNIX?
Here's just what you need.

First, you'll get a no-nonsense tutorial guide to the nCurses version 5.5 library, taking you from basic to advanced functions step by step. Then you'll find an A-to-Z reference of more than 175 nCurses functions, cross-referenced and illustrated with examples. With this all-purpose nCurses reference, you?ll: Learn techniques that can be used to program Linux(R), FreeBSD(R), Mac OS(R) X, or any other UNIX-based OS. Program, control, and manipulate text on the terminal screen. Control interactive I/O, organize content into windows on the screen, and use color to highlight text and organize information. Use a mouse to further refine input. Create nCurses programs using your choice of editors. Find hundreds of quick, easy-to-understand programming examples.

Author Dan Gookin is known for making technology make sense. Buy this book and you'll see why.

Best iPad Apps: The Guide for Discriminating Downloaders (Best Apps)

Systems Analysis and Design (Shelly Cashman Series)

Linux Command Line and Shell Scripting Bible

Going Gas: From VBA to Google Apps Script

Extending Jenkins

Applied Network Security Monitoring: Collection, Detection, and Analysis

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Star\n”); addstr(“How I wonder what you are.\n”); refresh(); getch(); endwin(); return 0; } The important thing to remember about this code is that an attribute stays on until you turn it off, either via attroff() or attrset(). Otherwise, the attributes are slapped on to all text output after the attribute function is used, which can be seen in Figure 3-1. A_BOLD displays the text foreground in bold. 33 34 Chapter 3 ■ Formatting Text Blinking Text Figure 3-1: Output of the twinkle.c code.

Seems to be how the overlay() function (line 23) works best. First the program displays the Lorem ipsum text in the stdscr window. Something like this: Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Press the Enter key and the contents of the alpha window are displayed,.

The window is not moved; the mvwin() function returns ERR. ■■ To complete the move, the window in the background must be updated. The touchline() or touchwin() functions can handle this, followed by a wrefresh() of the background window. ■■ Do not move subwindows using mvwin(). Subwindows share memory with the parent window, but the parent window is unaware of this. Therefore, when you move the subwindow, NCurses cannot update which text was moved in which window and the results can be.

Directories to the final NCurses directory. Using an Editor to Create an NCurses Program There’s no point in bothering with a fancy developer environment or IDE when you’re programming NCurses. I think you’ll be happier using the terminal window and a shell prompt, unless you’ve been totally corrupted by some IDE. Then you’re on your own! Picking an Editor Since day one of UNIX, a text editor has been used to create code. That’s what I recommend for this book. Any text editor will do, and most.

UNIX commands. 13 14 Chapter 1 ■ The Setup And from now on, I will not be reminding you to specifically input, compile, and run the sample programs. There may be other, specific instructions given in the text, but whenever you see source code, it’s assumed that you can type it in and run it if you want to learn more. Handy Shell Commands to Know cat Displays a text file (source code) to the screen clear Clears the screen cp Copies a file ls –l Lists files in the long format ls.

Download sample

Download