Mercurial > ~mikael > mcabber > hg
diff mcabber/src/screen.c @ 1127:fddf2fef7b83
Add option "cmdhistory_lines"
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 14 Jan 2007 15:00:25 +0100 |
parents | 648fe6f715a6 |
children | 1a109ebf3f24 |
line wrap: on
line diff
--- 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()