From d994ad5284f39926afa413bedbf45de29493b3b1 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 23 Nov 2004 21:40:26 +0000
Subject: [PATCH] in get_edit_input(), readd parameter allow_funcs, as it's now
 needed as a workaround for when unjustified text is stored in the justify
 buffer and either the justify or the full justify shortcut is hit

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2128 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   |  6 ------
 src/nano.c  |  6 ++++--
 src/proto.h |  2 +-
 src/winio.c | 17 ++++++++++-------
 4 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cb0044c1..d2fcef3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,12 +36,6 @@ CVS code -
   do_justify()
 	- For consistency, preserve placewewant if we didn't unjustify
 	  instead of setting it to 0. (DLR)
-- winio.c:
-  get_edit_input()
-	- Remove parameter allow_funcs, as it was only needed as a
-	  workaround for when justified text was stored in the cutbuffer
-	  and the cut shortcut was hit at the "Can now UnJustify!"
-	  prompt. (DLR)
 
 GNU nano 1.3.5 - 2004.11.22
 - General:
diff --git a/src/nano.c b/src/nano.c
index c1ab42d3..ca262703 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -3038,7 +3038,7 @@ void do_justify(bool full_justify)
 
     /* Now get a keystroke and see if it's unjustify; if not, unget the
      * keystroke and return. */
-    kbinput = get_edit_input(&meta_key, &func_key);
+    kbinput = get_edit_input(&meta_key, &func_key, FALSE);
 
     if (!meta_key && !func_key && kbinput == NANO_UNJUSTIFY_KEY) {
 	/* Restore the justify we just did (ungrateful user!). */
@@ -3092,6 +3092,8 @@ void do_justify(bool full_justify)
 	    edit_refresh();
 	}
     } else {
+	unget_kbinput(kbinput, meta_key, func_key);
+
 	/* Blow away the text in the justify buffer.*/
 	free_filestruct(jusbuffer);
 	jusbuffer = NULL;
@@ -3955,7 +3957,7 @@ int main(int argc, char **argv)
 	currshortcut = main_list;
 #endif
 
-	kbinput = get_edit_input(&meta_key, &func_key);
+	kbinput = get_edit_input(&meta_key, &func_key, TRUE);
 
 	/* Last gasp, stuff that's not in the main lists. */
 	if (kbinput != ERR && !is_cntrl_char(kbinput)) {
diff --git a/src/proto.h b/src/proto.h
index 4065da18..9481df1d 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -555,7 +555,7 @@ const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool
 #ifndef NANO_SMALL
 const toggle *get_toggle(int kbinput, bool meta_key);
 #endif
-int get_edit_input(bool *meta_key, bool *func_key);
+int get_edit_input(bool *meta_key, bool *func_key, bool allow_funcs);
 #ifndef DISABLE_MOUSE
 bool get_edit_mouse(void);
 #endif
diff --git a/src/winio.c b/src/winio.c
index 47b636f6..7c8be144 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1491,7 +1491,7 @@ const toggle *get_toggle(int kbinput, bool meta_key)
 }
 #endif /* !NANO_SMALL */
 
-int get_edit_input(bool *meta_key, bool *func_key)
+int get_edit_input(bool *meta_key, bool *func_key, bool allow_funcs)
 {
     bool keyhandled = FALSE;
     int kbinput, retval;
@@ -1536,10 +1536,12 @@ int get_edit_input(bool *meta_key, bool *func_key)
 	if (s->func != do_cut_text)
 	    cutbuffer_reset();
 	if (s->func != NULL) {
-	    if (ISSET(VIEW_MODE) && !s->viewok)
-		print_view_warning();
-	    else
-		s->func();
+	    if (allow_funcs) {
+		if (ISSET(VIEW_MODE) && !s->viewok)
+		    print_view_warning();
+		else
+		    s->func();
+	    }
 	    keyhandled = TRUE;
 	}
     }
@@ -1553,7 +1555,8 @@ int get_edit_input(bool *meta_key, bool *func_key)
 	 * corresponding flag. */
 	if (t != NULL) {
 	    cutbuffer_reset();
-	    do_toggle(t);
+	    if (allow_funcs)
+		do_toggle(t);
 	    keyhandled = TRUE;
 	}
     }
@@ -1562,7 +1565,7 @@ int get_edit_input(bool *meta_key, bool *func_key)
     /* If we got a shortcut with a corresponding function or a toggle,
      * reset meta_key and retval.  If we didn't, keep the value of
      * meta_key and return the key we got in retval. */
-    if (keyhandled) {
+    if (allow_funcs && keyhandled) {
 	*meta_key = FALSE;
 	retval = ERR;
     } else {
-- 
GitLab