* Changed type of userptr to be void * (now matches ncurses)
* Bumped lib major version due to above. * Changed debug output to go to a file instead of stderr, the file gets opened when the form is posted iff one is not already open.
This commit is contained in:
parent
8e47aad460
commit
af28ef95ea
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: field.c,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
|
||||
/* $NetBSD: field.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-1999 Brett Lymn
|
||||
* (blymn@baea.com.au, brett_lymn@yahoo.com.au)
|
||||
|
@ -83,7 +83,7 @@ _formi_create_field(FIELD *, int, int, int, int, int, int);
|
|||
* Set the userptr for the field
|
||||
*/
|
||||
int
|
||||
set_field_userptr(FIELD *field, char *ptr)
|
||||
set_field_userptr(FIELD *field, void *ptr)
|
||||
{
|
||||
FIELD *fp = (field == NULL) ? &_formi_default_field : field;
|
||||
|
||||
|
@ -96,7 +96,7 @@ set_field_userptr(FIELD *field, char *ptr)
|
|||
* Return the userptr for the field.
|
||||
*/
|
||||
|
||||
char *
|
||||
void *
|
||||
field_userptr(FIELD *field)
|
||||
{
|
||||
if (field == NULL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: form.c,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
|
||||
/* $NetBSD: form.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998-1999 Brett Lymn
|
||||
|
@ -154,7 +154,7 @@ scale_form(FORM *form, int *rows, int *cols)
|
|||
* Set the user defined pointer for the form given.
|
||||
*/
|
||||
int
|
||||
set_form_userptr(FORM *form, char *ptr)
|
||||
set_form_userptr(FORM *form, void *ptr)
|
||||
{
|
||||
if (form == NULL)
|
||||
_formi_default_form.userptr = ptr;
|
||||
|
@ -167,7 +167,7 @@ set_form_userptr(FORM *form, char *ptr)
|
|||
/*
|
||||
* Return the user defined pointer associated with the given form.
|
||||
*/
|
||||
char *
|
||||
void *
|
||||
form_userptr(FORM *form)
|
||||
{
|
||||
|
||||
|
@ -577,7 +577,7 @@ pos_form_cursor(FORM *form)
|
|||
row = cur->form_row + cur->cursor_ypos;
|
||||
col = cur->form_col + cur->cursor_xpos;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "pos_cursor: row=%d, col=%d\n", row, col);
|
||||
fprintf(dbg, "pos_cursor: row=%d, col=%d\n", row, col);
|
||||
#endif
|
||||
|
||||
wmove(form->subwin, row, col);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: form.h,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
|
||||
/* $NetBSD: form.h,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998-1999 Brett Lymn
|
||||
|
@ -270,7 +270,7 @@ int field_pad(FIELD *);
|
|||
int field_status(FIELD *);
|
||||
Form_Hook field_term(FORM *);
|
||||
FIELDTYPE *field_type(FIELD *);
|
||||
char *field_userptr(FIELD *);
|
||||
void *field_userptr(FIELD *);
|
||||
int form_driver(FORM *, int);
|
||||
FIELD **form_fields(FORM *);
|
||||
Form_Hook form_init(FORM *);
|
||||
|
@ -280,7 +280,7 @@ int form_opts_on(FORM *, Form_Options);
|
|||
int form_page(FORM *);
|
||||
WINDOW *form_sub(FORM *);
|
||||
Form_Hook form_term(FORM *);
|
||||
char *form_userptr(FORM *);
|
||||
void *form_userptr(FORM *);
|
||||
WINDOW *form_win(FORM *);
|
||||
int free_field(FIELD *);
|
||||
int free_fieldtype(FIELDTYPE *);
|
||||
|
@ -307,7 +307,7 @@ int set_field_pad(FIELD *, int);
|
|||
int set_field_status(FIELD *, int);
|
||||
int set_field_term(FORM *, Form_Hook);
|
||||
int set_field_type(FIELD *, FIELDTYPE *, ...);
|
||||
int set_field_userptr(FIELD *, char *);
|
||||
int set_field_userptr(FIELD *, void *);
|
||||
int set_fieldtype_arg(FIELDTYPE *, char *(*)(va_list *),
|
||||
char *(*)(char *),
|
||||
void (*)(char *));
|
||||
|
@ -319,7 +319,7 @@ int set_form_opts(FORM *, Form_Options);
|
|||
int set_form_page(FORM *, int);
|
||||
int set_form_sub(FORM *, WINDOW *);
|
||||
int set_form_term(FORM *, Form_Hook);
|
||||
int set_form_userptr(FORM *, char *);
|
||||
int set_form_userptr(FORM *, void *);
|
||||
int set_form_win(FORM *, WINDOW *);
|
||||
int set_max_field(FIELD *, int);
|
||||
int set_new_page(FIELD *, int);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: internals.c,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
|
||||
/* $NetBSD: internals.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998-1999 Brett Lymn
|
||||
|
@ -36,6 +36,14 @@
|
|||
#include "internals.h"
|
||||
#include "form.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* file handle to write debug info to, this will be initialised when
|
||||
* the form is first posted.
|
||||
*/
|
||||
FILE *dbg = NULL;
|
||||
#endif
|
||||
|
||||
/* define our own min function - this is not generic but will do here
|
||||
* (don't believe me? think about what value you would get
|
||||
* from min(x++, y++)
|
||||
|
@ -714,11 +722,11 @@ _formi_redraw_field(FORM *form, int field)
|
|||
wattrset(form->subwin, cur->back);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "redraw_field: start=%d, pre=%d, slen=%d, flen=%d, post=%d, hscroll=%d\n",
|
||||
fprintf(dbg, "redraw_field: start=%d, pre=%d, slen=%d, flen=%d, post=%d, hscroll=%d\n",
|
||||
start, pre, slen, flen, post, cur->hscroll);
|
||||
strncpy(buffer, &str[cur->start_char], flen);
|
||||
buffer[flen] = '\0';
|
||||
fprintf(stderr, "redraw_field: %s\n", buffer);
|
||||
fprintf(dbg, "redraw_field: %s\n", buffer);
|
||||
#endif
|
||||
|
||||
for (i = start + cur->hscroll; i < pre; i++)
|
||||
|
@ -734,14 +742,14 @@ _formi_redraw_field(FORM *form, int field)
|
|||
flen = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "redraw_field: will add %d chars, offset is %d\n",
|
||||
fprintf(dbg, "redraw_field: will add %d chars, offset is %d\n",
|
||||
min(slen, flen), offset);
|
||||
#endif
|
||||
for (i = 0;
|
||||
i < min(slen, flen); i++)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "adding char str[%d]=%c\n",
|
||||
fprintf(dbg, "adding char str[%d]=%c\n",
|
||||
i + offset, str[i + offset]);
|
||||
#endif
|
||||
waddch(form->subwin,
|
||||
|
@ -789,12 +797,13 @@ _formi_add_char(FIELD *field, unsigned int pos, char c)
|
|||
int status;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"add_char: pos=%d, char=%c\n", pos, c);
|
||||
fprintf(stderr,"add_char enter: xpos=%d, start=%d, length=%d(%d), allocated=%d\n",
|
||||
fprintf(dbg, "add_char: pos=%d, char=%c\n", pos, c);
|
||||
fprintf(dbg,
|
||||
"add_char enter: xpos=%d, start=%d, length=%d(%d), allocated=%d\n",
|
||||
field->cursor_xpos, field->start_char,
|
||||
field->buffers[0].length, strlen(field->buffers[0].string),
|
||||
field->buffers[0].allocated);
|
||||
fprintf(stderr,"add_char enter: %s\n", field->buffers[0].string);
|
||||
fprintf(dbg, "add_char enter: %s\n", field->buffers[0].string);
|
||||
#endif
|
||||
if (((field->opts & O_BLANK) == O_BLANK) &&
|
||||
(field->buf0_status == FALSE)) {
|
||||
|
@ -864,12 +873,13 @@ _formi_add_char(FIELD *field, unsigned int pos, char c)
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"add_char exit: xpos=%d, start=%d, length=%d(%d), allocated=%d\n",
|
||||
fprintf(dbg,
|
||||
"add_char exit: xpos=%d, start=%d, length=%d(%d), allocated=%d\n",
|
||||
field->cursor_xpos, field->start_char,
|
||||
field->buffers[0].length, strlen(field->buffers[0].string),
|
||||
field->buffers[0].allocated);
|
||||
fprintf(stderr,"add_char exit: %s\n", field->buffers[0].string);
|
||||
fprintf(stderr, "add_char exit: status = %s\n",
|
||||
fprintf(dbg,"add_char exit: %s\n", field->buffers[0].string);
|
||||
fprintf(dbg, "add_char exit: status = %s\n",
|
||||
(status == E_OK)? "OK" : "FAILED");
|
||||
#endif
|
||||
return (status == E_OK);
|
||||
|
@ -890,10 +900,11 @@ _formi_manipulate_field(FORM *form, int c)
|
|||
cur = form->fields[form->cur_field];
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "entry: xpos=%d, start_char=%d, length=%d, allocated=%d\n",
|
||||
fprintf(dbg,
|
||||
"entry: xpos=%d, start_char=%d, length=%d, allocated=%d\n",
|
||||
cur->cursor_xpos, cur->start_char, cur->buffers[0].length,
|
||||
cur->buffers[0].allocated);
|
||||
fprintf(stderr, "entry: string=\"%s\"\n", cur->buffers[0].string);
|
||||
fprintf(dbg, "entry: string=\"%s\"\n", cur->buffers[0].string);
|
||||
#endif
|
||||
switch (c) {
|
||||
case REQ_NEXT_CHAR:
|
||||
|
@ -1103,7 +1114,7 @@ _formi_manipulate_field(FORM *form, int c)
|
|||
return E_REQUEST_DENIED;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "req_right_char enter: start=%d, xpos=%d, c=%c\n",
|
||||
fprintf(dbg, "req_right_char enter: start=%d, xpos=%d, c=%c\n",
|
||||
cur->start_char, cur->cursor_xpos,
|
||||
cur->buffers[0].string[pos]);
|
||||
#endif
|
||||
|
@ -1127,7 +1138,7 @@ _formi_manipulate_field(FORM *form, int c)
|
|||
cur->cursor_xpos++;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "req_right_char exit: start=%d, xpos=%d, c=%c\n",
|
||||
fprintf(dbg, "req_right_char exit: start=%d, xpos=%d, c=%c\n",
|
||||
cur->start_char, cur->cursor_xpos,
|
||||
cur->buffers[0].string[cur->start_char +
|
||||
cur->cursor_xpos]);
|
||||
|
@ -1334,10 +1345,10 @@ _formi_manipulate_field(FORM *form, int c)
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "exit: xpos=%d, start_char=%d, length=%d, allocated=%d\n",
|
||||
fprintf(dbg, "exit: xpos=%d, start_char=%d, length=%d, allocated=%d\n",
|
||||
cur->cursor_xpos, cur->start_char, cur->buffers[0].length,
|
||||
cur->buffers[0].allocated);
|
||||
fprintf(stderr, "exit: string=\"%s\"\n", cur->buffers[0].string);
|
||||
fprintf(dbg, "exit: string=\"%s\"\n", cur->buffers[0].string);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
@ -1561,7 +1572,7 @@ _formi_stitch_fields(FORM *form)
|
|||
below_row = -1;
|
||||
end_below = TRUE;
|
||||
real_end = TRUE;
|
||||
while (below != CIRCLEQ_FIRST(&form->sorted_fields)) {
|
||||
while (below != (void *)&form->sorted_fields) {
|
||||
if (below->form_row != cur_row) {
|
||||
below_row = below->form_row;
|
||||
end_below = FALSE;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: internals.h,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
|
||||
/* $NetBSD: internals.h,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998-1999 Brett Lymn
|
||||
|
@ -29,11 +29,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "form.h"
|
||||
|
||||
#ifndef FORMI_INTERNALS_H
|
||||
#define FORMI_INTERNALS_H 1
|
||||
|
||||
#ifdef DEBUG
|
||||
extern FILE *dbg;
|
||||
#endif
|
||||
|
||||
/* direction definitions for _formi_pos_new_field */
|
||||
#define _FORMI_BACKWARD 1
|
||||
#define _FORMI_FORWARD 2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: post.c,v 1.1 2000/12/17 12:04:30 blymn Exp $ */
|
||||
/* $NetBSD: post.c,v 1.2 2001/01/04 12:30:37 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998-2000 Brett Lymn
|
||||
|
@ -68,6 +68,16 @@ post_form(FORM *form)
|
|||
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (dbg == NULL) {
|
||||
dbg = fopen("___form_dbg.out", "w");
|
||||
if (dbg == NULL) {
|
||||
fprintf(stderr, "Cannot open debug file!\n");
|
||||
return E_SYSTEM_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
form->in_init = 1;
|
||||
if (form->form_init != NULL)
|
||||
form->form_init(form);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: shlib_version,v 1.1 2000/12/17 12:04:30 blymn Exp $
|
||||
# $NetBSD: shlib_version,v 1.2 2001/01/04 12:30:37 blymn Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
major=0
|
||||
major=1
|
||||
minor=0
|
||||
|
|
Loading…
Reference in New Issue