From d4798798bee7599d4028da1e99ad00d84a39e770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Diego=20Aur=C3=A9lio=20Mesquita?= Date: Sat, 2 Sep 2017 23:32:14 -0300 Subject: [PATCH] Enalbe history for command execution prompt. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marco Diego Aurélio Mesquita --- src/files.c | 3 ++- src/global.c | 10 ++++++++-- src/proto.h | 3 +++ src/search.c | 13 +++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/files.c b/src/files.c index 6a6bb1ca..a10b6783 100644 --- a/src/files.c +++ b/src/files.c @@ -1077,7 +1077,7 @@ void do_insertfile(void) #endif MINSERTFILE, given, #ifndef DISABLE_HISTORIES - NULL, + execute ? &execute_history : NULL, #endif edit_refresh, msg, #ifndef DISABLE_OPERATINGDIR @@ -1140,6 +1140,7 @@ void do_insertfile(void) #endif /* Save the command's output in the current buffer. */ execute_command(answer); + update_history(&execute_history, answer); #ifdef ENABLE_MULTIBUFFER /* If this is a new buffer, put the cursor at the top. */ diff --git a/src/global.c b/src/global.c index e2017115..dd27c726 100644 --- a/src/global.c +++ b/src/global.c @@ -205,6 +205,12 @@ filestruct *searchage = NULL; /* The top of the search string history list. */ filestruct *searchbot = NULL; /* The bottom of the search string history list. */ +filestruct *execute_history = NULL; + /* The search string history list. */ +filestruct *executeage = NULL; + /* The top of the search string history list. */ +filestruct *executebot = NULL; + /* The bottom of the search string history list. */ filestruct *replace_history = NULL; /* The replace string history list. */ filestruct *replaceage = NULL; @@ -1265,8 +1271,8 @@ void shortcut_init(void) add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^N", 0, get_history_newer_void, 0); #ifdef ENABLE_UTF8 if (using_utf8()) { - add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0); - add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0); + add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0); + add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0); } else #endif { diff --git a/src/proto.h b/src/proto.h index 8ee4eb0e..7cf7cd55 100644 --- a/src/proto.h +++ b/src/proto.h @@ -159,6 +159,9 @@ extern subnfunc *uncutfunc; extern filestruct *search_history; extern filestruct *searchage; extern filestruct *searchbot; +extern filestruct *execute_history; +extern filestruct *executeage; +extern filestruct *executebot; extern filestruct *replace_history; extern filestruct *replaceage; extern filestruct *replacebot; diff --git a/src/search.c b/src/search.c index 92d90223..c2aa46db 100644 --- a/src/search.c +++ b/src/search.c @@ -1103,6 +1103,11 @@ void history_init(void) searchage = search_history; searchbot = search_history; + execute_history = make_new_node(NULL); + execute_history->data = mallocstrcpy(NULL, ""); + executeage = execute_history; + executebot = execute_history; + replace_history = make_new_node(NULL); replace_history->data = mallocstrcpy(NULL, ""); replaceage = replace_history; @@ -1114,6 +1119,8 @@ void history_reset(const filestruct *h) { if (h == search_history) search_history = searchbot; + else if (h == execute_history) + execute_history = executebot; else if (h == replace_history) replace_history = replacebot; } @@ -1145,6 +1152,9 @@ void update_history(filestruct **h, const char *s) if (*h == search_history) { hage = &searchage; hbot = &searchbot; + } else if (*h == execute_history) { + hage = &executeage; + hbot = &executebot; } else if (*h == replace_history) { hage = &replaceage; hbot = &replacebot; @@ -1245,6 +1255,9 @@ char *get_history_completion(filestruct **h, char *s, size_t len) if (*h == search_history) { hage = searchage; hbot = searchbot; + } else if (*h == execute_history) { + hage = executeage; + hbot = executebot; } else if (*h == replace_history) { hage = replaceage; hbot = replacebot; -- 2.11.0