From 3af22aad8deb0ef1e5fa0754663a6eb59bc09d2b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 13 Jun 2014 12:28:33 +0000 Subject: [PATCH] Letting a toggle not break a series of ^Ks. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4962 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 1 + src/nano.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3caf368..783e868d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ (result == 0) should break a series of ^Ks. * src/nano.c (do_mouse): Clicking on the titlebar or the statusbar should not break a series of ^Ks, thus result must not be zero. + * src/nano.c (do_input): A toggle should not break a series of ^Ks. 2014-06-11 Benno Schulenberg * src/winio.c (get_mouseinput): Produce the correct return value for diff --git a/src/nano.c b/src/nano.c index 11948b70..9c0f00d2 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1577,8 +1577,8 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs) /* The input buffer. */ static size_t kbinput_len = 0; /* The length of the input buffer. */ - bool cut_copy = FALSE; - /* Are we cutting or copying text? */ + bool preserve = FALSE; + /* Preserve the contents of the cutbuffer? */ const sc *s; bool have_shortcut; @@ -1678,7 +1678,7 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs) || s->scfunc == do_copy_text || s->scfunc == do_cut_till_end #endif ) - cut_copy = TRUE; + preserve = TRUE; if (s->scfunc != 0) { const subnfunc *f = sctofunc((sc *) s); @@ -1686,9 +1686,10 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs) print_view_warning(); else { #ifndef NANO_TINY - if (s->scfunc == do_toggle_void) + if (s->scfunc == do_toggle_void) { do_toggle(s->toggle); - else + preserve = TRUE; + } else #endif { /* Execute the function of the shortcut. */ @@ -1711,9 +1712,9 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs) } } - /* If we aren't cutting or copying text, blow away the text in the - * cutbuffer upon the next cutting action. */ - if (!cut_copy) + /* If we aren't cutting or copying text, and the key wasn't a toggle, + * blow away the text in the cutbuffer upon the next cutting action. */ + if (!preserve) cutbuffer_reset(); return input;