From 960ff2f3bf7677e3b25db1605e53bcfd7e8b6ffd Mon Sep 17 00:00:00 2001 From: rexy712 Date: Sat, 1 Apr 2023 13:11:17 -0700 Subject: [PATCH] Patch 06 --- configure.ac | 14 ++++++++++++++ src/Makefile.am | 1 + src/global.c | 17 +++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b08dade5..ceb16a0f 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,20 @@ if test "x$enable_color" != xno; then color_support=yes fi +AC_ARG_ENABLE(folding, +AS_HELP_STRING([--disable-folding], [Disable line folding support])) +if test "x$enable_tiny" = xyes; then + if test "x$enable_folding" = xyes; then + AC_MSG_ERROR([ + *** --enable-folding cannot work with --enable-tiny]) + else + enable_folding=no + fi +fi +if test "x$enable_folding" != xno; then + AC_DEFINE(ENABLE_FOLDING, 1, [Define this to have line folding support.]) +fi + AC_ARG_ENABLE(comment, AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function])) if test "x$enable_tiny" = xyes; then diff --git a/src/Makefile.am b/src/Makefile.am index cd019daf..48d1ef30 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ nano_SOURCES = \ color.c \ cut.c \ files.c \ + folding.c \ global.c \ help.c \ history.c \ diff --git a/src/global.c b/src/global.c index ed93fa31..e7217a02 100644 --- a/src/global.c +++ b/src/global.c @@ -642,6 +642,9 @@ void shortcut_init(void) const char *savefile_gist = N_("Save file without prompting"); const char *findprev_gist = N_("Search next occurrence backward"); const char *findnext_gist = N_("Search next occurrence forward"); +#ifdef ENABLE_FOLDING + const char *fold_gist = N_("Fold/unfold the currently selected lines"); +#endif #ifndef NANO_TINY const char *recordmacro_gist = N_("Start/stop recording a macro"); const char *runmacro_gist = N_("Run the last recorded macro"); @@ -998,7 +1001,14 @@ void shortcut_init(void) N_("Record"), WHENHELP(recordmacro_gist), TOGETHER); add_to_funcs(run_macro, MMAIN, N_("Run Macro"), WHENHELP(runmacro_gist), BLANKAFTER); +#endif +#ifdef ENABLE_FOLDING + add_to_funcs(do_fold_segment, MMAIN, N_("Fold"), + WHENHELP(fold_gist), BLANKAFTER); +#endif + +#ifndef NANO_TINY add_to_funcs(zap_text, MMAIN, /* TRANSLATORS: This refers to deleting a line or marked region. */ N_("Zap"), WHENHELP(zap_gist), BLANKAFTER); @@ -1208,6 +1218,9 @@ void shortcut_init(void) #ifdef ENABLE_FORMATTER add_to_sclist(MMAIN, "M-F", 0, do_formatter, 0); add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0); +#endif +#ifdef ENABLE_FOLDING + add_to_sclist(MMAIN, "M-[", 0, do_fold_segment, 0); #endif add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0); add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn, 0); @@ -1341,10 +1354,10 @@ void shortcut_init(void) add_to_sclist(MMAIN|MHELP, "M-=", 0, do_scroll_down, 0); #endif #ifdef ENABLE_MULTIBUFFER - add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer, 0); add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer, 0); - add_to_sclist(MMAIN, "M-.", 0, switch_to_next_buffer, 0); + add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer, 0); add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer, 0); + add_to_sclist(MMAIN, "M-.", 0, switch_to_next_buffer, 0); #endif add_to_sclist(MMOST, "M-V", 0, do_verbatim_input, 0); #ifndef NANO_TINY