From c8cfcadfdae0430e1c30465a0eff11ed3c1271c8 Mon Sep 17 00:00:00 2001
From: Francesco Cosoleto <cosoleto@gmail.com>
Date: Thu, 28 Apr 2011 04:12:36 +0200
Subject: [PATCH] Save input line content in history only if has changed
It's possible users reuse the same content of a dialog or just
enable/disable some options available, then saving the history is
pointless.
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
lib/widget/input.c | 11 ++++++++++-
lib/widget/input.h | 1 +
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/widget/input.c b/lib/widget/input.c
index e7f33b1..8a432a3 100644
a
|
b
|
push_history (WInput * in, const char *text) |
224 | 224 | strip_password (t, i >= ELEMENTS); |
225 | 225 | } |
226 | 226 | |
| 227 | if (in->history && in->history->data) |
| 228 | if (!strcmp(in->history->data, t)) |
| 229 | return; |
| 230 | |
227 | 231 | in->history = list_append_unique (in->history, t); |
| 232 | in->history_changed = TRUE; |
228 | 233 | in->need_push = FALSE; |
229 | 234 | } |
230 | 235 | |
… |
… |
input_destroy (WInput * in) |
771 | 776 | |
772 | 777 | if (in->history != NULL) |
773 | 778 | { |
774 | | if (!in->is_password && (((Widget *) in)->owner->ret_value != B_CANCEL)) |
| 779 | if (in->history_changed && !in->is_password && (((Widget *) in)->owner->ret_value != B_CANCEL)) |
| 780 | { |
775 | 781 | history_put (in->history_name, in->history); |
| 782 | in->history_changed = FALSE; |
| 783 | } |
776 | 784 | |
777 | 785 | in->history = g_list_first (in->history); |
778 | 786 | g_list_foreach (in->history, (GFunc) g_free, NULL); |
… |
… |
input_new (int y, int x, const int *input_colors, int width, const char *def_tex |
884 | 892 | in->disable_update = 0; |
885 | 893 | in->mark = 0; |
886 | 894 | in->need_push = TRUE; |
| 895 | in->history_changed = FALSE; |
887 | 896 | in->is_password = FALSE; |
888 | 897 | |
889 | 898 | strcpy (in->buffer, def_text); |
diff --git a/lib/widget/input.h b/lib/widget/input.h
index 25b6c22..11d371f 100644
a
|
b
|
typedef struct |
58 | 58 | gboolean is_password; /* is this a password input line? */ |
59 | 59 | char *buffer; /* pointer to editing buffer */ |
60 | 60 | GList *history; /* the history */ |
| 61 | int history_changed; /* if the history has changed */ |
61 | 62 | gboolean need_push; /* need to push the current Input on hist? */ |
62 | 63 | char **completions; /* possible completions array */ |
63 | 64 | input_complete_t completion_flags; |