void textbuffer_reformat_line(WINDOW_REC *window, LINE_REC *line) { GUI_WINDOW_REC *gui; TEXT_DEST_REC dest; LINE_REC *line_prev; LINE_INFO_REC line_info; GString *raw; char *str, *tmp, *prestr, *linestart, *leveltag; gui = WINDOW_GUI(window); raw = g_string_new(NULL); str = textbuffer_line_get_format(window, line, raw); if (str == NULL && raw->len == 2 && raw->str[1] == (char)LINE_CMD_FORMAT_CONT) { /* multiline format, format explained in one the following lines. remove this line. */ textbuffer_view_remove_line(gui->view, line); } else if (str != NULL) { /* FIXME: ugly ugly .. and this can't handle unformatted lines.. */ g_string_append_c(raw, '\0'); g_string_append_c(raw, (char)LINE_CMD_EOL); line_prev = line->prev; memcpy(&line_info, &line->info, sizeof(line_info)); textbuffer_view_remove_line(gui->view, line); line = NULL; format_create_dest(&dest, NULL, NULL, line_info.level, window); linestart = format_get_line_start(current_theme, &dest, line_info.time); leveltag = format_get_level_tag(current_theme, &dest); prestr = g_strconcat(linestart == NULL ? "" : linestart, leveltag, NULL); g_free_not_null(linestart); g_free_not_null(leveltag); tmp = format_add_linestart(str, prestr); g_free(str); g_free(prestr); gui_printtext_after(&dest, line_prev, tmp); g_free(tmp); line = textbuffer_insert(gui->view->buffer, gui->insert_after, (unsigned char *) raw->str, raw->len, &line_info); textbuffer_view_insert_line(gui->view, line); } g_string_free(raw, TRUE); }
void quassel_irssi_set_last_seen_msg(void *arg, int buffer_id, int msgid) { (void) msgid; Quassel_SERVER_REC *server = (Quassel_SERVER_REC*)arg; if(!PROTO_CHECK_CAST(SERVER(server), Quassel_SERVER_REC, chat_type, "Quassel")) return; Quassel_CHANNEL_REC* chanrec = NULL; //First find channel GSList *chans = server->channels; while(chans) { chanrec = (Quassel_CHANNEL_REC*) chans->data; if(chanrec->buffer_id == buffer_id) break; chanrec = NULL; chans = g_slist_next(chans); } if(!chanrec) return; chanrec->last_seen_msg_id = msgid; if(chanrec->init_last_seen_msg_id == -1) chanrec->init_last_seen_msg_id = msgid; //Now find windows GSList *win = windows; while(win) { WINDOW_REC* winrec = (WINDOW_REC*) win->data; if(winrec->active_server != SERVER(server) && winrec->connect_server != SERVER(server)) goto next; if(!winrec->active) goto next; if(strcmp(winrec->active->visible_name, chanrec->name)==0) { signal_emit("window dehilight", 1, winrec); if(winrec != active_win) { LINE_REC *linerec = textbuffer_view_get_bookmark(WINDOW_GUI(winrec)->view, "trackbar"); if(linerec) textbuffer_view_remove_line(WINDOW_GUI(winrec)->view, linerec); char *str = malloc(winrec->width+3); str[0] = '%'; str[1] = 'K'; for(int i=0; i<winrec->width; ++i) str[i+2]='-'; str[winrec->width+2]=0; printtext_string_window(winrec, MSGLEVEL_NEVER, str); free(str); textbuffer_view_set_bookmark_bottom(WINDOW_GUI(winrec)->view, "trackbar"); } } next: win = g_slist_next(win); } }
static void sig_window_changed(WINDOW_REC *active, WINDOW_REC *old) { window_read(active); window_read(old); textbuffer_view_set_bookmark_bottom(WINDOW_GUI(active)->view, "useless_end"); LINE_REC *linerec = textbuffer_view_get_bookmark(WINDOW_GUI(active)->view, "trackbar"); LINE_REC *last_line = textbuffer_view_get_bookmark(WINDOW_GUI(active)->view, "useless_end"); if(linerec == last_line && linerec) textbuffer_view_remove_line(WINDOW_GUI(active)->view, linerec); }
static void remove_old_lines(TEXT_BUFFER_VIEW_REC *view) { LINE_REC *line; time_t cur_time = time(NULL); time_t old_time; old_time = cur_time - scrollback_time + 1; if (view->buffer->lines_count >= scrollback_lines+scrollback_burst_remove) { /* remove lines by line count */ while (view->buffer->lines_count > scrollback_lines) { line = view->buffer->first_line; if (line->info.time >= old_time || scrollback_lines == 0) { /* too new line, don't remove yet - also if scrollback_lines is 0, we want to check only scrollback_time setting. */ break; } textbuffer_view_remove_line(view, line); } } if (scrollback_max_age > 0) { old_time = cur_time - scrollback_max_age; while (view->buffer->lines_count > 0) { line = view->buffer->first_line; if (line->info.time >= old_time) { /* * The first line is newer than the threshold * time -> no need to remove more lines. */ break; } textbuffer_view_remove_line(view, line); } } }
void textbuffer_view_remove_lines_by_level(TEXT_BUFFER_VIEW_REC *view, int level) { LINE_REC *line, *next; term_refresh_freeze(); line = textbuffer_view_get_lines(view); while (line != NULL) { next = line->next; if (line->info.level & level) textbuffer_view_remove_line(view, line); line = next; } textbuffer_view_redraw(view); term_refresh_thaw(); }
static void window_lastlog_clear(WINDOW_REC *window) { TEXT_BUFFER_VIEW_REC *view; LINE_REC *line, *next; term_refresh_freeze(); view = WINDOW_GUI(window)->view; line = textbuffer_view_get_lines(view); while (line != NULL) { next = line->next; if (line->info.level & MSGLEVEL_LASTLOG) textbuffer_view_remove_line(view, line); line = next; } textbuffer_view_redraw(view); term_refresh_thaw(); }
static void remove_old_lines(TEXT_BUFFER_VIEW_REC *view) { LINE_REC *line; time_t old_time; old_time = time(NULL)-(scrollback_hours*3600)+1; if (view->buffer->lines_count >= scrollback_lines+scrollback_burst_remove) { /* remove lines by line count */ while (view->buffer->lines_count > scrollback_lines) { line = view->buffer->first_line; if (line->info.time >= old_time || scrollback_lines == 0) { /* too new line, don't remove yet - also if scrollback_lines is 0, we want to check only scrollback_hours setting. */ break; } textbuffer_view_remove_line(view, line); } } }