Lamma.com.hk

LAMMA-ZINE - CLASSIFIEDS - EVENTS - GALLERIES - LINKS - Subscribe - Donate - Advertise - Contact Us - Facebook

  WHAT'S NEW? Bike Clearance ~ Lamma Island bolt-hole ~ Beautiful island ~ Lamma Guide
  WHAT'S ON?    Quiz Night ~ Art Breakfast ~ Game Night ~ Summer Camp ~ MTB Enduro Race
  LAMMA-ZINE:  Free Dining Coupons ~ Andy's Seafood ~ Wildlife Contest ~ Lamma Life 

It is currently Wed Nov 25, 2026 4:15 pm

All times are UTC + 8 hours




Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Greenpeace International
PostPosted: Fri Jan 26, 2007 11:34 pm 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
Greenpeace International
Say no to genetic engineering
http://www.greenpeace.org/international ... ngineering

Global Status of Genetically Engineered Crops
http://www.greenpeace.org/international ... etically-e

The NON-GMO Project
http://www.nongmoproject.org/links.html

{L_QUOTE}:
MPROVED TRADITIONAL FARMING (FTM)
http://www.paghonduras.org/pancamFTM.html

“Traditional Farming Indigenous Solutions for a Sustainable Future” (Non-Conventional Farming)
http://www.eya.ca/seedsforsurvival/trdtnl_frming.html

:radiant:


Last edited by flame on Sat Jan 27, 2007 12:43 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Old Pond Publishing
PostPosted: Sat Jan 27, 2007 11:32 am 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:


:radiant:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 27, 2007 9:16 pm 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
"Only when the last tree has died
And the last river has been poisoned
And the last fish caught
Will we realize that we cannot eat money.
-- The Cree
http://supak.com/end/organic_agriculture.htm


Top
 Profile  
 
PostPosted: Sun Jan 28, 2007 11:48 am 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
A Bad Time For Organic Believers
Tuesday October 3, 2006
http://www.cgfi.org/cgficommentary/a-ba ... -believers


:radiant:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 12:59 pm 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
Time to sow an organic revolution

Girijaa Upadhyay

ORGANIC FARMING is now acknowledged the world over as a sustainable model for alleviating poverty and increasing prosperity.

Nothing reflects better the shallowness of policymakers' response to what is probably the worst symptom of the systemic crisis in agriculture than reducing farmer-suicides to numbers and percentages. Not too long ago, both the Uttar Pradesh and Maharashtra governments underplayed the crisis by denying the magnitude of the lives lost; at the Centre too, Agriculture Ministry officials are busy reducing the increasing trend of self-destruction to a minor statistic in relation to the population........
http://www.thehindubusinessline.com/200 ... 360800.htm


:radiant:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 1:23 pm 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
Researchers find animal antibiotics in vegetables

By Ahmed ElAmin

Get the latest Market Reports on
antibiotics
organic
manure
Related News

Codex adopts twenty food standards at Rome meeting
Listeria, Salmonella: the bacteria that won't die
Antibiotic use promotes resistant strains of Campylobacter

News Archives

All news for June 2006
All news for May 2006

11/22/2005 - Antibiotics given to livestock can end up in vegetables and pose a health threat to consumers, according to a study looking at the use of animal manure as a fertilizer.........
http://www.nutraingredients-usa.com/new ... -manure%20


:radiant:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 12:37 am 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
Against organic farming

Perhaps the most eminent critic of organic farming is Norman Borlaug, the father of the “green revolution”, winner of the Nobel peace prize and an outspoken advocate of the use of synthetic fertilisers to increase crop yields. He claims the idea that organic farming is better for the environment is “ridiculous” because organic farming produces lower yields and therefore requires more land under cultivation to produce the same amount of food. Thanks to synthetic fertilisers, Mr Borlaug points out, global cereal production tripled between 1950 and 2000, but the amount of land used increased by only 10%. Using traditional techniques such as crop rotation, compost and manure to supply the soil with nitrogen and other minerals would have required a tripling of the area under cultivation. The more intensively you farm, Mr Borlaug contends, the more room you have left for rainforest.

Read more here.

Addendum: Speaking of The Economist, here are their book recommendations for the year.

Posted by Tyler Cowen on December 11, 2006 at 12:48 PM in Food and Drink | Permalink
Comments

Of course, we have the relevant question here: Is the market in organi and ostesibly "moral" food defined by consumers who really want to help the rest of the world, or by consumers who just want to feel good about themselves?

Here's a paper idea: Do the "stupid feel good" consumers impose a negative externality on the "really wanna help out" consumers by attracting products that don't really help out, thus raising the search costs for consumers who really want to make the world a better place?

Posted by: Keith at Dec 11, 2006 1:09:08 PM

T-shirt and bumber sticker nominee - "Save the rainforests! Boycott organic!"

Posted by: cb at Dec 11, 2006 2:52:02 PM

THIS is why I come to Marginal Revolution.

Keith, is it really necessary to call these people stupid? I'd guess that the majority of your "stupid feel good" consumers really want to help out and see organic farming as a way of doing so. Your paper idea is clever, more so if you remove the falsely attributed motives.

Posted by: eriks at Dec 11, 2006 2:55:28 PM

Rising organic food purchases have nothing to do with what's good for the planet. The public has a increasing belief that the food produced by agri-business, and the chemical approach to farming, are dangerous to their health. Can we say there's no truth in that idea? Where the population is in a position to pay for lower yields and higher spoilage, they will do so, efficiency be damned. For most of the world, this doesn't apply, of course, so it's hard to see how important the impact of organic production will be. The Economist would do better trying to improve the corporate farms image than crying about inefficiency.

Posted by: Weldon at Dec 11, 2006 3:00:47 PM
.........
http://www.marginalrevolution.com/margi ... ganic.html


:radiant:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 12:37 am 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
Organic_Clothing: Bad Shipping News
Acute exposure can cause severe chemical burns of the skin, eyes and airways, and delayed chemical pneumonia which produces water in the lungs. Overexposure can be fatal and numerous deaths have occurred among farm pesticide appliers, ...
http://organicclothing.blogs.com/my_web ... ng_ne.html


:radiant:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 11:39 am 
Offline
over 100 messages posted
over 100 messages posted

Joined: Thu Jul 17, 2003 10:24 pm
Posts: 128
there is a very interesting book on organic farming. You can read some reviews at http://www.amazon.com/One-Straw-Revolut ... 0878572201


Top
 Profile  
 
PostPosted: Thu Feb 01, 2007 12:49 pm 
Offline
User avatar

Joined: Sat Aug 05, 2006 6:56 pm
Posts: 65
{L_QUOTE}:
This article originally appeared in the July/August 1998 Children's Advocate newsmagazine, published by Action Alliance for Children.

Good bugs, bad bugs
Organic gardening comes naturally at a Vallejo Unified School District farm

By Stephanie Kim

Digging their hands into the soil, finding wet worms and red gleaming ladybugs, kids at the Loma Vista Farm and Garden Center learn about organic gardening by doing. Loma Vista is one of hundreds of gardening programs for children that have been sprouting up all over the state. Rooted in Vallejo, 40 miles north of San Francisco, this farm and garden functions as an outdoor classroom for adjacent Loma Vista Elementary School and other nearby schools. Kids come here to wash and spin wool sheared from sheep on the farm, feed an array of farm animals, cultivate an eclectic garden, and cook dishes with the vegetables they grow.

Run by the Vallejo Unified School District, the center stands on a former military housing site. Since 1974, teachers and students have transformed these five acres into an agricultural enclave. "All the buildings were built by kids," says Thom Arcadi, Teacher-in-Charge of the center. Arcadi and two assistants instruct and guide about 100 students a day, year-round.

On this late spring day, Phoebe Holbrook's kindergarten class from Loma Vista is spending their weekly half-hour visit planting pumpkins in the garden. "Mother Nature sets the lesson plan," says Rita LeRoy of the center staff. Rainy weather, exploding weeds, or an insect attack can determine the day's activities.

These five- and six-year-old children learn to garden without toxic pesticides. Six-year-old Zaire explains integrated pest management: "Sometimes the bugs—aphids—eat the plants. We search for ladybugs and we throw them on the plants. They eat the aphids."

When a child brings a roly poly, ladybug, or worm to "Farmer Rita," as LeRoy is known, she shows the creature to the whole class and discusses the role it plays in the garden. Five-year-old Emily has already learned about worms. "Worms make the plants grow," she explains, "'cause they are wet and they make the ground so wet 'cause they be sliding all around." Meanwhile, someone shouts, "Another worm!" and the kids hurry to see.

Farmers Thom and Rita find fun organic ways to solve pesky problems. The Center has a "weed race," in which kids "pull weeds by hundreds of pounds a week...it's so fun!" says LeRoy. When aphids attack, the kids take paper cups to hills beyond the farm for a "ladybug roundup."

The center is not trying to teach kids how to be farmers. Rather, it is a hands-on environment that teachers can use to teach their curricula. "It's up to the teachers how they want to use the farm," says LeRoy. The farm allows kids to explore math and science problems and provides a subject for creative writing.

Kathie Stats' and Mary Piper's kindergarten class from Davidson Elementary School in nearby Richmond have come to the Center to cap a month-long science unit on farming and plants. On their visit, they feed hungry farm animals, cook "Farm Foo Young" with freshly picked Swiss chard and green onions, pot succulents in the greenhouse, and plant sunflowers in the garden. Amid sounds of roosters, goats, and pigs, LeRoy shows Stats' and Piper's class how to plant the sunflower stem. Stats adds, "We were only able to make one field trip this year, and this was it. We saved up for this one."

LeRoy and Arcadi make it sound easy to keep the Center organic. "We don't use any chemicals. The ducks and geese eat the slugs and snails, and the ladybugs eat the aphids," LeRoy explains. After twenty-five years, Arcadi says, "We're at an equilibrium with the things around us—even in the greenhouse. People sterilize greenhouses and that causes an imbalance. Well, ours is totally unsterile—it's such a kid place. It's sort of wild in a way, but I think it's really worked out fine."

Action Alliance for Children



{L_QUOTE}:
"My husband and I went out driving with out four-year-old granddaughter, Lara, when I noticed that the cloud trails, reflecting the sunset, had a pink tinge.
Lara, sitting in the back seat, must have also been enchanted by this magical trick of the light.
She suddenly broke the silence and exclaimed, "Look, grandma. The skey's lips are painted." :twisted:
~~ Quoted from Reader's Digest - "Life's Like That ~~


:radiant:


Last edited by flame on Thu Feb 01, 2007 2:47 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 1:53 pm 
Offline
Over 900 messages posted
Over 900 messages posted
User avatar

Joined: Thu Oct 03, 2002 5:42 pm
Posts: 905
If you go to the Internet and type in "www.google.com" you will find this amazing site. You can type words into a space they have provided and then press "search" and it finds all sorts of stuff. Fantastic. Try it yourself and then why don't we all post everything we find on here!

:coffee:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 1:55 pm 
Offline
Over 900 messages posted
Over 900 messages posted
User avatar

Joined: Thu Oct 03, 2002 5:42 pm
Posts: 905
Let me start with this...

Writing Programs with NCURSES

by Eric S. Raymond and Zeyd M. Ben-Halim
Contents

Introduction
A Brief History of Curses
Scope of This Document
Terminology
The Curses Library
An Overview of Curses
Compiling Programs using Curses
Updating the Screen
Standard Windows and Function Naming Conventions
Variables
Using the Library
Starting up
Output
Input
Using Forms Characters
Character Attributes and Color
Mouse Interfacing
Finishing Up
Function Descriptions
Initialization and Wrapup
Causing Output to the Terminal
Low-Level Capability Access
Debugging
Hints, Tips, and Tricks
Some Notes of Caution
Temporarily Leaving ncurses Mode
Using ncurses under xterm
Handling Multiple Terminal Screens
Testing for Terminal Capabilities
Tuning for Speed
Special Features of ncurses
Compatibility with Older Versions
Refresh of Overlapping Windows
Background Erase
XSI Curses Conformance
The Panels Library
Compiling With the Panels Library
Overview of Panels
Panels, Input, and the Standard Screen
Hiding Panels
Miscellaneous Other Facilities
The Menu Library
Compiling with the menu Library
Overview of Menus
Selecting items
Menu Display
Menu Windows
Processing Menu Input
Miscellaneous Other Features
The Forms Library
Compiling with the forms Library
Overview of Forms
Creating and Freeing Fields and Forms
Fetching and Changing Field Attributes
Fetching Size and Location Data
Changing the Field Location
The Justification Attribute
Field Display Attributes
Field Option Bits
Field Status
Field User Pointer
Variable-Sized Fields
Field Validation
TYPE_ALPHA
TYPE_ALNUM
TYPE_ENUM
TYPE_INTEGER
TYPE_NUMERIC
TYPE_REGEXP
Direct Field Buffer Manipulation
Attributes of Forms
Control of Form Display
Input Processing in the Forms Driver
Page Navigation Requests
Inter-Field Navigation Requests
Intra-Field Navigation Requests
Scrolling Requests
Field Editing Requests
Order Requests
Application Commands
Field Change Hooks
Field Change Commands
Form Options
Custom Validation Types
Union Types
New Field Types
Validation Function Arguments
Order Functions For Custom Types
Avoiding Problems
Introduction

This document is an introduction to programming with curses. It is not an exhaustive reference for the curses Application Programming Interface (API); that role is filled by the curses manual pages. Rather, it is intended to help C programmers ease into using the package.
This document is aimed at C applications programmers not yet specifically familiar with ncurses. If you are already an experienced curses programmer, you should nevertheless read the sections on Mouse Interfacing, Debugging, Compatibility with Older Versions, and Hints, Tips, and Tricks. These will bring you up to speed on the special features and quirks of the ncurses implementation. If you are not so experienced, keep reading.

The curses package is a subroutine library for terminal-independent screen-painting and input-event handling which presents a high level screen model to the programmer, hiding differences between terminal types and doing automatic optimization of output to change one screenfull of text into another. Curses uses terminfo, which is a database format that can describe the capabilities of thousands of different terminals.

The curses API may seem something of an archaism on UNIX desktops increasingly dominated by X, Motif, and Tcl/Tk. Nevertheless, UNIX still supports tty lines and X supports xterm(1); the curses API has the advantage of (a) back-portability to character-cell terminals, and (b) simplicity. For an application that does not require bit-mapped graphics and multiple fonts, an interface implementation using curses will typically be a great deal simpler and less expensive than one using an X toolkit.


A Brief History of Curses

Historically, the first ancestor of curses was the routines written to provide screen-handling for the game rogue; these used the already- existing termcap database facility for describing terminal capabilities. These routines were abstracted into a documented library and first released with the early BSD UNIX versions.
System III UNIX from Bell Labs featured a rewritten and much-improved curses library. It introduced the terminfo format. Terminfo is based on Berkeley's termcap database, but contains a number of improvements and extensions. Parameterized capabilities strings were introduced, making it possible to describe multiple video attributes, and colors and to handle far more unusual terminals than possible with termcap. In the later AT&T System V releases, curses evolved to use more facilities and offer more capabilities, going far beyond BSD curses in power and flexibility.


Scope of This Document

This document describes ncurses, a freeware implementation of the System V curses API with some clearly marked extensions. It includes the following System V curses features:
Support for multiple screen highlights (BSD curses could only handle one `standout' highlight, usually reverse-video).
Support for line- and box-drawing using forms characters.
Recognition of function keys on input.
Color support.
Support for pads (windows of larger than screen size on which the screen or a subwindow defines a viewport).
Also, this package makes use of the insert and delete line and character features of terminals so equipped, and determines how to optimally use these features with no help from the programmer. It allows arbitrary combinations of video attributes to be displayed, even on terminals that leave ``magic cookies'' on the screen to mark changes in attributes.
The ncurses package can also capture and use event reports from a mouse in some environments (notably, xterm under the X window system). This document includes tips for using the mouse. The ncurses package was originated by Pavel Curtis. The primary maintainer of the package is Zeyd Ben-Halim <zmbenhal@netcom.com>. Eric S. Raymond <esr@snark.thyrsus.com> wrote many of the new features in versions after 1.8.1 and wrote most of this introduction.

This document also describes the extension library, similarly modeled on the SVr4 panels facility. This library allows you to associate backing store with each of a stack or deck of overlapping windows, and provides operations for moving windows around in the stack that change their visibility in the natural way (handling window overlaps).

Finally, this document describes in detail the menus and forms extension libraries, also cloned from System V, which support easy construction and sequences of menus and fill-in forms. This code was contributed to the project by Jürgen Pfeifer.


Terminology

In this document, the following terminology is used with reasonable consistency:
window
A data structure describing a sub-rectangle of the screen (possibly the entire screen). You can write to a window as though it were a miniature screen, scrolling independently of other windows on the physical screen.
screens
A subset of windows which are as large as the terminal screen, i.e., they start at the upper left hand corner and encompass the lower right hand corner. One of these, stdscr, is automatically provided for the programmer.
terminal screen
The package's idea of what the terminal display currently looks like, i.e., what the user sees now. This is a special screen.
The Curses Library

An Overview of Curses

Compiling Programs using Curses

In order to use the library, it is necessary to have certain types and variables defined. Therefore, the programmer must have a line:
#include <curses.h>
at the top of the program source. The screen package uses the Standard I/O library, so <curses.h> includes <stdio.h>. <curses.h> also includes <termios.h>, <termio.h>, or <sgtty.h> depending on your system. It is redundant (but harmless) for the programmer to do these includes, too. In linking with curses you need to have -lncurses in your LDFLAGS or on the command line. There is no need for any other libraries.
Updating the Screen

In order to update the screen optimally, it is necessary for the routines to know what the screen currently looks like and what the programmer wants it to look like next. For this purpose, a data type (structure) named WINDOW is defined which describes a window image to the routines, including its starting position on the screen (the (y, x) coordinates of the upper left hand corner) and its size. One of these (called curscr, for current screen) is a screen image of what the terminal currently looks like. Another screen (called stdscr, for standard screen) is provided by default to make changes on.
A window is a purely internal representation. It is used to build and store a potential image of a portion of the terminal. It doesn't bear any necessary relation to what is really on the terminal screen; it's more like a scratchpad or write buffer.

To make the section of physical screen corresponding to a window reflect the contents of the window structure, the routine refresh() (or wrefresh() if the window is not stdscr) is called.

A given physical screen section may be within the scope of any number of overlapping windows. Also, changes can be made to windows in any order, without regard to motion efficiency. Then, at will, the programmer can effectively say ``make it look like this,'' and let the package implementation determine the most efficient way to repaint the screen.


Standard Windows and Function Naming Conventions

As hinted above, the routines can use several windows, but two are automatically given: curscr, which knows what the terminal looks like, and stdscr, which is what the programmer wants the terminal to look like next. The user should never actually access curscr directly. Changes should be made to through the API, and then the routine refresh() (or wrefresh()) called.
Many functions are defined to use stdscr as a default screen. For example, to add a character to stdscr, one calls addch() with the desired character as argument. To write to a different window. use the routine waddch() (for `w'indow-specific addch()) is provided. This convention of prepending function names with a `w' when they are to be applied to specific windows is consistent. The only routines which do not follow it are those for which a window must always be specified.

In order to move the current (y, x) coordinates from one point to another, the routines move() and wmove() are provided. However, it is often desirable to first move and then perform some I/O operation. In order to avoid clumsiness, most I/O routines can be preceded by the prefix 'mv' and the desired (y, x) coordinates prepended to the arguments to the function. For example, the calls

move(y, x);
addch(ch);
can be replaced by
mvaddch(y, x, ch);
and
wmove(win, y, x);
waddch(win, ch);
can be replaced by
mvwaddch(win, y, x, ch);
Note that the window description pointer (win) comes before the added (y, x) coordinates. If a function requires a window pointer, it is always the first parameter passed.

Variables

The curses library sets some variables describing the terminal capabilities.
type name description
------------------------------------------------------------------
int LINES number of lines on the terminal
int COLS number of columns on the terminal
The curses.h also introduces some #define constants and types of general usefulness:
bool
boolean type, actually a `char' (e.g., bool doneit;)
TRUE
boolean `true' flag (1).
FALSE
boolean `false' flag (0).
ERR
error flag returned by routines on a fail (-1).
OK
error flag returned by routines when things go right.
Using the Library

Now we describe how to actually use the screen package. In it, we assume all updating, reading, etc. is applied to stdscr. These instructions will work on any window, providing you change the function names and parameters as mentioned above.
Here is a sample program to motivate the discussion:


#include <curses.h>
#include <signal.h>

static void finish(int sig);

main(int argc, char *argv[])
{
/* initialize your non-curses data structures here */

(void) signal(SIGINT, finish); /* arrange interrupts to terminate */

(void) initscr(); /* initialize the curses library */
keypad(stdscr, TRUE); /* enable keyboard mapping */
(void) nonl(); /* tell curses not to do NL->CR/NL on output */
(void) cbreak(); /* take input chars one at a time, no wait for \n */
(void) noecho(); /* don't echo input */

if (has_colors())
{
start_color();

/*
* Simple color assignment, often all we need.
*/
init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
}

for (;;)
{
int c = getch(); /* refresh, accept single keystroke of input */

/* process the command keystroke */
}

finish(0); /* we're done */
}

static void finish(int sig)
{
endwin();

/* do your non-curses wrapup here */

exit(0);
}
Starting up

In order to use the screen package, the routines must know about terminal characteristics, and the space for curscr and stdscr must be allocated. These function initscr() does both these things. Since it must allocate space for the windows, it can overflow memory when attempting to do so. On the rare occasions this happens, initscr() will terminate the program with an error message. initscr() must always be called before any of the routines which affect windows are used. If it is not, the program will core dump as soon as either curscr or stdscr are referenced. However, it is usually best to wait to call it until after you are sure you will need it, like after checking for startup errors. Terminal status changing routines like nl() and cbreak() should be called after initscr().
Once the screen windows have been allocated, you can set them up for your program. If you want to, say, allow a screen to scroll, use scrollok(). If you want the cursor to be left in place after the last change, use leaveok(). If this isn't done, refresh() will move the cursor to the window's current (y, x) coordinates after updating it.

You can create new windows of your own using the functions newwin(), derwin(), and subwin(). The routine delwin() will allow you to get rid of old windows. All the options described above can be applied to any window.


Output

Now that we have set things up, we will want to actually update the terminal. The basic functions used to change what will go on a window are addch() and move(). addch() adds a character at the current (y, x) coordinates. move() changes the current (y, x) coordinates to whatever you want them to be. It returns ERR if you try to move off the window. As mentioned above, you can combine the two into mvaddch() to do both things at once.
The other output functions, such as addstr() and printw(), all call addch() to add characters to the window.

After you have put on the window what you want there, when you want the portion of the terminal covered by the window to be made to look like it, you must call refresh(). In order to optimize finding changes, refresh() assumes that any part of the window not changed since the last refresh() of that window has not been changed on the terminal, i.e., that you have not refreshed a portion of the terminal with an overlapping window. If this is not the case, the routine touchwin() is provided to make it look like the entire window has been changed, thus making refresh() check the whole subsection of the terminal for changes.

If you call wrefresh() with curscr as its argument, it will make the screen look like curscr thinks it looks like. This is useful for implementing a command which would redraw the screen in case it get messed up.


Input

The complementary function to addch() is getch() which, if echo is set, will call addch() to echo the character. Since the screen package needs to know what is on the terminal at all times, if characters are to be echoed, the tty must be in raw or cbreak mode. Since initially the terminal has echoing enabled and is in ordinary ``cooked'' mode, one or the other has to changed before calling getch(); otherwise, the program's output will be unpredictable.
When you need to accept line-oriented input in a window, the functions wgetstr() and friends are available. There is even a wscanw() function that can do scanf()(3)-style multi-field parsing on window input. These pseudo-line-oriented functions turn on echoing while they execute.

The example code above uses the call keypad(stdscr, TRUE) to enable support for function-key mapping. With this feature, the getch() code watches the input stream for character sequences that correspond to arrow and function keys. These sequences are returned as pseudo-character values. The #define values returned are listed in the curses.h The mapping from sequences to #define values is determined by key_ capabilities in the terminal's terminfo entry.


Using Forms Characters

The addch() function (and some others, including box() and border()) can accept some pseudo-character arguments which are specially defined by ncurses. These are #define values set up in the curses.h header; see there for a complete list (look for the prefix ACS_).
The most useful of the ACS defines are the forms-drawing characters. You can use these to draw boxes and simple graphs on the screen. If the terminal does not have such characters, curses.h will map them to a recognizable (though ugly) set of ASCII defaults.


Character Attributes and Color

The ncurses package supports screen highlights including standout, reverse-video, underline, and blink. It also supports color, which is treated as another kind of highlight.
Highlights are encoded, internally, as high bits of the pseudo-character type (chtype) that curses.h uses to represent the contents of a screen cell. See the curses.h header file for a complete list of highlight mask values (look for the prefix A_).

There are two ways to make highlights. One is to logical-or the value of the highlights you want into the character argument of an addch() call, or any other output call that takes a chtype argument.

The other is to set the current-highlight value. This is logical-or'ed with any highlight you specify the first way. You do this with the functions attron(), attroff(), and attrset(); see the manual pages for details. Color is a special kind of highlight. The package actually thinks in terms of color pairs, combinations of foreground and background colors. The sample code above sets up eight color pairs, all of the guaranteed-available colors on black. Note that each color pair is, in effect, given the name of its foreground color. Any other range of eight non-conflicting values could have been used as the first arguments of the init_pair() values.

Once you've done an init_pair() that creates color-pair N, you can use COLOR_PAIR(N) as a highlight that invokes that particular color combination. Note that COLOR_PAIR(N), for constant N, is itself a compile-time constant and can be used in initializers.


Mouse Interfacing

The ncurses library also provides a mouse interface. Note: his facility is original to ncurses, it is not part of either the XSI Curses standard, nor of System V Release 4, nor BSD curses. Thus, we recommend that you wrap mouse-related code in an #ifdef using the feature macro NCURSES_MOUSE_VERSION so it will not be compiled and linked on non-ncurses systems.
Presently, mouse event reporting works only under xterm. In the future, ncurses will detect the presence of \fBgpm\fR(1), Alessandro Rubini's freeware mouse server for Linux systems, and accept mouse reports through it.

The mouse interface is very simple. To activate it, you use the function mousemask(), passing it as first argument a bit-mask that specifies what kinds of events you want your program to be able to see. It will return the bit-mask of events that actually become visible, which may differ from the argument if the mouse device is not capable of reporting some of the event types you specify.

Once the mouse is active, your application's command loop should watch for a return value of KEY_MOUSE from wgetch(). When you see this, a mouse event report has been queued. To pick it off the queue, use the function getmouse() (you must do this before the next wgetch(), otherwise another mouse event might come in and make the first one inaccessible).

Each call to getmouse() fills a structure (the address of which you'll pass it) with mouse event data. The event data includes zero-origin, screen-relative character-cell coordinates of the mouse pointer. It also includes an event mask. Bits in this mask will be set, corresponding to the event type being reported.

The mouse structure contains two additional fields which may be significant in the future as ncurses interfaces to new kinds of pointing device. In addition to x and y coordinates, there is a slot for a z coordinate; this might be useful with touchscreens that can return a pressure or duration parameter. There is also a device ID field, which could be used to distinguish between multiple pointing devices.

The class of visible events may be changed at any time via mousemask(). Events that can be reported include presses, releases, single-, double- and triple-clicks (you can set the maximum button-down time for clicks). If you don't make clicks visible, they will be reported as press-release pairs. In some environments, the event mask may include bits reporting the state of shift, alt, and ctrl keys on the keyboard during the event.

A function to check whether a mouse event fell within a given window is also supplied. You can use this to see whether a given window should consider a mouse event relevant to it.

Because mouse event reporting will not be available in all environments, it would be unwise to build ncurses applications that require the use of a mouse. Rather, you should use the mouse as a shortcut for point-and-shoot commands your application would normally accept from the keyboard. Two of the test games in the ncurses distribution (bs and knight) contain code that illustrates how this can be done.

See the manual page curs_mouse(3X) for full details of the mouse-interface functions.


Finishing Up

In order to clean up after the ncurses routines, the routine endwin() is provided. It restores tty modes to what they were when initscr() was first called, and moves the cursor down to the lower-left corner. Thus, anytime after the call to initscr, endwin() should be called before exiting.

Function Descriptions

We describe the detailed behavior of some important curses functions here, as a supplement to the manual page descriptions.
Initialization and Wrapup

initscr()
The first function called should almost always be initscr(). This will determine the terminal type and initialize curses data structures. initscr() also arranges that the first call to refresh() will clear the screen. If an error occurs a message is written to standard error and the program exits. Otherwise it returns a pointer to stdscr. A few functions may be called before initscr (slk_init(), filter(), ripofflines(), use_env(), and, if you are using multiple terminals, newterm().)
endwin()
Your program should always call endwin() before exiting or shelling out of the program. This function will restore tty modes, move the cursor to the lower left corner of the screen, reset the terminal into the proper non-visual mode. Calling refresh() or doupdate() after a temporary escape from the program will restore the ncurses screen from before the escape.
newterm(type, ofp, ifp)
A program which outputs to more than one terminal should use newterm() instead of initscr(). newterm() should be called once for each terminal. It returns a variable of type SCREEN * which should be saved as a reference to that terminal. The arguments are the type of the terminal (a string) and FILE pointers for the output and input of the terminal. If type is NULL then the environment variable $TERM is used. endwin() should called once at wrapup time for each terminal opened using this function.
set_term(new)
This function is used to switch to a different terminal previously opened by newterm(). The screen reference for the new terminal is passed as the parameter. The previous terminal is returned by the function. All other calls affect only the current terminal.
delscreen(sp)
The inverse of newterm(); deallocates the data structures associated with a given SCREEN reference.
Causing Output to the Terminal

refresh() and wrefresh(win)
These functions must be called to actually get any output on the terminal, as other routines merely manipulate data structures. wrefresh() copies the named window to the physi- cal terminal screen, taking into account what is already there in order to do optimizations. refresh() does a refresh of stdscr(). Unless leaveok() has been enabled, the physical cursor of the terminal is left at the location of the window's cursor.
doupdate() and wnoutrefresh(win)
These two functions allow multiple updates with more efficiency than wrefresh. To use them, it is important to understand how curses works. In addition to all the window structures, curses keeps two data structures representing the terminal screen: a physical screen, describing what is actually on the screen, and a virtual screen, describing what the programmer wants to have on the screen. wrefresh works by first copying the named window to the virtual screen (wnoutrefresh()), and then calling the routine to update the screen (doupdate()). If the programmer wishes to output several windows at once, a series of calls to wrefresh will result in alternating calls to wnoutrefresh() and doupdate(), causing several bursts of output to the screen. By calling wnoutrefresh() for each window, it is then possible to call doupdate() once, resulting in only one burst of output, with fewer total characters transmitted (this also avoids a visually annoying flicker at each update).
Low-Level Capability Access

setupterm(term, filenum, errret) This routine is called to initialize a terminal's description, without setting up the curses screen structures or changing the tty-driver mode bits. term is the character string representing the name of the terminal being used. filenum is the UNIX file descriptor of the terminal to be used for output. errret is a pointer to an integer, in which a success or failure indication is returned. The values returned can be 1 (all is well), 0 (no such terminal), or -1 (some problem locating the terminfo database).
The value of term can be given as NULL, which will cause the value of TERM in the environment to be used. The errret pointer can also be given as NULL, meaning no error code is wanted. If errret is defaulted, and something goes wrong, setupterm() will print an appropriate error message and exit, rather than returning. Thus, a simple program can call setupterm(0, 1, 0) and not worry about initialization errors.

After the call to setupterm(), the global variable cur_term is set to point to the current structure of terminal capabilities. By calling setupterm() for each terminal, and saving and restoring cur_term, it is possible for a program to use two or more terminals at once. Setupterm() also stores the names section of the terminal description in the global character array ttytype[]. Subsequent calls to setupterm() will overwrite this array, so you'll have to save it yourself if need be.

Debugging

NOTE: These functions are not part of the standard curses SPI!

trace()
This function can be used to explicitly set a trace level. If the trace level is nonzero, execution of your program will generate a file called `trace' in the current working directory containing a report on the library's actions. Higher trace levels enable more detailed (and verbose) reporting -- see comments attached to TRACE_ defines in the curses.h file for details. (It is also possible to set a trace level by assigning a trace level value to the environment variable NCURSES_TRACE).
_tracef()
This function can be used to output your own debugging information. It is only available only if you link with -lncurses_g. It can be used the same way as printf(), only it outputs a newline after the end of arguments. The output goes to a file called trace in the current directory.
Trace logs can be difficult to interpret due to the sheer volume of data dumped in them. There is a script called tracemunch included with the ncurses distribution that can alleviate this problem somewhat; it compacts long sequences of similar operations into more succinct single-line pseudo-operations. These pseudo-ops can be distinguished by the fact that they are named in capital letters.

Hints, Tips, and Tricks

The ncurses manual pages are a complete reference for this library. In the remainder of this document, we discuss various useful methods that may not be obvious from the manual page descriptions.

Some Notes of Caution

If you find yourself thinking you need to use noraw() or nocbreak(), think again and move carefully. It's probably better design to use getstr() or one of its relatives to simulate cooked mode. The noraw() and nocbreak() functions try to restore cooked mode, but they may end up clobbering some control bits set before you started your application. Also, they have always been poorly documented, and are likely to hurt your application's usability with other curses libraries.
Bear in mind that refresh() is a synonym for wrefresh(stdscr), and don't try to mix use of stdscr with use of windows declared by newwin(); a refresh() call will blow them off the screen. The right way to handle this is to use subwin(), or not touch stdscr at all and tile your screen with declared windows which you then wnoutrefresh() somewhere in your program event loop, with a single doupdate() call to trigger actual repainting.

You are much less likely to run into problems if you design your screen layouts to use tiled rather than overlapping windows. Historically, curses support for overlapping windows has been weak, fragile, and poorly documented. The ncurses library is not yet an exception to this rule.

There is a freeware panels library included in the ncurses distribution that does a pretty good job of strengthening the overlapping-windows facilities.

Try to avoid using the global variables LINES and COLS. Use getmaxyx() on the stdscr context instead. Reason: your code may be ported to run in an environment with window resizes, in which case several screens could be open with different sizes.


Temporarily Leaving ncurses Mode

Sometimes you will want to write a program that spends most of its time in screen mode, but occasionally returns to ordinary `cooked' mode. A common reason for this is to support shell-out. This behavior is simple to arrange in ncurses.
To leave ncurses mode, call endwin() as you would if you were intending to terminate the program. This will take the screen back to cooked mode; you can do your shell-out. When you want to return to ncurses mode, simply call refresh() or doupdate(). This will repaint the screen.

There is a boolean function, isendwin(), which code can use to test whether ncurses screen mode is active. It returns TRUE in the interval between an endwin() call and the following refresh(), FALSE otherwise.

Here is some sample code for shellout:

addstr("Shelling out...");
def_prog_mode(); /* save current tty modes */
endwin(); /* restore original tty modes */
system("sh"); /* run shell */
addstr("returned.\n"); /* prepare return message */
refresh(); /* restore save modes, repaint screen */
Using ncurses Under xterm

A resize operation in X sends SIGWINCH to the application running under xterm. The ncurses library does not catch this signal, because it cannot in general know how you want the screen re-painted. You will have to write the SIGWINCH handler yourself.
The easiest way to code your SIGWINCH handler is to have it do an endwin, followed by an initscr and a screen repaint you code yourself. The initscr will pick up the new screen size from the xterm's environment.

Handling Multiple Terminal Screens

The initscr() function actually calls a function named newterm() to do most of its work. If you are writing a program that opens multiple terminals, use newterm() directly.
For each call, you will have to specify a terminal type and a pair of file pointers; each call will return a screen reference, and stdscr will be set to the last one allocated. You will switch between screens with the set_term call. Note that you will also have to call def_shell_mode and def_prog_mode on each tty yourself.


Testing for Terminal Capabilities

Sometimes you may want to write programs that test for the presence of various capabilities before deciding whether to go into ncurses mode. An easy way to do this is to call setupterm(), then use the functions tigetflag(), tigetnum(), and tigetstr() to do your testing.
A particularly useful case of this often comes up when you want to test whether a given terminal type should be treated as `smart' (cursor-addressable) or `stupid'. The right way to test this is to see if the return value of tigetstr("cup") is non-NULL. Alternatively, you can include the term.h file and test the value of the macro cursor_address.


Tuning for Speed

Use the addchstr() family of functions for fast screen-painting of text when you know the text doesn't contain any control characters. Try to make attribute changes infrequent on your screens. Don't use the immedok() option!

Special Features of ncurses

When running on PC-clones, ncurses has enhanced support for the IBM high-half and ROM characters. The A_ALTCHARSET highlight, enables display of both high-half ACS graphics and the PC ROM graphics 0-31 that are normally interpreted as control characters.
The wresize() function allows you to resize a window in place.


Compatibility with Older Versions

Despite our best efforts, there are some differences between ncurses and the (undocumented!) behavior of older curses implementations. These arise from ambiguities or omissions in the documentation of the API.
Refresh of Overlapping Windows

If you define two windows A and B that overlap, and then alternately scribble on and refresh them, the changes made to the overlapping region under historic curses versions were often not documented precisely.
To understand why this is a problem, remember that screen updates are calculated between two representations of the entire display. The documentation says that when you refresh a window, it is first copied to to the virtual screen, and then changes are calculated to update the physical screen (and applied to the terminal). But "copied to" is not very specific, and subtle differences in how copying works can produce different behaviors in the case where two overlapping windows are each being refreshed at unpredictable intervals.

What happens to the overlapping region depends on what wnoutrefresh() does with its argument -- what portions of the argument window it copies to the virtual screen. Some implementations do "change copy", copying down only locations in the window that have changed (or been marked changed with wtouchln() and friends). Some implementations do "entire copy", copying all window locations to the virtual screen whether or not they have changed.

The ncurses library itself has not always been consistent on this score. Due to a bug, versions 1.8.7 to 1.9.8a did entire copy. Versions 1.8.6 and older, and versions 1.9.9 and newer, do change copy.

For most commercial curses implementations, it is not documented and not known for sure (at least not to the ncurses maintainers) whether they do change copy or entire copy. We know that System V release 3 curses has logic in it that looks like an attempt to do change copy, but the surrounding logic and data representations are sufficiently complex, and our knowledge sufficiently indirect, that it's hard to know whether this is reliable. It is not clear what the SVr4 documentation and XSI standard intend. The XSI Curses standard barely mentions wnoutrefresh(); the SVr4 documents seem to be describing entire-copy, but it is possible with some effort and straining to read them the other way.

It might therefore be unwise to rely on either behavior in programs that might have to be linked with other curses implementations. Instead, you can do an explicit touchwin() before the wnoutrefresh() call to guarantee an entire-contents copy anywhere.

The really clean way to handle this is to use the panels library. If, when you want a screen update, you do update_panels(), it will do all the necessary wnoutrfresh() calls for whatever panel stacking order you have defined. Then you can do one doupdate() and there will be a single burst of physical I/O that will do all your updates.


Background Erase

If you have been using a very old versions of ncurses (1.8.7 or older) you may be surprised by the behavior of the erase functions. In older versions, erased areas of a window were filled with a blank modified by the window's current attribute (as set by wattrset(), wattron(), wattroff() and friends).
In newer versions, this is not so. Instead, the attribute of erased blanks is normal unless and until it is modified by the functions bkgdset() or wbkgdset().

This change in behavior conforms ncurses to System V Release 4 and the XSI Curses standard.


XSI Curses Conformance

The ncurses library is intended to be base-level conformant with the XSI Curses standard from X/Open. May extended-level features (in fact, almost all features not directly concerned with wide characters and internationalization) are also supported.
One effect of XSI conformance is the change in behavior described under "Background Erase -- Compatibility with Old Versions".

Also, ncurses meets the XSI requirement that every macro entry point have a corresponding function which may be linked (and will be prototype-checked) if the macro definition is disabled with #undef.


The Panels Library

The ncurses library by itself provides good support for screen displays in which the windows are tiled (non-overlapping). In the more general case that windows may overlap, you have to use a series of wnoutrefresh() calls followed by a doupdate(), and be careful about the order you do the window refreshes in. It has to be bottom-upwards, otherwise parts of windows that should be obscured will show through.
When your interface design is such that windows may dive deeper into the visibility stack or pop to the top at runtime, the resulting book-keeping can be tedious and difficult to get right. Hence the panels library.

The panel library first appeared in AT&T System V. The version documented here is the freeware panel code distributed with ncurses.

Compiling With the Panels Library

Your panels-using modules must import the panels library declarations with
#include <panel.h>
and must be linked explicitly with the panels library using an -lpanel argument. Note that they must also link the ncurses library with -lncurses. Most modern linkers are two-pass and will accept either order, but it is still good practice to put -lpanel first and -lncurses second.
Overview of Panels

A panel object is a window that is implicitly treated as part of a deck including all other panel objects. The deck has an implicit bottom-to-top visibility order. The panels library includes an update function (analogous to refresh()) that displays all panels in the deck in the proper order to resolve overlaps. The standard window, stdscr, is considered below all panels.
Details on the panels functions are available in the man pages. We'll just hit the highlights here.

You create a panel from a window by calling new_panel() on a window pointer. It then becomes the top of the deck. The panel's window is available as the value of panel_window() called with the panel pointer as argument.

You can delete a panel (removing it from the deck) with del_panel. This will not deallocate the associated window; you have to do that yourself. You can replace a panel's window with a different window by calling replace_window. The new window may be of different size; the panel code will re-compute all overlaps. This operation doesn't change the panel's position in the deck.

To move a panel's window, use move_panel(). The mvwin() function on the panel's window isn't sufficient because it doesn't update the panels library's representation of where the windows are. This operation leaves the panel's depth, contents, and size unchanged.

Two functions (top_panel(), bottom_panel()) are provided for rearranging the deck. The first pops its argument window to the top of the deck; the second sends it to the bottom. Either operation leaves the panel's screen location, contents, and size unchanged.

The function update_panels() does all the wnoutrefresh() calls needed to prepare for doupdate() (which you must call yourself, afterwards).

Typically, you will want to call update_panels() and doupdate() just before accepting command input, once in each cycle of interaction with the user. If you call update_panels() after each and every panel write, youll generate a lot of unnecessary refresh activity and screen flicker.


Panels, Input, and the Standard Screen

You shouldn't mix wnoutrefresh() or wrefresh() operations with panels code; this will work only if the argument window is either in the top panel or un-obscured by any other panels.
The stsdcr window is a special case. It is considered below all panels. Because changes to panels may obscure parts of stdscr, though, you should call update_panels() before doupdate() even when you only change stdscr.

Note that wgetch automatically calls wrefresh. Therefore, before requesting input from a panel window, you need to be sure that the panel is totally un-obscured.

There is presently no way to display changes to one obscured panel without repainting all panels.


Hiding Panels

It's possible to remove a panel from the deck temporarily; use hide_panel for this. You can un-hide a panel with show_panel(). The predicate function panel_hidden tests whether or not a panel is hidden.
The panel_update code ignores hidden panels. You cannot do top_panel() or bottom_panel on a hidden panel(). Other panels operations are applicable.


Miscellaneous Other Facilities

It's possible to navigate the deck using the functions panel_above() and panel_below. Handed a panel pointer, they return the panel above or below that panel. Handed NULL, they return the bottom-most or top-most panel.
Every panel has an associated user pointer, not used by the panel code, to which you can attach application data. See the man page documentation of set_panel_userptr() and panel_userptr for details.


The Menu Library

A menu is a screen display that assists the user to choose some subset of a given set of items. The menu library is a curses extension that supports easy programming of menu hierarchies with a uniform but flexible interface.
The menu library first appeared in AT&T System V. The version documented here is the freeware menu code distributed with ncurses.


Compiling With the menu Library

Your menu-using modules must import the menu library declarations with
#include <menu.h>
and must be linked explicitly with the menus library using an -lmenu argument. Note that they must also link the ncurses library with -lncurses. Most modern linkers are two-pass and will accept either order, but it is still good practice to put -lmenu first and -lncurses second.
Overview of Menus

The menus created by this library consist of collections of items including a name string part and a description string part. To make menus, you create groups of these items and connect them with menu frame objects.
The menu can then by posted, that is written to an associated window. Actually, each menu has two associated windows; a containing window in which the programmer can scribble titles or borders, and a subwindow in which the menu items proper are displayed. If this subwindow is too small to display all the items, it will be a scrollable viewport on the collection of items.

A menu may also be unposted (that is, undisplayed), and finally freed to make the storage associated with it and its items available for re-use.

The general flow of control of a menu program looks like this:

Initialize curses.
Create the menu items, using new_item().
Create the menu using new_menu().
Post the menu using menu_post().
Refresh the screen.
Process user requests via an input loop.
Unpost the menu using menu_unpost().
Free the menu, using free_menu().
Free the items using free_item().
Terminate curses.
Selecting items

Menus may be multi-valued or (the default) single-valued (see the manual page mitem_opts(3x) to see how to change the default). Both types always have a current item.
From a single-valued menu you can read the selected value simply by looking at the current item. From a multi-valued menu, you get the selected set by looping through the items applying the item_value() predicate function. Your menu-processing code can use the function set_item_value() to flag the items in the select set.

Menu items can be made un-selectable using set_item_opts() or item_opts_off() with the O_SELECTABLE argument. This is the only option so far defined for menus, but it is good practice to code as though other option bits might be on.


Menu Display

The menu library calculates a minimum display size for your window, based on the following variables:

The number and maximum length of the menu items
Whether the O_ROWMAJOR option is enabled
Whether display of descriptions is enabled
Whatever menu format may have been set by the programmer
The length of the menu mark string used for highlighting selected items
The function set_menu_format() allows you to set the maximum size of the viewport or menu page that will be used to display menu items. You can retrieve any format associated with a menu with menu_format(). The default format is rows=16, columns=1.
The actual menu page may be smaller than the format size. This depends on the item number and size and whether O_ROWMAJOR is on. This option (on by default) causes menu items to be displayed in a `raster-scan' pattern, so that if more than one item will fit horizontally the first couple of items are side-by-side in the top row. The alternative is column-major display, which tries to put the first several items in the first column.

As mentioned above, a menu format not large enough to allow all items to fit on-screen will result in a menu display that is vertically scrollable.

You can scroll it with requests to the menu driver, which will be described in the section on menu input handling.

Each menu has a mark string used to visually tag selected items; see the menu_mark(3x) manual page for details. The mark string length also influences the menu page size.

The function scale_menu() returns the minimum display size that the menu code computes from all these factors. There are other menu display attributes including a select attribute, an attribute for selectable items, an attribute for unselectable items, and a pad character used to separate item name text from description text. These have reasonable defaults which the library allows you to change (see the menu_attribs(3x)manual page.


Menu Windows

Each menu has, as mentioned previously, a pair of associated windows. Both these windows are painted when the menu is posted and erased when the menu is unposted.
The outer or frame window is not otherwise touched by the menu routines. It exists so the programmer can associate a title, a border, or perhaps help text with the menu and have it properly refreshed or erased at post/unpost time. The inner window or subwindow is where the current menu page is displayed.

By default, both windows are stdscr. You can set them with the functions in menu_win(3x).

When you call menu_post(), you write the menu to its subwindow. When you call menu_unpost(), you erase the subwindow, However, neither of these actually modifies the screen. To do that, call wrefresh() or some equivalent.


Processing Menu Input

The main loop of your menu-processing code should call menu_driver() repeatedly. The first argument of this routine is a menu pointer; the second is a menu command code. You should write an input-fetching routine that maps input characters to menu command codes, and pass its output to menu_driver(). The menu command codes are fully documented in menu_driver(3x).
The simplest group of command codes is REQ_NEXT_ITEM, REQ_PREV_ITEM, REQ_FIRST_ITEM, REQ_LAST_ITEM, REQ_UP_ITEM, REQ_DOWN_ITEM, REQ_LEFT_ITEM, REQ_RIGHT_ITEM. These change the currently selected item. These requests may cause scrolling of the menu page if it only partially displayed.

There are explicit requests for scrolling which also change the current item (because the select location does not change, but the item there does). These are REQ_SCR_DLINE, REQ_SCR_ULINE, REQ_SCR_DPAGE, and REQ_SCR_UPAGE.

The REQ_TOGGLE_ITEM selects or deselects the current item. It is for use in multi-valued menus; if you use it with O_ONEVALUE on, you'll get an error return (E_REQUEST_DENIED).

Each menu has an associated pattern buffer. The menu_driver() logic tries to accumulate printable ASCII characters passed in in that buffer; when it matches a prefix of an item name, that item (or the next matching item) is selected. If appending a character yields no new match, that character is deleted from the pattern buffer, and menu_driver() returns E_NO_MATCH.

Some requests change the pattern buffer directly: REQ_CLEAR_PATTERN, REQ_BACK_PATTERN, REQ_NEXT_MATCH, REQ_PREV_MATCH. The latter two are useful when pattern buffer input matches more than one item in a multi-valued menu.

Each successful scroll or item navigation request clears the pattern buffer. It is also possible to set the pattern buffer explicitly with set_menu_pattern().

Finally, menu driver requests above the constant MAX_COMMAND are considered application-specific commands. The menu_driver() code ignores them and returns E_UNKNOWN_COMMAND.

Miscellaneous Other Features

Various menu options can affect the processing and visual appearance and input processing of menus. See menu_opts(3x) for details.
It is possible to change the current item from application code; this is useful if you want to write your own navigation requests. It is also possible to explicitly set the top row of the menu display. See mitem_current(3x). If your application needs to change the menu subwindow cursor for any reason, pos_menu_cursor() will restore it to the correct location for continuing menu driver processing.

It is possible to set hooks to be called at menu initialization and wrapup time, and whenever the selected item changes. See menu_hook(3x).

Each item, and each menu, has an associated user pointer on which you can hang application data. See mitem_userptr(3x) and menu_userptr(3x).


The Forms Library

The form library is a curses extension that supports easy programming of on-screen forms for data entry and program control.
The form library first appeared in AT&T System V. The version documented here is the freeware form code distributed with ncurses.


Compiling With the form Library

Your form-using modules must import the form library declarations with
#include <form.h>
and must be linked explicitly with the forms library using an -lform argument. Note that they must also link the ncurses library with -lncurses. Most modern linkers are two-pass and will accept either order, but it is still good practice to put -lform first and -lncurses second.

Overview of Forms

A form is a collection of fields; each field may be either a label (explanatory text) or a data-entry location. Long forms may be segmented into pages; each entry to a new page clears the screen.
To make forms, you create groups of fields and connect them with form frame objects; the form library makes this relatively simple.

Once defined, a form can be posted, that is written to an associated window. Actually, each form has two associated windows; a containing window in which the programmer can scribble titles or borders, and a subwindow in which the form fields proper are displayed.

As the form user fills out the posted form, navigation and editing keys support movement between fields, editing keys support modifying field, and plain text adds to or changes data in a current field. The form library allows you (the forms designer) to bind each navigation and editing key to any keystroke accepted by curses Fields may have validation conditions on them, so that they check input data for type and value. The form library supplies a rich set of pre-defined field types, and makes it relatively easy to define new ones.

Once its transaction is completed (or aborted), a form may be unposted (that is, undisplayed), and finally freed to make the storage associated with it and its items available for re-use.

The general flow of control of a form program looks like this:

Initialize curses.
Create the form fields, using new_field().
Create the form using new_form().
Post the form using form_post().
Refresh the screen.
Process user requests via an input loop.
Unpost the form using form_unpost().
Free the form, using free_form().
Free the fields using free_field().
Terminate curses.
Note that this looks much like a menu program; the form library handles tasks which are in many ways similar, and its interface was obviously designed to resemble that of the menu library wherever possible.
In forms programs, however, the `process user requests' is somewhat more complicated than for menus. Besides menu-like navigation operations, the menu driver loop has to support field editing and data validation.


Creating and Freeing Fields and Forms

The basic function for creating fields is new_field():

FIELD *new_field(int height, int width, /* new field size */
int top, int left, /* upper left corner */
int offscreen, /* number of offscreen rows */
int nbuf); /* number of working buffers */
Menu items always occupy a single row, but forms fields may have multiple rows. So new_field() requires you to specify a width and height (the first two arguments, which mist both be greater than zero).
You must also specify the location of the field's upper left corner on the screen (the third and fourth arguments, which must be zero or greater). Note that these coordinates are relative to the form subwindow, which will coincide with stdscr by default but need not be stdscr if you've done an explicit set_form_window() call.

The fifth argument allows you to specify a number of off-screen rows. If this is zero, the entire field will always be displayed. If it is nonzero, the form will be scrollable, with only one screen-full (initially the top part) displayed at any given time. If you make a field dynamic and grow it so it will no longer fit on the screen, the form will become scrollable even if the \fBoffscreen\fR argument was initially zero.

The forms library allocates one working buffer per field; the size of each buffer is ((height + offscreen)*width + 1, one character for each position in the field plus a NUL terminator. The sixth argument is the number of additional data buffers to allocate for the field; your application can use them for its own purposes.


FIELD *dup_field(FIELD *field, /* field to copy */
int top, int left); /* location of new copy */
The function dup_field() duplicates an existing field at a new location. Size and buffering information are copied; some attribute flags and status bits are not (see the form_field_new(3X) for details).

FIELD *link_field(FIELD *field, /* field to copy */
int top, int left); /* location of new copy */
The function link_field() also duplicates an existing field at a new location. The difference from dup_field() is that it arranges for the new field's buffer to be shared with the old one.
Besides the obvious use in making a field editable from two different form pages, linked fields give you a way to hack in dynamic labels. If you declare several fields linked to an original, and then make them inactive, changes from the original will still be propagated to the linked fields.

As with duplicated fields, linked fields have attribute bits separate from the original.

As you might guess, all these field-allocations return NULL if the field allocation is not possible due to an out-of-memory error or out-of-bounds arguments.

To connect fields to a form, use


FORM *new_form(FIELD **fields);
This function expects to see a NULL-terminated array of field pointers. Said fields are connected to a newly-allocated form object; its address is returned (or else NULL if the allocation fails).
Note that new_field() does not copy the pointer array into private storage; if you modify the contents of the pointer array during forms processing, all manner of bizarre things might happen. Also note that any given field may only be connected to one form.

The functions free_field() and free_form are available to free field and form objects. It is an error to attempt to free a field connected to a form, but not vice-versa; thus, you will generally free your form objects first.


Fetching and Changing Field Attributes

Each form field has a number of location and size attributes associated with it. There are other field attributes used to control display and editing of the field. Some (for example, the \fBO_STATIC\fR bit) involve sufficient complications to be covered in sections of their own later on. We cover the functions used to get and set several basic attributes here.
When a field is created, the attributes not specified by the new_field function are copied from an invisible system default field. In attribute-setting and -fetching functions, the argument NULL is taken to mean this field. Changes to it persist as defaults until your forms application terminates.


Fetching Size and Location Data

You can retrieve field sizes and locations through:

int field_info(FIELD *field, /* field from which to fetch */
int *height, *int width, /* field size */
int *top, int *left, /* upper left corner */
int *offscreen, /* number of offscreen rows */
int *nbuf); /* number of working buffers */
This function is a sort of inverse of new_field(); instead of setting size and location attributes of a new field, it fetches them from an existing one.

Changing the Field Location

If is possible to move a field's location on the screen:

int move_field(FIELD *field, /* field to alter */
int top, int left); /* new upper-left corner */
You can, of course. query the current location through field_info().
The Justification Attribute

One-line fields may be unjustified, justified right, justified left, or centered. Here is how you manipulate this attribute:

int set_field_just(FIELD *field, /* field to alter */
int justmode); /* mode to set */

int field_just(FIELD *field); /* fetch mode of field */
The mode values accepted and returned by this functions are preprocessor macros NO_JUSTIFICATION, JUSTIFY_RIGHT, JUSTIFY_LEFT, or JUSTIFY_CENTER.

Field Display Attributes

For each field, you can set a foreground attribute for entered characters, a background attribute for the entire field, and a pad character for the unfilled portion of the field. You can also control pagination of the form.
This group of four field attributes controls the visual appearance of the field on the screen, without affecting in any way the data in the field buffer.


int set_field_fore(FIELD *field, /* field to alter */
chtype attr); /* attribute to set */

chtype field_fore(FIELD *field); /* field to query */

int set_field_back(FIELD *field, /* field to alter */
chtype attr); /* attribute to set */

chtype field_back(FIELD *field); /* field to query */

int set_field_pad(FIELD *field, /* field to alter */
int pad); /* pad character to set */

chtype field_pad(FIELD *field);

int set_new_page(FIELD *field, /* field to alter */
int flag); /* TRUE to force new page */

chtype new_page(FIELD *field); /* field to query */
The attributes set and returned by the first four functions are normal curses(3x) display attribute values (A_STANDOUT, A_BOLD, A_REVERSE etc). The page bit of a field controls whether it is displayed at the start of a new form screen.

Field Option Bits

There is also a large collection of field option bits you can set to control various aspects of forms processing. You can manipulate them with these functions:
int set_field_opts(FIELD *field, /* field to alter */
int attr); /* attribute to set */

int field_opts_on(FIELD *field, /* field to alter */
int attr); /* attributes to turn on */

int field_opts_off(FIELD *field, /* field to alter */
int attr); /* attributes to turn off */

int field_opts(FIELD *field); /* field to query */
By default, all options are on. Here are the available option bits:
O_VISIBLE
Controls whether the field is visible on the screen. Can be used during form processing to hide or pop up fields depending on the value of parent fields.
O_ACTIVE
Controls whether the field is active during forms processing (i.e. visited by form navigation keys). Can be used to make labels or derived fields with buffer values alterable by the forms application, not the user.
O_PUBLIC
Controls whether data is displayed during field entry. If this option is turned off on a field, the library will accept and edit data in that field, but it will not be displayed and the visible field cursor will not move. You can turn off the O_PUBLIC bit to define password fields.
O_EDIT
Controls whether the field's data can be modified. When this option is off, all editing requests except REQ_PREV_CHOICE and REQ_NEXT_CHOICEwill fail. Such read-only fields may be useful for help messages.
O_WRAP
Controls word-wrapping in multi-line fields. Normally, when any character of a (blank-separated) word reaches the end of the current line, the entire word is wrapped to the next line (assuming there is one). When this option is off, the word will be split across the line break.
O_BLANK
Controls field blanking. When this option is on, entering a character at the first field position erases the entire field (except for the just-entered character).
O_AUTOSKIP
Controls automatic skip to next field when this one fills. Normally, when the forms user tries to type more data into a field than will fit, the editing location jumps to next field. When this option is off, the user's cursor will hang at the end of the field. This option is ignored in dynamic fields that have not reached their size limit.
O_NULLOK
Controls whether validation is applied to blank fields. Normally, it is not; the user can leave a field blank without invoking the usual validation check on exit. If this option is off on a field, exit from it will invoke a validation check.
O_PASSOK
Controls whether validation occurs on every exit, or only after the field is modified. Normally the latter is true. Setting O_PASSOK may be useful if your field's validation function may change during forms processing.
O_STATIC
Controls whether the field is fixed to its initial dimensions. If you turn this off, the field becomes dynamic and will stretch to fit entered data.
A field's options cannot be changed while th


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 9:03 pm 
Offline
over 600 messages posted
over 600 messages posted
User avatar

Joined: Fri Sep 12, 2003 11:41 am
Posts: 693
Fortune Chan, let me get this straight. You're saying that if I go to this 'Google' and search for something like. say, 'organic farming' I'll get loads of stuff totally irrelevant to Lamma and be able to post it all here? That's amazing! Do I have to call myself 'flame' or what?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 9:14 pm 
Offline
over 600 messages posted
over 600 messages posted
User avatar

Joined: Fri Sep 12, 2003 11:41 am
Posts: 693
Hey, you're right! Look what I found, it sure beats the hell out of having to go to the trouble of having to think about something original to say:

Beautiful lawns, gardens and parks can be maintained without using pesticides.
Pesticides kill indiscriminately, killing pests along with their natural insect predators. This leads to the irony of pesticide use: once insect predators are eliminated, pest populations grow unchecked - leading to ever-greater pesticide applications. Utilizing the basic principles of Integrated Pest Management (IPM), you can take charge of your home and garden without the use of pesticides and inspire others to do the same.

The facts of pesticide use in the home and garden are very surprising:

 Each year 67 million pounds of pesticides are applied to lawns.
 Suburban lawns and gardens receive far heavier pesticide applications per acre than most agricultural areas.
Most consumers don't realize how potentially harmful they can be:

 Children are particularly vulnerable to pesticides, and the most likely to be exposed to lawn pesticides. Children living in homes using pesticides (indoor or outdoor) are at higher risk for developing brain cancer, childhood leukemia, lymphoma, and asthma.
 Pesticides are easily tracked indoors -- an EPA study found 23 pesticides in dust and air inside homes.
 Lawn chemicals can harm pets. Dog owners who use the herbicide 2,4,-D four or more times per season, double their dog's risk of developing lymphoma.
 Garden chemicals harm the environment. The U.S. Geological Survey routinely finds every type of garden chemical - particularly weed killers - in the streams and rivers around urban centers.
Safer Pest Control Project (SPCP) offers alternatives to pesticides and maintains lists of lawn care professionals who can provide non-toxic lawn care.

REFERENCES:
National Research Council, National Academy of Sciences, Urban Pest Management, 1980
Journal of the National Cancer Institute, 83 (17): 1226, 1991
Beyond Pesticides, Health Effects of 36 Commonly Used Lawn Pesticides, updated 2002.
Green, Emily "Bees are Paying Price for our Perfect Roses, Chicago Tribune, (August 1, 2004)
Daniels, Julie L. et al. "Pesticides and Childhood Cancers." Environmental Health Perspectives 105 (1997): 1068-1077.
Pesticide Free Zone
Let everyone know that your yard is pesticide free and pet and child friendly by posting a pesticide free zone sign. You can post these signs at schools, parks, and businesses.

Ideally, pesticide free means that no chemical pest controls at all are used. However, we consider the use of organically certified materials and EPA-exempt pesticides to be compatible with our philosophy because we want to encourage manufacturers to develop safer products. If the sign accurately reflects your practices, you can purchase it from SPCP.

The signs are eight-inch diameter aluminum signs that will last through harsh winters and hot summers. Each sign costs $10.00 which includes shipping and instructions for posting. Use our order form (at right) to place your order. Call about discounts for larger orders.

This sign comes with two factsheets: Talking to Your Neighbors About Pesticides and Pesticide Free Zone Yard Sign, including display instructions.

orderform1.pdf
Park District Manual
In general, parks have landscaping that requires a significant amount of effort to maintain. Unfortunately, this often means that pesticides are used to reduce weeds and unwanted insects. To, SPCP's manual, "Integrated Pest Management for Park Districts: Increasing the Effectiveness and Reducing the Risk of Pest Management", provides alternatives that reduce the amount of pesticides used.

This manual provides practical information on safe and effective methods of controlling weeds, turf and plant diseases, and common pests. It also includes steps outlining the transition into an IPM program, provides additional resources, and contains a list of IPM product suppliers.

Ask if your Park District practices IPM. If they don't, encourage them to do so with the help of this manual. We'd be happy to contact Park Districts interested in beginning a program to improve the health and well being of its residents by reducing pesticide use.

Download a free copy by clicking link at right.

pdmanual.pdf

Factsheets
Note: To download factsheets, you must sign up. It's free and simple.
Kids' Guide to Pesticides 186k
Kids' Guide to Pesticides (Spanish) 148k
Pesticide Free Zone Yard Sign 345k
IPM in the Garden 370k
IPM in the Garden (Spanish) 233k
Talking to Your Neighbors About Pesticides 418k
A Tale of Two Families 109k
Lawns We Can Live With 172k
Lawns We Can Live With (Spanish) 122k
Mosquito Misters: What You Need to Know 457k
West Nile Virus and Your Community 538k
Chicago-Area Garden Centers that Sell Environmentally Friendly Products 154k
Chicago-are Yard Care Companies that Offer Environmentally Friendly Services 111k
Laws to Protect You From Outdoor Pesticides 69k

Links
Take the Pledge
"The Green, Green Grass of Home" SPCP's article in Conscious Choice
Natural Pest Control - Chicago Wilderness magazine
IPM for Turfgrass in Schools
Illinois 'Right to Know' Law for Outdoor Pesticide Applications
 
Home About Us News Newsletter Resources Contact Donate
Schools Childcare Residential Yards & Parks
©2007 Safer Pest Control Project  info@spcpweb.org


.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 01, 2007 11:12 pm 
Offline
Over 1,000 messages posted
Over 1,000 messages posted
User avatar

Joined: Mon Dec 02, 2002 12:28 am
Posts: 1028
Location: on line
To quote 'The Specials' track called Pearl's Cafe....

Its all all a load of bollocks, and bollocks to it all

I dont think many people really care about this


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 8:28 pm 
Offline
over 600 messages posted
over 600 messages posted
User avatar

Joined: Fri Sep 12, 2003 11:41 am
Posts: 693
I dont think many people really care about this

I certainly don't. Bollocks indeed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 8:44 pm 
Offline
over 100 messages posted
over 100 messages posted
User avatar

Joined: Wed Sep 15, 2004 9:03 am
Posts: 125
Location: Isle de Lamma
Fascinating! I loved the bit about "Direct Field Buffer Manipulation" - who would ever have suspected it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC + 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group