/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2022 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* authorization. *
****************************************************************************/
/*
- * $Id: move_field.c,v 1.8 2021/03/27 23:41:57 tom Exp $
+ * $Id: move_field.c,v 1.13 2022/05/21 20:59:46 tom Exp $
*
* Demonstrate move_field().
*/
#include <edit_field.h>
#include <popup_msg.h>
-#ifdef HAVE_NETBSD_FORM_H
-#define form_field_row(field) (field)->form_row
-#define form_field_col(field) (field)->form_col
-#else /* e.g., SVr4, ncurses */
-#define form_field_row(field) (field)->frow
-#define form_field_col(field) (field)->fcol
-#endif
-
#define DO_DEMO CTRL('F') /* actual key for toggling demo-mode */
#define MY_DEMO EDIT_FIELD('f') /* internal request-code */
werase(w);
wrefresh(w);
delwin(s);
- delwin(w);
}
static FieldAttrs *
static FIELD **
copy_fields(FIELD **source, size_t length)
{
- FIELD **target = calloc(length + 1, sizeof(FIELD *));
+ FIELD **target = typeCalloc(FIELD *, length + 1);
memcpy(target, source, length * sizeof(FIELD *));
return target;
}
{
int count = field_count(form);
FIELD *my_field = current_field(form);
+ FIELD **old_fields = form_fields(form);
- if (count > 0 && my_field != NULL) {
+ if (count > 0 && old_fields != NULL && my_field != NULL) {
size_t needed = (size_t) count;
- FIELD **old_fields = copy_fields(form_fields(form), needed);
- FIELD **new_fields = copy_fields(form_fields(form), needed);
+ FIELD **new_fields = copy_fields(old_fields, needed);
- if (old_fields != NULL && new_fields != NULL) {
+ if (new_fields != NULL) {
bool found = FALSE;
int ch;