From nobody@FreeBSD.org  Sun Jul 10 19:06:05 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 034721065673
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 10 Jul 2011 19:06:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id CE0718FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 10 Jul 2011 19:06:04 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6AJ646X094016
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 10 Jul 2011 19:06:04 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p6AJ64Tq094015;
	Sun, 10 Jul 2011 19:06:04 GMT
	(envelope-from nobody)
Message-Id: <201107101906.p6AJ64Tq094015@red.freebsd.org>
Date: Sun, 10 Jul 2011 19:06:04 GMT
From: Alexander Best <arundel@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: top(1)'s output when using 'C' and 'H' interactively is inconsistent with the other interactive keys
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         158775
>Category:       bin
>Synopsis:       [patch] top(1)'s output when using 'C' and 'H' interactively is inconsistent with the other interactive keys
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jhb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 10 19:10:10 UTC 2011
>Closed-Date:    Mon Mar 04 18:56:46 UTC 2013
>Last-Modified:  Mon Mar 04 18:56:46 UTC 2013
>Originator:     Alexander Best
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD otaku 9.0-CURRENT FreeBSD 9.0-CURRENT #20 r223849=be9ff60-dirty: Fri Jul  8 04:39:15 CEST 2011     arundel@otaku:/usr/obj/usr/git-freebsd-head/sys/ARUNDEL  amd64
>Description:
when using the interaactive key commands in top, such as 'z' or 't', the output is being displayed with an extra space before it. this is useful, because the first character is occupied by the blinking cursor and thus improves readability of the output.

for the 'C' and 'H' keys however this isn't the case. no extra space is being displayed before the output and thus the first character collides with the cursors postion.

the attached patch should fix the problem.

please note that for interactive commands such as 'u' or 's' the situation is different. the cursor jumps to the end of the output, because the user is requested to input further information. for these messages not having an extra space at their beginning is OK.
>How-To-Repeat:
run 'top' and compare the output of the 'C' and 'H' command, compared to 'z' or 't' e.g.
>Fix:


Patch attached with submission follows:

diff --git a/contrib/top/top.c b/contrib/top/top.c
index 6673a27..31dd869 100644
--- a/contrib/top/top.c
+++ b/contrib/top/top.c
@@ -1019,7 +1020,7 @@ restart:
 			    case CMD_thrtog:
 				ps.thread = !ps.thread;
 				new_message(MT_standout | MT_delayed,
-				    "Displaying threads %s",
+				    " Displaying threads %s",
 				    ps.thread ? "separately" : "as a count");
 				header_text = format_header(uname_field);
 				reset_display();
@@ -1028,7 +1029,7 @@ restart:
 			    case CMD_wcputog:
 				ps.wcpu = !ps.wcpu;
 				new_message(MT_standout | MT_delayed,
-				    "Displaying %sCPU",
+				    " Displaying %sCPU",
 				    ps.wcpu ? "W" : "");
 				header_text = format_header(uname_field);
 				reset_display();



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jhb 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Sun Jul 10 19:12:11 UTC 2011 
Responsible-Changed-Why:  
Hi John, 

could you take a look at this PR? 

Cheers. 
Alex 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158775 
State-Changed-From-To: open->patched 
State-Changed-By: jhb 
State-Changed-When: Mon Jul 11 16:51:40 UTC 2011 
State-Changed-Why:  
Fix committed to HEAD. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158775 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/158775: commit references a PR
Date: Mon, 11 Jul 2011 16:51:43 +0000 (UTC)

 Author: jhb
 Date: Mon Jul 11 16:51:29 2011
 New Revision: 223937
 URL: http://svn.freebsd.org/changeset/base/223937
 
 Log:
   Add a leading space to the status messages output after toggling the
   'C' and 'H' flags at runtime.  This matches messages output for other
   toggles which leave the first column in the message blank to hold the
   cursor.
   
   PR:		bin/158775
   Submitted by:	arundel
   MFC after:	3 days
 
 Modified:
   head/contrib/top/top.c
 
 Modified: head/contrib/top/top.c
 ==============================================================================
 --- head/contrib/top/top.c	Mon Jul 11 16:48:52 2011	(r223936)
 +++ head/contrib/top/top.c	Mon Jul 11 16:51:29 2011	(r223937)
 @@ -1020,7 +1020,7 @@ restart:
  			    case CMD_thrtog:
  				ps.thread = !ps.thread;
  				new_message(MT_standout | MT_delayed,
 -				    "Displaying threads %s",
 +				    " Displaying threads %s",
  				    ps.thread ? "separately" : "as a count");
  				header_text = format_header(uname_field);
  				reset_display();
 @@ -1029,7 +1029,7 @@ restart:
  			    case CMD_wcputog:
  				ps.wcpu = !ps.wcpu;
  				new_message(MT_standout | MT_delayed,
 -				    "Displaying %sCPU",
 +				    " Displaying %sCPU",
  				    ps.wcpu ? "W" : "");
  				header_text = format_header(uname_field);
  				reset_display();
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jhb 
State-Changed-When: Mon Mar 4 18:56:35 UTC 2013 
State-Changed-Why:  
Merged to 8 a while ago. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158775 
>Unformatted:
