diff options
author | Timo Sirainen <cras@irssi.org> | 2000-05-25 12:24:09 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-05-25 12:24:09 +0000 |
commit | 48b409ea14ff2ab56499f8f7e862e40b84c0978c (patch) | |
tree | 36a378145cf7abbebe06f14b7fd8b9189715106f | |
parent | 76605ad0aed7e53c4a9dab686474235f547a5837 (diff) | |
download | irssi-48b409ea14ff2ab56499f8f7e862e40b84c0978c.zip |
/set max_textbuffer_lines changed to /set scrollback_lines and
/set scrollback_hours - this means that keep scrollback usually max.
x lines, but allow more if the text is newer than n hours.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@231 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r-- | src/fe-common/core/command-history.c | 2 | ||||
-rw-r--r-- | src/fe-text/gui-printtext.c | 37 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/fe-common/core/command-history.c b/src/fe-common/core/command-history.c index fa7a1375..1bffe2c7 100644 --- a/src/fe-common/core/command-history.c +++ b/src/fe-common/core/command-history.c @@ -156,8 +156,6 @@ static void read_settings(void) void command_history_init(void) { - settings_add_int("history", "max_textwidget_lines", 1000); - settings_add_int("history", "block_remove_lines", 20); settings_add_int("history", "max_command_history", 100); settings_add_bool("history", "window_history", FALSE); diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c index d94d9302..85024c90 100644 --- a/src/fe-text/gui-printtext.c +++ b/src/fe-text/gui-printtext.c @@ -32,8 +32,8 @@ #define TEXT_CHUNK_USABLE_SIZE (LINE_TEXT_CHUNK_SIZE-2-sizeof(char*)) -static gint mirc_colors[] = { 15, 0, 1, 2, 4, 6, 5, 4, 14, 10, 3, 11, 9, 13, 8, 7, 15 }; -static gint max_textwidget_lines; +static int mirc_colors[] = { 15, 0, 1, 2, 4, 6, 5, 4, 14, 10, 3, 11, 9, 13, 8, 7, 15 }; +static int scrollback_lines, scrollback_hours; #define mark_temp_eol(text) \ memcpy((text)->buffer + (text)->pos, "\0\x80", 2); @@ -130,6 +130,28 @@ static void remove_first_line(WINDOW_REC *window) gui_window_redraw(window); } +static void remove_old_lines(WINDOW_REC *window) +{ + GUI_WINDOW_REC *gui; + LINE_REC *line; + time_t old_time; + + gui = WINDOW_GUI(window); + + old_time = time(NULL)-(scrollback_hours*3600); + if (scrollback_lines > 0) { + /* remove lines by line count */ + while (window->lines > scrollback_lines) { + line = gui->lines->data; + if (line->time >= old_time) { + /* too new line, don't remove yet */ + break; + } + remove_first_line(window); + } + } +} + static void get_colors(int flags, int *fg, int *bg) { if (flags & PRINTFLAG_MIRC_COLOR) { @@ -224,10 +246,9 @@ static void gui_printtext(WINDOW_REC *window, gpointer fgcolor, gpointer bgcolor g_return_if_fail(window != NULL); - gui = WINDOW_GUI(window); - if (max_textwidget_lines > 0 && max_textwidget_lines <= window->lines) - remove_first_line(window); + remove_old_lines(window); + gui = WINDOW_GUI(window); visible = is_window_visible(window) && gui->bottom; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); @@ -320,11 +341,15 @@ static void sig_printtext_finished(WINDOW_REC *window) static void read_settings(void) { - max_textwidget_lines = settings_get_int("max_textwidget_lines"); + scrollback_lines = settings_get_int("scrollback_lines"); + scrollback_hours = settings_get_int("scrollback_hours"); } void gui_printtext_init(void) { + settings_add_int("history", "scrollback_lines", 500); + settings_add_int("history", "scrollback_hours", 24); + signal_add("gui print text", (SIGNAL_FUNC) gui_printtext); signal_add("print text finished", (SIGNAL_FUNC) sig_printtext_finished); signal_add("setup changed", (SIGNAL_FUNC) read_settings); |