Module Name:    src
Committed By:   blymn
Date:           Tue Oct 19 21:22:20 UTC 2021

Modified Files:
        src/lib/libform: internals.c

Log Message:
Fix for PR lib/47397

Fix a misinterpretation of the role of field fore and back.  Now field
pad is rendered in the back attribute always instead of only being used
for the non-current field.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libform/internals.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libform/internals.c
diff -u src/lib/libform/internals.c:1.40 src/lib/libform/internals.c:1.41
--- src/lib/libform/internals.c:1.40	Tue Apr 13 13:13:04 2021
+++ src/lib/libform/internals.c	Tue Oct 19 21:22:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: internals.c,v 1.40 2021/04/13 13:13:04 christos Exp $	*/
+/*	$NetBSD: internals.c,v 1.41 2021/10/19 21:22:20 blymn Exp $	*/
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: internals.c,v 1.40 2021/04/13 13:13:04 christos Exp $");
+__RCSID("$NetBSD: internals.c,v 1.41 2021/10/19 21:22:20 blymn Exp $");
 
 #include <limits.h>
 #include <ctype.h>
@@ -1606,11 +1606,6 @@ _formi_redraw_field(FORM *form, int fiel
 			}
 		}
 
-		if (form->cur_field == field)
-			wattrset(form->scrwin, cur->fore);
-		else
-			wattrset(form->scrwin, cur->back);
-
 		str = &row->string[cur->start_char];
 
 #ifdef DEBUG
@@ -1631,11 +1626,14 @@ _formi_redraw_field(FORM *form, int fiel
 		_formi_dbg_printf("%s: %s\n", __func__,  buffer);
 #endif
 
+		wattrset(form->scrwin, cur->back);
+
 		for (i = start + cur->start_char; i < pre; i++)
 			waddch(form->scrwin, cur->pad);
 
 		_formi_dbg_printf("%s: will add %d chars\n", __func__,
 			min(slen, flen));
+		wattrset(form->scrwin, cur->fore);
 		for (i = 0, cpos = cur->start_char; i < min(slen, flen);
 		     i++, str++, cpos++) 
 		{
@@ -1647,8 +1645,11 @@ _formi_redraw_field(FORM *form, int fiel
 				if (c == '\t')
 					tab = add_tab(form, row, cpos,
 						      cur->pad);
-				else
+				else {
+					wattrset(form->scrwin, cur->back);
 					waddch(form->scrwin, cur->pad);
+					wattrset(form->scrwin, cur->fore);
+				}
 			} else if ((cur->opts & O_VISIBLE) == O_VISIBLE) {
 				if (c == '\t')
 					tab = add_tab(form, row, cpos, ' ');
@@ -1670,6 +1671,7 @@ _formi_redraw_field(FORM *form, int fiel
 				i += tab - 1;
 		}
 
+		wattrset(form->scrwin, cur->back);
 		for (i = 0; i < post; i++)
 			waddch(form->scrwin, cur->pad);
 	}
@@ -1678,10 +1680,7 @@ _formi_redraw_field(FORM *form, int fiel
 		wmove(form->scrwin, (int) (cur->form_row + i),
 		      (int) cur->form_col);
 
-		if (form->cur_field == field)
-			wattrset(form->scrwin, cur->fore);
-		else
-			wattrset(form->scrwin, cur->back);
+		wattrset(form->scrwin, cur->back);
 
 		for (j = 0; j < cur->cols; j++) {
 			waddch(form->scrwin, cur->pad);

Reply via email to