[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ncurses & commercial applications
From: |
Dan Hatchen |
Subject: |
Re: ncurses & commercial applications |
Date: |
Tue, 07 Aug 2001 16:43:56 -0600 |
> <snip>
I wrote a 15,000 line program this spring using C, ncurses, and MySQL that
tracks
and bills for
almost 300,000 items in a 3rd party warehouse. A smaller (1000 line) program
interfaces this
with their accounting program. I share this only to let you know that I have
done
non-trivial
work with ncurses.
PS I prefer MySQL to Prostgres. Its faster and does so have transactions and row
locks, depending
on which table types you use.
#1 Look at the demo programs, they will give you a good start. The HOW-TOs are
ok
but they
only tell you about the API, not how it fits together. I did quite a bit of
source
tracing and printed
out some of the structures before I got a small working knowledge
I give some code examples here. I am sure that other have better ways of doing
this,
but this is just
to illustrate
> While going through ncurses we have got the following problems :
>
> 1. How to validate date fields ?
>
> 2. How to create validation functions for each field where we can put our
> customised error messages for users ?
>
> 3. There is something called HOOKS. What is it ? We could not find any proper
> documentation regarding this in the HTML ncurse-intro by Raymond.
The 'HOOKS' are the answer to your first three questions. They are called when
you
enter, leave a field
or a form. They are stored function pointers.
First write your 'handler'
-------------------------------------------------------------------------------------------------
void MyFormFieldInit( FORM * f )
{
int x = field_index( current_field( f ) ); /* which field are we
entering */
switch( x )
{
case 1: /* first field */
/* do stuff */
case 2: /* second field */
etc ...
}
}
-------------------------------------------------------------------------------------------------
then , in your module entry point
-------------------------------------------------------------------------------------------------
void MyForm( void )
{
void ( *fieldinit ) ( FORM * f1); /* declare prototype */
...
fieldinit = MyFormFieldInit; /* set to your handler */
...
/* build and instanciate MyForm as f */
set_field_init( f, fieldinit ); /* ncurses call - registers the
function pointer*/
/* need a message loop */
do
{
switch ( form_driver( f, c = FormKeys( w ) ) ) /* FormKeys - my own
keystoke handler */
{
/*
I can override or pass to ncurses */
case E_OK:
wrefresh( w );
break;
case E_INVALID_FIELD:
MyFormFieldError( f ); /* I can display error messages
based on field I am in */
break;
case E_UNKNOWN_COMMAND:
if ( !( finished = ( c == KEY_MAX ) ? TRUE : FALSE ) )
MyFormFunctions( f, c ); /* I can trap and respond
to the
extended keys */
break;
default:
beep( );
break;
}
}
while ( !finished );
...
/* free resources */
}
-------------------------------------------------------------------------------------------------
> 4. One of our requirement is Master - Detail forms say for entry of Invoices.
> There will be header part and than the detail part will contain 'n' no. of
> items
> in the Invoice. Is there any easy way out for this ?
>
I did not find this part easy but through the use of panels was able to have
a header,
a scrolling window of line items,
a line item entry window,
and a footer.
Hope this helps some.
contact me private if you wish so we can keep this list clear
P.S
Thomas,
I have given some thought to a screen painter and a report writer like many 4GLs
have for
ncurses. I am short of time for a month or two, but do you think that there
would be
enough demand
for a project like that ????
danh