]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/move_field.c
ncurses 6.2 - patch 20210327
[ncurses.git] / test / move_field.c
index 8344c56f8c14ed62ea273024fe3e9048fcfe07cf..5e7fc82e3904ace6694ce2f7a2c67065420a9369 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: move_field.c,v 1.7 2020/05/09 12:52:00 tom Exp $
+ * $Id: move_field.c,v 1.8 2021/03/27 23:41:57 tom Exp $
  *
  * Demonstrate move_field().
  */
@@ -41,7 +41,7 @@
 #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 */
+#else /* e.g., SVr4, ncurses */
 #define form_field_row(field) (field)->frow
 #define form_field_col(field) (field)->fcol
 #endif
@@ -51,7 +51,6 @@
 
 static char empty[] = "";
 static FIELD *all_fields[100];
-
 /* *INDENT-OFF* */
 static struct {
     int code;
@@ -196,7 +195,6 @@ my_edit_field(FORM *form, int *result)
     int status;
     FIELD *before;
     unsigned n;
-    int length;
     int before_row;
     int before_col;
     int before_off = offset_in_field(form);
@@ -222,8 +220,8 @@ my_edit_field(FORM *form, int *result)
 
     if (status == E_OK) {
        bool modified = TRUE;
+       int length = buffer_length(before);
 
-       length = buffer_length(before);
        if (length < before_off)
            length = before_off;
        switch (*result) {
@@ -316,10 +314,10 @@ do_demo(FORM *form)
        size_t needed = (size_t) count;
        FIELD **old_fields = copy_fields(form_fields(form), needed);
        FIELD **new_fields = copy_fields(form_fields(form), needed);
-       int ch;
 
        if (old_fields != NULL && new_fields != NULL) {
            bool found = FALSE;
+           int ch;
 
            /* TODO: move the label too, in parallel with the editing field */
 
@@ -338,7 +336,6 @@ do_demo(FORM *form)
                getyx(stdscr, currow, curcol);
 
                show_status(form, my_field);
-               ch = '?';
                while ((ch = wgetch(form_win(form))) != DO_DEMO) {
                    int field_y = form_field_row(my_field);
                    int field_x = form_field_col(my_field);