Mercurial > hg
changeset 1127:fddf2fef7b83
Add option "cmdhistory_lines"
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 14 Jan 2007 15:00:25 +0100 |
parents | 771eb6aa2d41 |
children | ac9c89f6cb51 |
files | mcabber/mcabberrc.example mcabber/src/screen.c |
diffstat | 2 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/mcabberrc.example Sat Jan 13 14:38:07 2007 +0100 +++ b/mcabber/mcabberrc.example Sun Jan 14 15:00:25 2007 +0100 @@ -76,6 +76,11 @@ # de, fr, nl, pl, ru, uk. #set lang = en +# History +# Number of lines to remember for the command line history +# (default: 0, unlimited). +set cmdhistory_lines = 250 + # Set hide_offline_buddies to 1 to display only connected buddies # in the roster. #set hide_offline_buddies = 0
--- a/mcabber/src/screen.c Sat Jan 13 14:38:07 2007 +0100 +++ b/mcabber/src/screen.c Sun Jan 14 15:00:25 2007 +0100 @@ -97,6 +97,7 @@ static int completion_started; static GList *cmdhisto; static GList *cmdhisto_cur; +static guint cmdhisto_nblines; static char cmdhisto_backup[INPUTLINE_LENGTH+1]; static int chatstate; /* (0=active, 1=composing, 2=paused) */ @@ -2093,9 +2094,27 @@ // Add a line to the inputLine history inline void scr_cmdhisto_addline(char *line) { - if (!line || !*line) return; + int max_histo_lines; + + if (!line || !*line) + return; + + max_histo_lines = settings_opt_get_int("cmdhistory_lines"); + + if (max_histo_lines < 0) + max_histo_lines = 1; + + if (max_histo_lines) + while (cmdhisto_nblines >= (guint)max_histo_lines) { + if (cmdhisto_cur && cmdhisto_cur == cmdhisto) + break; + g_free(cmdhisto->data); + cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); + cmdhisto_nblines--; + } cmdhisto = g_list_append(cmdhisto, g_strdup(line)); + cmdhisto_nblines++; } // scr_cmdhisto_prev()