From 4fd74e0db4fb9db6f7d46bd1681a53c5d50cc3b2 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Sun, 23 Apr 2006 01:10:55 +0000
Subject: [PATCH] in help_init(), if we have at least two entries' worth of
 blank space, use it to display more of "^Space" and "M-Space"

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3414 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog  |  4 ++++
 src/help.c | 23 +++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 94ac1f52..b5dff26a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -102,6 +102,10 @@ CVS code -
 	- Call get_shortcut() after getting input, so that we only have
 	  to check for a main shortcut key instead of both it and all of
 	  its equivalents. (DLR)
+  help_init()
+	- If we have at least two entries' worth of blank space, use it
+	  to display more of "^Space" and "M-Space". (DLR, suggested by
+	  Benno Schulenberg)
 - nano.c:
   renumber()
 	- Remove invalid assert. (DLR, found by Filipe Moreira)
diff --git a/src/help.c b/src/help.c
index 9d12c7b5..0ec01e39 100644
--- a/src/help.c
+++ b/src/help.c
@@ -414,9 +414,22 @@ void help_init(void)
 	    /* Yucky sentinel values that we can't handle a better
 	     * way. */
 	    if (s->ctrlval == NANO_CONTROL_SPACE) {
-		char *space_ptr = display_string(_("Space"), 0, 6,
+		char *space_ptr = display_string(_("Space"), 0, 13,
 			FALSE);
 
+		if (s->funcval == NANO_NO_KEY && (s->metaval ==
+			NANO_NO_KEY || s->miscval == NANO_NO_KEY)) {
+		    /* If we're here, we have at least two entries worth
+		     * of blank space.  If this entry takes up more than
+		     * one entry's worth of space, use two to display
+		     * it. */
+		    if (strlen(space_ptr) + 1 > 7)
+			entries++;
+		} else
+		    /* Otherwise, truncate it so that it takes up only
+		     * one entry's worth of space. */
+		    space_ptr[7] = '\0';
+
 		ptr += sprintf(ptr, "^%s", space_ptr);
 
 		free(space_ptr);
@@ -452,9 +465,15 @@ void help_init(void)
 	    /* Yucky sentinel values that we can't handle a better
 	     * way. */
 	    if (s->metaval == NANO_ALT_SPACE && entries == 1) {
-		char *space_ptr = display_string(_("Space"), 0, 5,
+		char *space_ptr = display_string(_("Space"), 0, 13,
 			FALSE);
 
+		/* If we're here, we have at least two entries worth of
+		 * blank space.  If this entry takes up more than one
+		 * entry's worth of space, use two to display it. */
+		if (strlen(space_ptr) + 2 > 7)
+		    entries++;
+
 		ptr += sprintf(ptr, "M-%s", space_ptr);
 
 		free(space_ptr);
-- 
GitLab