}
#define SBAR_ITEM_REDRAW_NEEDED(_bar, _item, _xpos) \
- (((_bar)->dirty_xpos != -1 && \
- (_xpos) >= (_bar)->dirty_xpos) || \
+ (((_bar)->dirty_xpos != -1 && (_xpos) >= (_bar)->dirty_xpos) || \
(_item)->xpos != (_xpos) || (_item)->current_size != (_item)->size)
static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
if (rec->config->right_alignment) {
if (rec->size > 0)
right_items = g_slist_prepend(right_items, rec);
- else if (rec->current_size > 0) {
+ 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();
return value;
}
+static char *reverse_controls(const char *str)
+{
+ GString *out;
+ char *ret;
+
+ out = g_string_new(NULL);
+
+ while (*str != '\0') {
+ if ((unsigned char) *str < 32 ||
+ (term_type == TERM_TYPE_8BIT &&
+ (unsigned char) (*str & 0x7f) < 32)) {
+ /* control char */
+ g_string_sprintfa(out, "%%8%c%%8",
+ 'A'-1 + (*str & 0x7f));
+ } else {
+ g_string_append_c(out, *str);
+ }
+
+ str++;
+ }
+
+ ret = out->str;
+ g_string_free(out, FALSE);
+ return ret;
+}
+
void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
const char *str, const char *data,
int escape_vars)
{
SERVER_REC *server;
- WI_ITEM_REC *wiitem;
- char *tmpstr, *tmpstr2;
+ WI_ITEM_REC *wiitem;
+ char *tmpstr, *tmpstr2;
int len;
if (str == NULL)
server = NULL;
wiitem = NULL;
} else {
- server = active_win->active_server;
- wiitem = active_win->active;
+ server = active_win->active_server != NULL ?
+ active_win->active_server : active_win->connect_server;
+ wiitem = active_win->active;
}
/* expand templates */
tmpstr = strip_codes(tmpstr2);
g_free(tmpstr2);
+ /* show all control chars reversed */
+ tmpstr2 = reverse_controls(tmpstr);
+ g_free(tmpstr);
+
+ tmpstr = tmpstr2;
if (get_size_only) {
item->min_size = item->max_size = format_get_length(tmpstr);
} else {
/* they're forcing us smaller than minimum size.. */
len = format_real_length(tmpstr, item->size);
tmpstr[len] = '\0';
+ } else {
+ /* make sure the str is big enough to fill the
+ requested size, so it won't corrupt screen */
+ len = format_get_length(tmpstr);
+ if (len < item->size) {
+ char *fill;
+
+ len = item->size-len;
+ fill = g_malloc(len + 1);
+ memset(fill, ' ', len); fill[len] = '\0';
+
+ tmpstr2 = g_strconcat(tmpstr, fill, NULL);
+ g_free(fill);
+ g_free(tmpstr);
+ tmpstr = tmpstr2;
+ }
}
tmpstr2 = update_statusbar_bg(tmpstr, item->bar->color);
func = NULL;
break;
}
- if (func != NULL)
- signal_add_to_id(MODULE_NAME, 1, *pos, func);
+ if (func != NULL) {
+ signal_add_full_id(MODULE_NAME,
+ SIGNAL_PRIORITY_DEFAULT,
+ *pos, func, NULL);
+ }
}
if (g_slist_find(list, item) == NULL)
static void statusbar_signal_remove(int signal_id)
{
- signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_item);
- signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_server);
- signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window);
- signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window_item);
+ signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_item, NULL);
+ signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_server, NULL);
+ signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window, NULL);
+ signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window_item, NULL);
}
static void statusbar_item_remove_signal(SBAR_ITEM_REC *item, int signal_id)
g_slist_free(value);
}
-static void sig_setup_reload(void)
+void statusbars_create_window_bars(void)
{
- /* statusbar-config.c recreates root statusbars,
- we need to create window-statusbars */
g_slist_foreach(mainwindows, (GFunc) statusbars_add_visible, NULL);
}
signal_add("gui window created", (SIGNAL_FUNC) sig_gui_window_created);
signal_add("window changed", (SIGNAL_FUNC) sig_window_changed);
signal_add("mainwindow destroyed", (SIGNAL_FUNC) sig_mainwindow_destroyed);
- signal_add_last("setup reread", (SIGNAL_FUNC) sig_setup_reload);
statusbar_items_init();
statusbar_config_init(); /* signals need to be before this call */
signal_remove("gui window created", (SIGNAL_FUNC) sig_gui_window_created);
signal_remove("window changed", (SIGNAL_FUNC) sig_window_changed);
signal_remove("mainwindow destroyed", (SIGNAL_FUNC) sig_mainwindow_destroyed);
- signal_remove("setup reread", (SIGNAL_FUNC) sig_setup_reload);
statusbar_items_deinit();
statusbar_config_deinit();