summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/command.c16
-rw-r--r--src/command.h1
-rw-r--r--src/ex.c22
3 files changed, 19 insertions, 20 deletions
diff --git a/src/command.c b/src/command.c
index 9089f38..958251c 100644
--- a/src/command.c
+++ b/src/command.c
@@ -80,22 +80,6 @@ gboolean command_search(const Arg *arg)
return true;
}
-gboolean command_history(const Arg *arg)
-{
- char *input = vb_get_input_text();
- char *entry = history_get(input, arg->i);
- g_free(input);
-
- if (!entry) {
- return false;
- }
-
- vb_echo_force(VB_MSG_NORMAL, false, "%s", entry);
- g_free(entry);
-
- return true;
-}
-
gboolean command_yank(const Arg *arg)
{
static char *tmpl = "Yanked: %s";
diff --git a/src/command.h b/src/command.h
index 185ed1c..604583d 100644
--- a/src/command.h
+++ b/src/command.h
@@ -41,7 +41,6 @@ enum {
#endif
gboolean command_search(const Arg *arg);
-gboolean command_history(const Arg *arg);
gboolean command_yank(const Arg *arg);
gboolean command_save(const Arg *arg);
#ifdef FEATURE_QUEUE
diff --git a/src/ex.c b/src/ex.c
index c207533..212186e 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -112,6 +112,7 @@ static gboolean ex_shortcut(const ExArg *arg);
static gboolean ex_complete(short direction);
static void ex_completion_select(char *match);
+static gboolean ex_history(short direction);
/* The order of following command names is significant. If there exists
* ambiguous commands matching to the users input, the first defined will be
@@ -226,12 +227,11 @@ VbResult ex_keypress(unsigned int key)
break;
case CTRL('P'): /* up */
- /* TODO don't emit input change event when stepping though history in search mode */
- command_history(&((Arg){1}));
+ ex_history(-1);
break;
case CTRL('N'): /* down */
- command_history(&((Arg){0}));
+ ex_history(1);
break;
/* basic command line editing */
@@ -969,3 +969,19 @@ static void ex_completion_select(char *match)
}
vb_set_input_text(excomp.current);
}
+
+static gboolean ex_history(short direction)
+{
+ char *input = vb_get_input_text();
+ char *entry = history_get(input, direction < 0);
+ g_free(input);
+
+ if (entry) {
+ vb_set_input_text(entry);
+ g_free(entry);
+
+ return true;
+ }
+
+ return false;
+}