|
@@ -83,6 +83,19 @@ static char *kill_buffer = NULL;
|
|
|
/*** file scope functions ************************************************************************/
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
+static size_t
|
|
|
+get_history_length (const GList *history)
|
|
|
+{
|
|
|
+ size_t len = 0;
|
|
|
+
|
|
|
+ for (; history != NULL; history = g_list_previous (history))
|
|
|
+ len++;
|
|
|
+
|
|
|
+ return len;
|
|
|
+}
|
|
|
+
|
|
|
+/* --------------------------------------------------------------------------------------------- */
|
|
|
+
|
|
|
static void
|
|
|
draw_history_button (WInput * in)
|
|
|
{
|
|
@@ -170,14 +183,21 @@ delete_region (WInput * in, int x_first, int x_last)
|
|
|
static void
|
|
|
do_show_hist (WInput * in)
|
|
|
{
|
|
|
+ size_t len;
|
|
|
char *r;
|
|
|
|
|
|
+ len = get_history_length (in->history);
|
|
|
+
|
|
|
r = history_show (&in->history, &in->widget);
|
|
|
if (r != NULL)
|
|
|
{
|
|
|
input_assign_text (in, r);
|
|
|
g_free (r);
|
|
|
}
|
|
|
+
|
|
|
+ /* Has history cleaned up or not? */
|
|
|
+ if (len != get_history_length (in->history))
|
|
|
+ in->history_changed = TRUE;
|
|
|
}
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
@@ -224,7 +244,13 @@ push_history (WInput * in, const char *text)
|
|
|
strip_password (t, i >= ELEMENTS);
|
|
|
}
|
|
|
|
|
|
- in->history = list_append_unique (in->history, t);
|
|
|
+ if (in->history == NULL || in->history->data == NULL || strcmp (in->history->data, t) != 0 ||
|
|
|
+ in->history_changed)
|
|
|
+ {
|
|
|
+ in->history = list_append_unique (in->history, t);
|
|
|
+ in->history_changed = TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
in->need_push = FALSE;
|
|
|
}
|
|
|
|
|
@@ -584,6 +610,7 @@ hist_prev (WInput * in)
|
|
|
if (prev != NULL)
|
|
|
{
|
|
|
in->history = prev;
|
|
|
+ in->history_changed = TRUE;
|
|
|
input_assign_text (in, (char *) prev->data);
|
|
|
in->need_push = FALSE;
|
|
|
}
|
|
@@ -612,6 +639,7 @@ hist_next (WInput * in)
|
|
|
else
|
|
|
{
|
|
|
in->history = next;
|
|
|
+ in->history_changed = TRUE;
|
|
|
input_assign_text (in, (char *) next->data);
|
|
|
in->need_push = FALSE;
|
|
|
}
|
|
@@ -814,13 +842,14 @@ input_save_history (const gchar * event_group_name, const gchar * event_name,
|
|
|
(void) event_group_name;
|
|
|
(void) event_name;
|
|
|
|
|
|
- if (in->history != NULL && !in->is_password && (((Widget *) in)->owner->ret_value != B_CANCEL))
|
|
|
+ if (in->history != NULL && in->history_changed && !in->is_password &&
|
|
|
+ (((Widget *) in)->owner->ret_value != B_CANCEL))
|
|
|
{
|
|
|
ev_history_load_save_t *ev = (ev_history_load_save_t *) data;
|
|
|
|
|
|
- if (in->need_push)
|
|
|
- push_history (in, in->buffer);
|
|
|
+ push_history (in, in->buffer);
|
|
|
history_save (ev->cfg, in->history_name, in->history);
|
|
|
+ in->history_changed = FALSE;
|
|
|
}
|
|
|
|
|
|
return TRUE;
|
|
@@ -942,8 +971,9 @@ input_new (int y, int x, const int *input_colors, int width, const char *def_tex
|
|
|
in->completion_flags = completion_flags;
|
|
|
|
|
|
/* prepare to history setup */
|
|
|
- in->history_name = NULL;
|
|
|
in->history = NULL;
|
|
|
+ in->history_changed = FALSE;
|
|
|
+ in->history_name = NULL;
|
|
|
if ((histname != NULL) && (*histname != '\0'))
|
|
|
in->history_name = g_strdup (histname);
|
|
|
|
|
@@ -1276,12 +1306,15 @@ input_disable_update (WInput * in)
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
-/* Cleans the input line and adds the current text to the history */
|
|
|
+/**
|
|
|
+ * Cleans the input line and adds the current text to the history
|
|
|
+ *
|
|
|
+ * @param in the input line
|
|
|
+ */
|
|
|
void
|
|
|
input_clean (WInput * in)
|
|
|
{
|
|
|
- if (in->need_push)
|
|
|
- push_history (in, in->buffer);
|
|
|
+ push_history (in, in->buffer);
|
|
|
in->need_push = TRUE;
|
|
|
in->buffer[0] = '\0';
|
|
|
in->point = 0;
|