Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
1126:771eb6aa2d41 | 1127:fddf2fef7b83 |
---|---|
95 static char *ptr_inputline; | 95 static char *ptr_inputline; |
96 static short int inputline_offset; | 96 static short int inputline_offset; |
97 static int completion_started; | 97 static int completion_started; |
98 static GList *cmdhisto; | 98 static GList *cmdhisto; |
99 static GList *cmdhisto_cur; | 99 static GList *cmdhisto_cur; |
100 static guint cmdhisto_nblines; | |
100 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; | 101 static char cmdhisto_backup[INPUTLINE_LENGTH+1]; |
101 | 102 |
102 static int chatstate; /* (0=active, 1=composing, 2=paused) */ | 103 static int chatstate; /* (0=active, 1=composing, 2=paused) */ |
103 static bool lock_chatstate; | 104 static bool lock_chatstate; |
104 static time_t chatstate_timestamp; | 105 static time_t chatstate_timestamp; |
2091 | 2092 |
2092 // scr_cmdhisto_addline() | 2093 // scr_cmdhisto_addline() |
2093 // Add a line to the inputLine history | 2094 // Add a line to the inputLine history |
2094 inline void scr_cmdhisto_addline(char *line) | 2095 inline void scr_cmdhisto_addline(char *line) |
2095 { | 2096 { |
2096 if (!line || !*line) return; | 2097 int max_histo_lines; |
2098 | |
2099 if (!line || !*line) | |
2100 return; | |
2101 | |
2102 max_histo_lines = settings_opt_get_int("cmdhistory_lines"); | |
2103 | |
2104 if (max_histo_lines < 0) | |
2105 max_histo_lines = 1; | |
2106 | |
2107 if (max_histo_lines) | |
2108 while (cmdhisto_nblines >= (guint)max_histo_lines) { | |
2109 if (cmdhisto_cur && cmdhisto_cur == cmdhisto) | |
2110 break; | |
2111 g_free(cmdhisto->data); | |
2112 cmdhisto = g_list_delete_link(cmdhisto, cmdhisto); | |
2113 cmdhisto_nblines--; | |
2114 } | |
2097 | 2115 |
2098 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); | 2116 cmdhisto = g_list_append(cmdhisto, g_strdup(line)); |
2117 cmdhisto_nblines++; | |
2099 } | 2118 } |
2100 | 2119 |
2101 // scr_cmdhisto_prev() | 2120 // scr_cmdhisto_prev() |
2102 // Look for previous line beginning w/ the given mask in the inputLine history | 2121 // Look for previous line beginning w/ the given mask in the inputLine history |
2103 // Returns NULL if none found | 2122 // Returns NULL if none found |