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; int len; if (str == NULL) str = statusbar_item_get_value(item); if (str == NULL || *str == '\0') { item->min_size = item->max_size = 0; return; } if (active_win == NULL) { server = NULL; wiitem = NULL; } else { server = active_win->active_server; wiitem = active_win->active; } /* expand templates */ tmpstr = theme_format_expand_data(current_theme, &str, 'n', 'n', NULL, NULL, EXPAND_FLAG_ROOT | EXPAND_FLAG_IGNORE_REPLACES | EXPAND_FLAG_IGNORE_EMPTY); /* expand $variables */ tmpstr2 = parse_special_string(tmpstr, server, wiitem, data, NULL, (escape_vars ? PARSE_FLAG_ESCAPE_VARS : 0 )); g_free(tmpstr); /* remove color codes (not %formats) */ tmpstr = strip_codes(tmpstr2); g_free(tmpstr2); if (get_size_only) { item->min_size = item->max_size = format_get_length(tmpstr); } else { if (item->size < item->min_size) { /* they're forcing us smaller than minimum size.. */ len = format_real_length(tmpstr, item->size); tmpstr[len] = '\0'; } tmpstr2 = update_statusbar_bg(tmpstr, item->bar->color); gui_printtext(item->xpos, item->bar->real_ypos, tmpstr2); g_free(tmpstr2); } g_free(tmpstr); }
void gui_entry_set_perm_prompt(const char *str) { g_return_if_fail(str != NULL); g_free_not_null(prompt); prompt = g_strdup(str); promptlen = format_get_length(prompt); permanent_prompt = TRUE; gui_entry_set_prompt(NULL); }
void gui_entry_set_prompt(const char *str) { if (str != NULL) { if (permanent_prompt) return; g_free_not_null(prompt); prompt = g_strdup(str); promptlen = format_get_length(prompt); } if (prompt != NULL) gui_printtext(0, LINES-1, prompt); entry_screenpos(); entry_update(); }
void gui_entry_set_prompt(GUI_ENTRY_REC *entry, const char *str) { int oldlen; g_return_if_fail(entry != NULL); oldlen = entry->promptlen; if (str != NULL) { g_free_not_null(entry->prompt); entry->prompt = g_strdup(str); entry->promptlen = format_get_length(str); } if (entry->prompt != NULL) gui_printtext(entry->xpos, entry->ypos, entry->prompt); if (entry->promptlen != oldlen) { gui_entry_fix_cursor(entry); gui_entry_draw(entry); } }
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; theme_rm_col reset; strcpy(reset.m, "n"); int len; if (str == NULL) str = statusbar_item_get_value(item); if (str == NULL || *str == '\0') { item->min_size = item->max_size = 0; return; } if (active_win == NULL) { server = NULL; wiitem = NULL; } else { server = active_win->active_server != NULL ? active_win->active_server : active_win->connect_server; wiitem = active_win->active; } /* expand templates */ tmpstr = theme_format_expand_data(current_theme, &str, reset, reset, NULL, NULL, EXPAND_FLAG_ROOT | EXPAND_FLAG_IGNORE_REPLACES | EXPAND_FLAG_IGNORE_EMPTY); /* expand $variables */ tmpstr2 = parse_special_string(tmpstr, server, wiitem, data, NULL, (escape_vars ? PARSE_FLAG_ESCAPE_VARS : 0 )); g_free(tmpstr); /* remove color codes (not %formats) */ tmpstr = strip_codes(tmpstr2); g_free(tmpstr2); if (get_size_only) { item->min_size = item->max_size = format_get_length(tmpstr); } else { GString *out; if (item->size < item->min_size) { /* they're forcing us smaller than minimum size.. */ len = format_real_length(tmpstr, item->size); tmpstr[len] = '\0'; } out = finalize_string(tmpstr, item->bar->color); /* 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) { int i; len = item->size-len; for (i = 0; i < len; i++) g_string_append_c(out, ' '); } gui_printtext(item->xpos, item->bar->real_ypos, out->str); g_string_free(out, TRUE); } g_free(tmpstr); }
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; int len; if (str == NULL) str = statusbar_item_get_value(item); if (str == NULL || *str == '\0') { item->min_size = item->max_size = 0; return; } if (active_win == NULL) { server = NULL; wiitem = NULL; } else { server = active_win->active_server != NULL ? active_win->active_server : active_win->connect_server; wiitem = active_win->active; } /* expand templates */ tmpstr = theme_format_expand_data(current_theme, &str, 'n', 'n', NULL, NULL, EXPAND_FLAG_ROOT | EXPAND_FLAG_IGNORE_REPLACES | EXPAND_FLAG_IGNORE_EMPTY); /* expand $variables */ tmpstr2 = parse_special_string(tmpstr, server, wiitem, data, NULL, (escape_vars ? PARSE_FLAG_ESCAPE_VARS : 0 )); g_free(tmpstr); /* remove color codes (not %formats) */ 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 { if (item->size < item->min_size) { /* 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); gui_printtext(item->xpos, item->bar->real_ypos, tmpstr2); g_free(tmpstr2); } g_free(tmpstr); }