/****************************************************************************
- * Copyright (c) 2003-2007,2008 Free Software Foundation, Inc. *
+ * Copyright (c) 2003-2008,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: demo_forms.c,v 1.30 2008/10/18 20:38:20 tom Exp $
+ * $Id: demo_forms.c,v 1.33 2009/08/29 18:47:26 tom Exp $
*
* Demonstrate a variety of functions from the form library.
* Thomas Dickey - 2003/4/26
FIELD *f = new_field(rows, cols, frow, fcol, o_value, 1);
if (f) {
+ FieldAttrs *ptr;
+
set_field_back(f, A_UNDERLINE);
/*
* If -j and -d options are combined, -j loses. It is documented in
/*
* The userptr is used in edit_field.c's inactive_field().
*/
- set_field_userptr(f, (void *) (long) field_back(f));
+ ptr = (FieldAttrs *) field_userptr(f);
+ if (ptr == 0) {
+ ptr = typeCalloc(FieldAttrs, 1);
+ ptr->background = field_back(f);
+ }
+ set_field_userptr(f, (void *) ptr);
if (t_value)
set_field_buffer(f, 0, t_value);
}
}
waddch(win, ' ');
- wattrset(win, field_fore(field));
+ (void) wattrset(win, field_fore(field));
waddstr(win, "fore");
wattroff(win, field_fore(field));
waddch(win, '/');
- wattrset(win, field_back(field));
+ (void) wattrset(win, field_back(field));
waddstr(win, "back");
wattroff(win, field_back(field));
for (nbuf = 0; nbuf <= 2; ++nbuf) {
if ((buffer = field_buffer(field, nbuf)) != 0) {
wprintw(win, "buffer %d:", nbuf);
- wattrset(win, A_REVERSE);
+ (void) wattrset(win, A_REVERSE);
waddstr(win, buffer);
wattroff(win, A_REVERSE);
waddstr(win, "\n");
free_form(form);
}
- for (c = 0; f[c] != 0; c++)
+ for (c = 0; f[c] != 0; c++) {
+ void *ptr = field_userptr(f[c]);
+ free(ptr);
free_field(f[c]);
+ }
noraw();
nl();