diff options
author | Bernhard R. Link <brlink@debian.org> | 2008-06-10 14:24:05 +0200 |
---|---|---|
committer | Shawn <sabetts@juicebox.(none)> | 2008-10-22 14:18:41 -0700 |
commit | d11f0735321bc725441fbc1dec04e363d07c987a (patch) | |
tree | fa0e3a3383e92ced6d719b52952fa0bb591e0232 /src/history.c | |
parent | d801644502adf42570e9a5b75fcaa013f613fc5a (diff) | |
download | ratpoison-d11f0735321bc725441fbc1dec04e363d07c987a.zip |
SHELLCMD history only shows execute arguments, things to execute are stored as in history as execute commands
Diffstat (limited to 'src/history.c')
-rw-r--r-- | src/history.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/history.c b/src/history.c index 28292f6..4178cf9 100644 --- a/src/history.c +++ b/src/history.c @@ -86,7 +86,7 @@ history_add (int history_id, char *item) { HIST_ENTRY *h; - if (history_id == hist_NONE) + if (history_id == hist_NONE || history_id == hist_SHELLCMD) return; h = history_get (history_length); @@ -98,16 +98,39 @@ history_add (int history_id, char *item) add_history (item); } +static const char * +extract_shell_part (const char *p) +{ + if (strncmp(p, "exec", 4) && + strncmp(p, "verbexec", 8)) + return NULL; + while( *p && !isspace(*p) ) + p++; + while( *p && isspace(*p) ) + p++; + if (*p) + return p; + return NULL; +} + const char * history_previous (int history_id) { HIST_ENTRY *h = NULL; + const char *p; if (history_id == hist_NONE) return NULL; h = previous_history(); + if (history_id == hist_SHELLCMD) { + p = NULL; + while( h && h->line && !(p = extract_shell_part(h->line))) + h = previous_history(); + return p; + } + return h ? h->line : NULL; } @@ -115,12 +138,19 @@ const char * history_next (int history_id) { HIST_ENTRY *h = NULL; + const char *p; if (history_id == hist_NONE) return NULL; h = next_history(); + if (history_id == hist_SHELLCMD) { + p = NULL; + while( h && h->line && !(p = extract_shell_part(h->line))) + h = next_history(); + return p; + } return h ? h->line : NULL; } |