history: remember the commands that were executed during this session
Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>master
parent
4aec1649f5
commit
c8363a0d0b
|
@ -1081,7 +1081,7 @@ void do_insertfile(void)
|
|||
#endif
|
||||
MINSERTFILE, given,
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
execute ? &execute_history : NULL,
|
||||
#endif
|
||||
edit_refresh, msg,
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
|
@ -1144,6 +1144,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. */
|
||||
|
|
18
src/global.c
18
src/global.c
|
@ -216,6 +216,12 @@ filestruct *replaceage = NULL;
|
|||
/* The top of the replace string history list. */
|
||||
filestruct *replacebot = NULL;
|
||||
/* The bottom of the replace string history list. */
|
||||
filestruct *execute_history = NULL;
|
||||
/* The list of commands that have been run with ^R ^X. */
|
||||
filestruct *executetop = NULL;
|
||||
/* The top of the execute history list. */
|
||||
filestruct *executebot = NULL;
|
||||
/* The bottom of the execute history list. */
|
||||
poshiststruct *position_history = NULL;
|
||||
/* The cursor position history list. */
|
||||
#endif
|
||||
|
@ -1266,17 +1272,17 @@ void shortcut_init(void)
|
|||
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^P", 0, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^N", 0, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^P", 0, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^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
|
||||
{
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Up", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "Up", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "Down", KEY_DOWN, get_history_newer_void, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_BROWSER
|
||||
|
|
|
@ -165,6 +165,9 @@ extern filestruct *searchbot;
|
|||
extern filestruct *replace_history;
|
||||
extern filestruct *replaceage;
|
||||
extern filestruct *replacebot;
|
||||
extern filestruct *execute_history;
|
||||
extern filestruct *executetop;
|
||||
extern filestruct *executebot;
|
||||
extern poshiststruct *position_history;
|
||||
#endif
|
||||
|
||||
|
|
13
src/search.c
13
src/search.c
|
@ -1107,6 +1107,11 @@ void history_init(void)
|
|||
replace_history->data = mallocstrcpy(NULL, "");
|
||||
replaceage = replace_history;
|
||||
replacebot = replace_history;
|
||||
|
||||
execute_history = make_new_node(NULL);
|
||||
execute_history->data = mallocstrcpy(NULL, "");
|
||||
executetop = execute_history;
|
||||
executebot = execute_history;
|
||||
}
|
||||
|
||||
/* Set the current position in the history list h to the bottom. */
|
||||
|
@ -1116,6 +1121,8 @@ void history_reset(const filestruct *h)
|
|||
search_history = searchbot;
|
||||
else if (h == replace_history)
|
||||
replace_history = replacebot;
|
||||
else if (h == execute_history)
|
||||
execute_history = executebot;
|
||||
}
|
||||
|
||||
/* Return the first node containing the first len characters of the
|
||||
|
@ -1148,6 +1155,9 @@ void update_history(filestruct **h, const char *s)
|
|||
} else if (*h == replace_history) {
|
||||
hage = &replaceage;
|
||||
hbot = &replacebot;
|
||||
} else if (*h == execute_history) {
|
||||
hage = &executetop;
|
||||
hbot = &executebot;
|
||||
}
|
||||
|
||||
assert(hage != NULL && hbot != NULL);
|
||||
|
@ -1248,6 +1258,9 @@ char *get_history_completion(filestruct **h, char *s, size_t len)
|
|||
} else if (*h == replace_history) {
|
||||
hage = replaceage;
|
||||
hbot = replacebot;
|
||||
} else if (*h == execute_history) {
|
||||
hage = executetop;
|
||||
hbot = executebot;
|
||||
}
|
||||
|
||||
assert(hage != NULL && hbot != NULL);
|
||||
|
|
Loading…
Reference in New Issue