Ticket #2545: 0001-Save-input-line-content-in-history-only-if-has-chang.patch

File 0001-Save-input-line-content-in-history-only-if-has-chang.patch, 2.4 KB (added by cosoleto, 9 years ago)

Patch

  • lib/widget/input.c

    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) 
    224224        strip_password (t, i >= ELEMENTS); 
    225225    } 
    226226 
     227    if (in->history && in->history->data) 
     228        if (!strcmp(in->history->data, t)) 
     229            return; 
     230 
    227231    in->history = list_append_unique (in->history, t); 
     232    in->history_changed = TRUE; 
    228233    in->need_push = FALSE; 
    229234} 
    230235 
    input_destroy (WInput * in) 
    771776 
    772777    if (in->history != NULL) 
    773778    { 
    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        { 
    775781            history_put (in->history_name, in->history); 
     782            in->history_changed = FALSE; 
     783        } 
    776784 
    777785        in->history = g_list_first (in->history); 
    778786        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 
    884892    in->disable_update = 0; 
    885893    in->mark = 0; 
    886894    in->need_push = TRUE; 
     895    in->history_changed = FALSE; 
    887896    in->is_password = FALSE; 
    888897 
    889898    strcpy (in->buffer, def_text); 
  • lib/widget/input.h

    diff --git a/lib/widget/input.h b/lib/widget/input.h
    index 25b6c22..11d371f 100644
    a b typedef struct 
    5858    gboolean is_password;       /* is this a password input line? */ 
    5959    char *buffer;               /* pointer to editing buffer */ 
    6060    GList *history;             /* the history */ 
     61    int history_changed;        /* if the history has changed */ 
    6162    gboolean need_push;         /* need to push the current Input on hist? */ 
    6263    char **completions;         /* possible completions array */ 
    6364    input_complete_t completion_flags;