SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar, SBAR_ITEM_CONFIG_REC *config) { SBAR_ITEM_REC *rec; GSList *items; g_return_val_if_fail(bar != NULL, NULL); g_return_val_if_fail(config != NULL, NULL); rec = g_new0(SBAR_ITEM_REC, 1); bar->items = g_slist_append(bar->items, rec); rec->bar = bar; rec->config = config; rec->func = (STATUSBAR_FUNC) g_hash_table_lookup(sbar_item_funcs, config->name); if (rec->func == NULL) rec->func = statusbar_item_default_func; statusbar_item_default_signals(rec); items = g_hash_table_lookup(named_sbar_items, config->name); items = g_slist_append(items, rec); g_hash_table_insert(named_sbar_items, config->name, items); irssi_set_dirty(); rec->dirty = TRUE; bar->dirty = TRUE; signal_emit("statusbar item created", 1, rec); return rec; }
static void mainwindows_resize_two(MAIN_WINDOW_REC *grow_win, MAIN_WINDOW_REC *shrink_win, int count) { irssi_set_dirty(); mainwindow_resize(grow_win, 0, count); mainwindow_resize(shrink_win, 0, -count); grow_win->dirty = TRUE; shrink_win->dirty = TRUE; }
void mainwindows_redraw(void) { GSList *tmp; irssi_set_dirty(); for (tmp = mainwindows; tmp != NULL; tmp = tmp->next) { MAIN_WINDOW_REC *rec = tmp->data; rec->dirty = TRUE; } }
void gui_window_resize(WINDOW_REC *window, int width, int height) { GUI_WINDOW_REC *gui; if (window->width == width && window->height == height) return; gui = WINDOW_GUI(window); irssi_set_dirty(); WINDOW_MAIN(window)->dirty = TRUE; window->width = width; window->height = height; textbuffer_view_resize(gui->view, width, height); }
void statusbar_redraw(STATUSBAR_REC *bar, int force) { if (statusbar_need_recreate_items) return; /* don't bother yet */ if (bar != NULL) { if (force) { irssi_set_dirty(); bar->dirty = TRUE; bar->dirty_xpos = 0; } statusbar_calc_item_positions(bar); } else if (active_statusbar_group != NULL) { g_slist_foreach(active_statusbar_group->bars, (GFunc) statusbar_redraw, GINT_TO_POINTER(force)); } }
void statusbar_item_redraw(SBAR_ITEM_REC *item) { WINDOW_REC *old_active_win; g_return_if_fail(item != NULL); old_active_win = active_win; if (item->bar->parent_window != NULL) active_win = item->bar->parent_window->active; item->func(item, TRUE); item->dirty = TRUE; item->bar->dirty = TRUE; irssi_set_dirty(); if (item->max_size != item->size) { /* item wants a new size - we'll need to redraw the statusbar to see if this is allowed */ statusbar_redraw(item->bar, item->config->right_alignment); } active_win = old_active_win; }
STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group, STATUSBAR_CONFIG_REC *config, MAIN_WINDOW_REC *parent_window) { STATUSBAR_REC *bar; THEME_REC *theme; GSList *tmp; char *name, *value; g_return_val_if_fail(group != NULL, NULL); g_return_val_if_fail(config != NULL, NULL); g_return_val_if_fail(config->type != STATUSBAR_TYPE_WINDOW || parent_window != NULL, NULL); bar = g_new0(STATUSBAR_REC, 1); group->bars = g_slist_append(group->bars, bar); bar->group = group; bar->config = config; bar->parent_window = parent_window; irssi_set_dirty(); bar->dirty = TRUE; bar->dirty_xpos = 0; signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); signal_remove("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); if (config->type == STATUSBAR_TYPE_ROOT) { /* top/bottom of the screen */ mainwindows_reserve_lines(config->placement == STATUSBAR_TOP, config->placement == STATUSBAR_BOTTOM); theme = current_theme; } else { /* top/bottom of the window */ parent_window->statusbars = g_slist_append(parent_window->statusbars, bar); mainwindow_set_statusbar_lines(parent_window, config->placement == STATUSBAR_TOP, config->placement == STATUSBAR_BOTTOM); theme = parent_window != NULL && parent_window->active != NULL && parent_window->active->theme != NULL ? parent_window->active->theme : current_theme; } signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); signal_add("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); /* get background color from sb_background abstract */ name = g_strdup_printf("{sb_%s_bg}", config->name); value = theme_format_expand(theme, name); g_free(name); if (*value == '\0') { /* try with the statusbar group name */ g_free(value); name = g_strdup_printf("{sb_%s_bg}", group->name); value = theme_format_expand(theme, name); g_free(name); if (*value == '\0') { /* fallback to default statusbar background (also provides backwards compatibility..) */ g_free(value); value = theme_format_expand(theme, "{sb_background}"); } } if (*value == '\0') { g_free(value); value = g_strdup("%8"); } bar->color = g_strconcat("%n", value, NULL); g_free(value); statusbars_recalc_ypos(bar); signal_emit("statusbar created", 1, bar); /* create the items to statusbar */ for (tmp = config->items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_CONFIG_REC *rec = tmp->data; statusbar_item_create(bar, rec); } return bar; }
static void statusbar_calc_item_positions(STATUSBAR_REC *bar) { WINDOW_REC *old_active_win; GSList *tmp, *right_items; int xpos, rxpos; old_active_win = active_win; if (bar->parent_window != NULL) active_win = bar->parent_window->active; statusbar_resize_items(bar, term_width); /* left-aligned items */ xpos = 0; for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_REC *rec = tmp->data; if (!rec->config->right_alignment && (rec->size > 0 || rec->current_size > 0)) { if (SBAR_ITEM_REDRAW_NEEDED(bar, rec, xpos)) { /* redraw the item */ rec->dirty = TRUE; if (bar->dirty_xpos == -1 || xpos < bar->dirty_xpos) { irssi_set_dirty(); bar->dirty = TRUE; bar->dirty_xpos = xpos; } rec->xpos = xpos; } xpos += rec->size; } } /* right-aligned items - first copy them to a new list backwards, easier to draw them in right order */ right_items = NULL; for (tmp = bar->items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_REC *rec = tmp->data; if (rec->config->right_alignment) { if (rec->size > 0) right_items = g_slist_prepend(right_items, rec); else if (rec->current_size > 0 && (bar->dirty_xpos == -1 || rec->xpos < bar->dirty_xpos)) { /* item was hidden - set the dirty position to begin from the item's old xpos */ irssi_set_dirty(); bar->dirty = TRUE; bar->dirty_xpos = rec->xpos; } } } rxpos = term_width; for (tmp = right_items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_REC *rec = tmp->data; rxpos -= rec->size; if (SBAR_ITEM_REDRAW_NEEDED(bar, rec, rxpos)) { rec->dirty = TRUE; if (bar->dirty_xpos == -1 || rxpos < bar->dirty_xpos) { irssi_set_dirty(); bar->dirty = TRUE; bar->dirty_xpos = rxpos; } rec->xpos = rxpos; } } g_slist_free(right_items); active_win = old_active_win; }
static void sig_winch(int p) { irssi_set_dirty(); resize_dirty = TRUE; }