Multiple fixes:

* A debug version of libform will be build if DEBUG_FORMS is defined
* Can no longer edit fields that do not have O_EDIT set
* Changed background attribute to A_NORMAL like ncurses
* Fixed truncation of field contents when content length == field length
* Current field is set to first visible & active field on form post
This commit is contained in:
blymn 2001-01-16 01:02:47 +00:00
parent 2e39f7eacf
commit c021922626
8 changed files with 27 additions and 15 deletions

View File

@ -1,8 +1,11 @@
# $NetBSD: Makefile,v 1.1 2000/12/17 12:04:30 blymn Exp $
# $NetBSD: Makefile,v 1.2 2001/01/16 01:02:47 blymn Exp $
#
DBG=-g
CPPFLAGS+=-I${.CURDIR} #-DDEBUG
CPPFLAGS+=-I${.CURDIR}
.if defined(DEBUG_FORMS)
CFLAGS+=-g
CPPFLAGS+=-DDEBUG
.endif
LIB= form
SRCS= driver.c field_types.c internals.c field.c form.c post.c type_alnum.c \
type_alpha.c type_integer.c type_numeric.c type_enum.c type_regex.c \

View File

@ -1,4 +1,4 @@
/* $NetBSD: driver.c,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
/* $NetBSD: driver.c,v 1.2 2001/01/16 01:02:47 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@ -123,6 +123,10 @@ form_driver(FORM *form, int c)
pos = fieldp->start_char + fieldp->cursor_xpos
+ fieldp->hscroll;
/* check if we are allowed to edit this field */
if ((fieldp->opts & O_EDIT) != O_EDIT)
return E_REQUEST_DENIED;
/*
* Need to check here if we want to autoskip.
* we call the form driver recursively to pos

View File

@ -1,4 +1,4 @@
/* $NetBSD: field.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
/* $NetBSD: field.c,v 1.3 2001/01/16 01:02:47 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
* (blymn@baea.com.au, brett_lymn@yahoo.com.au)
@ -58,7 +58,7 @@ FIELD _formi_default_field = {
0, /* start of a new page on the form if 1 */
0, /* number of the page this field is on */
A_NORMAL, /* character attributes for the foreground */
A_REVERSE, /* character attributes for the background */
A_NORMAL, /* character attributes for the background */
' ', /* padding character */
DEFAULT_FORM_OPTS, /* options for the field */
NULL, /* the form this field is bound to, if any */

View File

@ -1,4 +1,4 @@
/* $NetBSD: form.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
/* $NetBSD: form.c,v 1.3 2001/01/16 01:02:47 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@ -40,6 +40,7 @@ extern FIELD _formi_default_field;
FORM _formi_default_form = {
FALSE, /* true if performing a init or term function */
FALSE, /* the form is posted */
FALSE, /* make field list circular if true */
NULL, /* window for the form */
NULL, /* subwindow for the form */
NULL, /* user defined pointer */

View File

@ -1,4 +1,4 @@
/* $NetBSD: form.h,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
/* $NetBSD: form.h,v 1.3 2001/01/16 01:02:47 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@ -221,6 +221,7 @@ struct _form_fieldtype {
struct _form_struct {
int in_init; /* true if performing a init or term function */
int posted; /* the form is posted */
int wrap; /* wrap from last field to first field if true */
WINDOW *win; /* window for the form */
WINDOW *subwin; /* subwindow for the form */
void *userptr; /* user defined pointer */

View File

@ -1,4 +1,4 @@
/* $NetBSD: internals.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
/* $NetBSD: internals.c,v 1.3 2001/01/16 01:02:47 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn
@ -736,9 +736,10 @@ _formi_redraw_field(FORM *form, int field)
if (cur->start_char > 0)
offset += cur->start_char - 1;
if (flen > cur->hscroll + 1)
flen -= cur->hscroll + 1;
else
if (flen > cur->hscroll + 1) {
if (flen > slen)
flen -= cur->hscroll + 1;
} else
flen = 0;
#ifdef DEBUG
@ -1492,6 +1493,7 @@ field_sort_compare(const void *one, const void *two)
const FIELD *a, *b;
int tl;
/* LINTED const castaway; we don't modify these! */
a = (const FIELD *) *((const FIELD **) one);
b = (const FIELD *) *((const FIELD **) two);

View File

@ -1,4 +1,4 @@
/* $NetBSD: post.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
/* $NetBSD: post.c,v 1.3 2001/01/16 01:02:47 blymn Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@ -86,6 +86,7 @@ post_form(FORM *form)
form->field_init(form);
form->in_init = 0;
_formi_pos_first_field(form);
if ((status = _formi_draw_page(form)) != E_OK)
return status;

View File

@ -1,5 +1,5 @@
# $NetBSD: shlib_version,v 1.4 2001/01/07 13:15:11 jdc Exp $
# $NetBSD: shlib_version,v 1.5 2001/01/16 01:02:47 blymn Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=1
minor=0
minor=1