Subject: bin/24755: cursor/repaint/form fixes for sushi(8)
To: None <gnats-bugs@gnats.NetBSD.org>
From: Peter Postma <peter@pointless.nl>
List: netbsd-bugs
Date: 03/12/2004 16:08:48
>Number:         24755
>Category:       bin
>Synopsis:       cursor/repaint/form fixes for sushi(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 12 15:09:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Peter Postma
>Release:        NetBSD 1.6ZK
>Organization:
>Environment:
System: NetBSD mercury.pointless.nl 1.6ZK NetBSD 1.6ZK (mercury) #26: Sun Mar 7 15:22:46 CET 2004 root@mercury.pointless.nl:/usr/obj/sys/arch/sparc64/compile/mercury sparc64
Architecture: sparc64
Machine: sparc64
>Description:
	Summary:

	* hide the cursor everywhere except in forms (looks nicer)
	* fix repaint with lists (from TODO)
	* fix the form page (removes XXX)
	* force a pos_form_cursor() after every keypress in the forms
	  to ensure that the selected field got the focus.
	* tweak the status message a bit.
>How-To-Repeat:
>Fix:

Index: C.msg
===================================================================
RCS file: /cvsroot/src/usr.sbin/sushi/C.msg,v
retrieving revision 1.11
diff -u -r1.11 C.msg
--- C.msg	9 Mar 2004 20:26:24 -0000	1.11
+++ C.msg	12 Mar 2004 14:56:40 -0000
@@ -65,6 +65,6 @@
 6 Enter the field data below, and hit enter to return to the form.
 7 Data Entry: 
 8 Form Page:
-9 PGUP/PGDN to change page, UP/DOWN switch field, ENTER=Do.
+9 PGUP/PGDN change page, UP/DOWN switch field, ENTER submit.
 10 Log ended at
 11 Script ended at
Index: TODO
===================================================================
RCS file: /cvsroot/src/usr.sbin/sushi/TODO,v
retrieving revision 1.7
diff -u -r1.7 TODO
--- TODO	1 Aug 2001 09:08:55 -0000	1.7
+++ TODO	12 Mar 2004 14:56:40 -0000
@@ -14,6 +14,5 @@
 /etc/ftpusers
 
 BUGS:
-the f4 popup isn't repainting the screen properly
 required fields, aren't.
 All of the /etc/*.conf menus need to be updated prior to release.
Index: scanform.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/sushi/scanform.c,v
retrieving revision 1.34
diff -u -r1.34 scanform.c
--- scanform.c	10 Mar 2004 19:03:16 -0000	1.34
+++ scanform.c	12 Mar 2004 14:56:40 -0000
@@ -80,11 +80,11 @@
 
 	wstandout(stdscr);
 	mvwaddstr(stdscr, ws.ws_row-3, 0, catgets(catalog, 4, 9,
-	    "PGUP/PGDN to change page, UP/DOWN switch field, ENTER=Do."));
+	    "PGUP/PGDN change page, UP/DOWN switch field, ENTER submit."));
 	wstandend(stdscr);
 	snprintf(buf, sizeof(buf), "%s (%d/%d)",
 	    catgets(catalog, 4, 8, "Form Page:"),
-	    form_page(form)+1, form->max_page); /* XXX */
+	    form_page(form)+1, form->max_page);
 	mvwaddstr(stdscr, ws.ws_row-3, 60, buf);
 	wrefresh(stdscr);
 }
@@ -481,10 +481,12 @@
 		/* NOTREACHED */
 		break;
 	case SHOWHELP:
+		curs_set(0);
 	        if (simple_lang_handler(path, HELPFILE, handle_help) == -2)
 			nohelp();
 		touchwin(stdscr);
 		wrefresh(stdscr);
+		curs_set(1);
 		return(FALSE);
 		/* NOTREACHED */
 		break;
@@ -500,6 +502,7 @@
 		if (field_buffer(curfield, 1) == NULL || 
 		    field_buffer(curfield, 0) == NULL)
 			return(FALSE);
+		curs_set(0);
 		otmp = tmp = strdup(field_buffer(curfield, 1));
 		stripWhiteSpace(vBOTH, tmp);
 		if (*tmp == 'm') {
@@ -545,6 +548,9 @@
 			destroyCDKScroll(plist);
 			free(otmp);
 		}
+		touchwin(stdscr);
+		wrefresh(stdscr);
+		curs_set(1);
 		return(FALSE);
 		/* NOTREACHED */
 		break;
@@ -859,6 +865,7 @@
 	if (strcmp("pre", form_userptr(form)) == 0)
 		return(process_preform(form, path));
 
+	curs_set(0);
 	*msg = catgets(catalog, 3, 17, "Are you sure? (Y/n)");
 	label = newCDKLabel(cdkscreen, CENTER, CENTER, msg, 1, TRUE, FALSE);
 	activateCDKLabel(label, NULL);
@@ -866,6 +873,7 @@
 	destroyCDKLabel(label);
 	touchwin(stdscr);
 	wrefresh(stdscr);
+	curs_set(1);
 	if (key != 13 && key != 10 && key != 121 && key != 89) /* enter y Y */
 		return -1;
 
@@ -1606,12 +1614,14 @@
 	} else
 		return;
 
+	curs_set(0);
 	label = newCDKLabel(cdkscreen, CENTER, CENTER, msg, lines, TRUE, FALSE);
 	activateCDKLabel(label, NULL);
 	waitCDKLabel(label, 0);
 	destroyCDKLabel(label);
 	touchwin(stdscr);
 	wrefresh(stdscr);
+	curs_set(1);
 }
 
 int
@@ -1637,6 +1647,7 @@
 		bailout("malloc: %s", strerror(errno));
 	fflush(NULL);
 
+	curs_set(0);
 	/* generate a label to let the user know we are thinking */
 	msg[0] = catgets(catalog, 4, 2, "Generating form data, please wait");
 	label = newCDKLabel(cdkscreen, CENTER, CENTER, msg, 1, TRUE, FALSE);
@@ -1665,11 +1676,15 @@
 	wrefresh(stdscr);
 	wrefresh(boxwin);
 	form_status(menuform);
+	curs_set(1);
 	while (!done) {
+		pos_form_cursor(menuform);
+		wrefresh(formwin);
 		switch (form_driver(menuform, c = get_request(formwin))) {
 		case E_OK:
 			if (c == REQ_NEXT_PAGE || c == REQ_PREV_PAGE ||
-			    c == REQ_FIRST_PAGE || c == REQ_LAST_PAGE)
+			    c == REQ_FIRST_PAGE || c == REQ_LAST_PAGE ||
+			    c == REQ_NEXT_FIELD || c == REQ_PREV_FIELD)
 				form_status(menuform);
 			break;
 		case E_UNKNOWN_COMMAND:
@@ -1682,6 +1697,7 @@
 			break;
 		}
 	}
+	curs_set(0);
 	fc = field_count(menuform);
 	f = form_fields(menuform);
 	unpost_form(menuform);
@@ -1738,6 +1754,7 @@
 		bailout("malloc: %s", strerror(errno));
 	fflush(NULL);
 
+	curs_set(0);
 	/* generate a label to let the user know we are thinking */
 	msg[0] = catgets(catalog, 4, 2, "Generating form data, please wait");
 	label = newCDKLabel(cdkscreen, CENTER, CENTER, msg, 1, TRUE, FALSE);
@@ -1763,11 +1780,15 @@
 	post_form(menuform);
 	wrefresh(stdscr);
 	form_status(menuform);
+	curs_set(1);
 	while (!done) {
+		pos_form_cursor(menuform);
+		wrefresh(formwin);
 		switch (form_driver(menuform, c = get_request(formwin))) {
 		case E_OK:
 			if (c == REQ_NEXT_PAGE || c == REQ_PREV_PAGE ||
-			    c == REQ_FIRST_PAGE || c == REQ_LAST_PAGE)
+			    c == REQ_FIRST_PAGE || c == REQ_LAST_PAGE ||
+			    c == REQ_NEXT_FIELD || c == REQ_PREV_FIELD)
 				form_status(menuform);
 			break;
 		case E_UNKNOWN_COMMAND:
@@ -1780,6 +1801,7 @@
 			break;
 		}
 	}
+	curs_set(0);
 	fc = field_count(menuform);
 	f = form_fields(menuform);
 	unpost_form(menuform);
Index: sushi.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/sushi/sushi.c,v
retrieving revision 1.17
diff -u -r1.17 sushi.c
--- sushi.c	9 Mar 2004 20:16:16 -0000	1.17
+++ sushi.c	12 Mar 2004 14:56:41 -0000
@@ -98,6 +98,7 @@
 	use_default_colors();
 
 	initCDKColor();
+	curs_set(0);
 	raw();
 
 	tree_init();
@@ -124,6 +125,7 @@
 
 	destroyCDKScreen(cdkscreen);
 	endCDK();
+	curs_set(1);
 	endwin();
 #ifdef DEBUG
 	tree_printtree(cqMenuHeadp);
@@ -384,6 +386,7 @@
 
 	destroyCDKScreen(cdkscreen);
 	endCDK();
+	curs_set(1);
 	fprintf(stderr, "%s: ", getprogname());
 	if (fmt != NULL)
 		vfprintf(stderr, fmt, ap);

>Release-Note:
>Audit-Trail:
>Unformatted: