1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

/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
This commit is contained in:
Timo Sirainen 2000-05-25 12:24:09 +00:00 committed by cras
parent 76605ad0ae
commit 48b409ea14
2 changed files with 31 additions and 8 deletions

View File

@ -156,8 +156,6 @@ static void read_settings(void)
void command_history_init(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_int("history", "max_command_history", 100);
settings_add_bool("history", "window_history", FALSE); settings_add_bool("history", "window_history", FALSE);

View File

@ -32,8 +32,8 @@
#define TEXT_CHUNK_USABLE_SIZE (LINE_TEXT_CHUNK_SIZE-2-sizeof(char*)) #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 int 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 scrollback_lines, scrollback_hours;
#define mark_temp_eol(text) \ #define mark_temp_eol(text) \
memcpy((text)->buffer + (text)->pos, "\0\x80", 2); memcpy((text)->buffer + (text)->pos, "\0\x80", 2);
@ -130,6 +130,28 @@ static void remove_first_line(WINDOW_REC *window)
gui_window_redraw(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) static void get_colors(int flags, int *fg, int *bg)
{ {
if (flags & PRINTFLAG_MIRC_COLOR) { 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); g_return_if_fail(window != NULL);
gui = WINDOW_GUI(window); remove_old_lines(window);
if (max_textwidget_lines > 0 && max_textwidget_lines <= window->lines)
remove_first_line(window);
gui = WINDOW_GUI(window);
visible = is_window_visible(window) && gui->bottom; visible = is_window_visible(window) && gui->bottom;
flags = GPOINTER_TO_INT(pflags); flags = GPOINTER_TO_INT(pflags);
fg = GPOINTER_TO_INT(fgcolor); fg = GPOINTER_TO_INT(fgcolor);
@ -320,11 +341,15 @@ static void sig_printtext_finished(WINDOW_REC *window)
static void read_settings(void) 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) 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("gui print text", (SIGNAL_FUNC) gui_printtext);
signal_add("print text finished", (SIGNAL_FUNC) sig_printtext_finished); signal_add("print text finished", (SIGNAL_FUNC) sig_printtext_finished);
signal_add("setup changed", (SIGNAL_FUNC) read_settings); signal_add("setup changed", (SIGNAL_FUNC) read_settings);