summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2013-02-24 20:33:05 +0100
committerDaniel Carl <danielcarl@gmx.de>2013-02-24 20:33:05 +0100
commitc8ef33bfcac14ea71bc550877b745ea4966d4b76 (patch)
treedf732e957ad6f64719f6820dcbdb5c556efb08b1
parent880612a9dc867edd0cabb71086a42cec46963894 (diff)
Save the commands together with the prefix ':' in history (#7).
This is not so flexible, but makes many tings easier to implement to violate the concerns of the components.
-rw-r--r--doc/vimp.1.txt9
-rw-r--r--src/command.c9
-rw-r--r--src/history.c5
-rw-r--r--src/main.c8
4 files changed, 11 insertions, 20 deletions
diff --git a/doc/vimp.1.txt b/doc/vimp.1.txt
index 0454140..1c0a4c6 100644
--- a/doc/vimp.1.txt
+++ b/doc/vimp.1.txt
@@ -283,12 +283,9 @@ Zoom \fIN\fP steps in or out of the current page \- effecting all elements.
Reset the zoomlevel to the default value.
.SS Command-History
.TP
-.BI [ N "]command-hist-prev [" PREFIX "], [" N "]command-hist-next [" PREFIX ]
-Prints the previous or next cammand from history into inputbox. If \fIPREFIX\fP
-is given, this will be used as prefix for the inserted command, else the
-default ':' will be used.
-If there is already text in the input box this will be used to get previous
-history items.
+.BI [ N "]command-hist-prev, [" N "]command-hist-next"
+Prints the previous or next cammand from history into inputbox. If there is
+already text in the input box this will be used to get history items.
.SS Misc
.TP
.BI [ N "]search-forward, [" N "]search-backward"
diff --git a/src/command.c b/src/command.c
index 3a96bdb..22ae839 100644
--- a/src/command.c
+++ b/src/command.c
@@ -88,8 +88,8 @@ static CommandInfo cmd_list[] = {
{"zoominfull", command_zoom, {COMMAND_ZOOM_IN | COMMAND_ZOOM_FULL}},
{"zoomoutfull", command_zoom, {COMMAND_ZOOM_OUT | COMMAND_ZOOM_FULL}},
{"zoomreset", command_zoom, {COMMAND_ZOOM_RESET}},
- {"command-hist-next", command_history, {VP_SEARCH_FORWARD, ":"}},
- {"command-hist-prev", command_history, {VP_SEARCH_BACKWARD, ":"}},
+ {"command-hist-next", command_history, {VP_SEARCH_FORWARD}},
+ {"command-hist-prev", command_history, {VP_SEARCH_BACKWARD}},
};
static void command_write_input(const char* str);
@@ -530,7 +530,6 @@ gboolean command_zoom(const Arg* arg)
gboolean command_history(const Arg* arg)
{
- char* msg = NULL;
const int count = vp.state.count ? vp.state.count : 1;
const gint step = count * (arg->i == VP_SEARCH_BACKWARD ? -1 : 1);
const char* entry = history_get(step);
@@ -538,9 +537,7 @@ gboolean command_history(const Arg* arg)
if (!entry) {
return FALSE;
}
- msg = g_strconcat(arg->s, entry, NULL);
- command_write_input(msg);
- g_free(msg);
+ command_write_input(entry);
return TRUE;
}
diff --git a/src/history.c b/src/history.c
index 0b0c087..5bb53d5 100644
--- a/src/history.c
+++ b/src/history.c
@@ -43,10 +43,7 @@ const char* history_get(const int step)
/* get the search prefix only on start of history search */
if (!vp.state.history_prefix) {
- const char* text = GET_TEXT();
- /* TODO at the moment we skip only the first char of input box but
- * maybe we'll have history items that have a longer or no prefix */
- OVERWRITE_STRING(vp.state.history_prefix, (text + 1));
+ OVERWRITE_STRING(vp.state.history_prefix, GET_TEXT());
}
for (GList* l = core.behave.history; l; l = l->next) {
diff --git a/src/main.c b/src/main.c
index 7001611..7d8f5c8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -171,22 +171,22 @@ static void vp_inputbox_activate_cb(GtkEntry *entry, gpointer user_data)
/* duplicate the content because this may change for example if
* :set varName? is used the text is changed to the new printed
* content of inputbox */
- command = g_strdup((text + 1));
+ command = g_strdup((text));
switch (*text) {
case '/':
case '?':
{
- Arg a = {*text == '/' ? VP_SEARCH_FORWARD : VP_SEARCH_BACKWARD, command};
+ Arg a = {*text == '/' ? VP_SEARCH_FORWARD : VP_SEARCH_BACKWARD, (command + 1)};
command_search(&a);
}
break;
case ':':
completion_clean();
- vp_process_input(command);
+ vp_process_input((command + 1));
- /* save the command in history */
+ /* save the command together with the first char in history */
history_append(command);
break;