diff --git a/src/conky.cc b/src/conky.cc index b94e9187..144d250c 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -573,8 +573,6 @@ int get_total_updates(void) return total_updates; } -#define SECRIT_MULTILINE_CHAR '\x02' - int calc_text_width(const char *s) { size_t slen = strlen(s); @@ -799,23 +797,6 @@ void parse_conky_vars(struct text_object *root, const char *txt, generate_text_internal(p, p_max_size, *root); } -/* substitutes all occurrences of '\n' with SECRIT_MULTILINE_CHAR, which allows - * multiline objects like $exec work with $align[rc] and friends - */ -void substitute_newlines(char *p, long l) -{ - char *s = p; - if (l < 0) return; - while (p && *p && p < s + l) { - if (*p == '\n') { - /* only substitute if it's not the last newline */ - *p = SECRIT_MULTILINE_CHAR; - } - p++; - } -} - - /* IFBLOCK jumping algorithm * * This is easier as it looks like: @@ -877,8 +858,6 @@ void generate_text_internal(char *p, int p_max_size, struct text_object root) #ifdef BUILD_ICONV iconv_convert(&a, buff_in, p, p_max_size); #endif /* BUILD_ICONV */ - if (!obj->verbatim_output) - substitute_newlines(p, a - 2); p += a; p_max_size -= a; (*p) = 0; @@ -1014,9 +993,6 @@ static int get_string_width_special(char *s, int special_index) } idx++; current = current->next; - } else if (*p == SECRIT_MULTILINE_CHAR) { - *p = 0; - break; } else { p++; } @@ -1133,8 +1109,6 @@ static long current_color; static int text_size_updater(char *s, int special_index) { int w = 0; - int lw; - int contain_SECRIT_MULTILINE_CHAR = 0; char *p; special_t *current = specials; @@ -1187,24 +1161,12 @@ static int text_size_updater(char *s, int special_index) special_index++; current = current->next; s = p + 1; - } else if (*p == SECRIT_MULTILINE_CHAR) { - contain_SECRIT_MULTILINE_CHAR = 1; - *p = '\0'; - lw = get_string_width(s); - *p = SECRIT_MULTILINE_CHAR; - s = p + 1; - w = lw > w ? lw : w; - text_height += last_font_height; } p++; } - /* Check also last substring if string contains SECRIT_MULTILINE_CHAR */ - if (contain_SECRIT_MULTILINE_CHAR) { - lw = get_string_width(s); - w = lw > w ? lw : w; - } else { - w += get_string_width(s); - } + + w += get_string_width(s); + if (w > text_width) { text_width = w; } @@ -1260,50 +1222,42 @@ static void draw_string(const char *s) int i, i2, pos, width_of_s; int max = 0; int added; - char *s_with_newlines; if (s[0] == '\0') { return; } width_of_s = get_string_width(s); - s_with_newlines = strdup(s); - for(i = 0; i < (int) strlen(s_with_newlines); i++) { - if(s_with_newlines[i] == SECRIT_MULTILINE_CHAR) { - s_with_newlines[i] = '\n'; - } - } if (out_to_stdout.get(*state) && draw_mode == FG) { - printf("%s\n", s_with_newlines); + printf("%s\n", s); if (extra_newline.get(*state)) fputc('\n', stdout); fflush(stdout); /* output immediately, don't buffer */ } if (out_to_stderr.get(*state) && draw_mode == FG) { - fprintf(stderr, "%s\n", s_with_newlines); + fprintf(stderr, "%s\n", s); fflush(stderr); /* output immediately, don't buffer */ } if (draw_mode == FG && overwrite_fpointer) { - fprintf(overwrite_fpointer, "%s\n", s_with_newlines); + fprintf(overwrite_fpointer, "%s\n", s); } if (draw_mode == FG && append_fpointer) { - fprintf(append_fpointer, "%s\n", s_with_newlines); + fprintf(append_fpointer, "%s\n", s); } #ifdef BUILD_NCURSES if (out_to_ncurses.get(*state) && draw_mode == FG) { - printw("%s", s_with_newlines); + printw("%s", s); } #endif #ifdef BUILD_HTTP if (out_to_http.get(*state) && draw_mode == FG) { std::string::size_type origlen = webpage.length(); - webpage.append(s_with_newlines); + webpage.append(s); webpage = string_replace_all(webpage, "\n", "
", origlen); webpage = string_replace_all(webpage, " ", "  ", origlen); webpage = string_replace_all(webpage, "  ", "  ", origlen); webpage.append("
"); } #endif - free(s_with_newlines); int tbs = text_buffer_size.get(*state); memset(tmpstring1, 0, tbs); memset(tmpstring2, 0, tbs); @@ -1395,7 +1349,6 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) int cur_y_add = 0; int mw = maximum_width.get(*state); #endif /* BUILD_X11 */ - char *recurse = 0; char *p = s; int last_special_needed = -1; int orig_special_index = special_index; @@ -1409,12 +1362,6 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) #endif /* BUILD_X11 */ while (*p) { - if (*p == SECRIT_MULTILINE_CHAR) { - /* special newline marker for multiline objects */ - recurse = p + 1; - *p = '\0'; - break; - } if (*p == SPECIAL_CHAR || last_special_applied > -1) { #ifdef BUILD_X11 int w = 0; @@ -1843,10 +1790,6 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) if (out_to_x.get(*state)) cur_y += font_descent(); #endif /* BUILD_X11 */ - if (recurse && *recurse) { - special_index = draw_each_line_inner(recurse, special_index, last_special_needed); - *(recurse - 1) = SECRIT_MULTILINE_CHAR; - } return special_index; } diff --git a/src/core.cc b/src/core.cc index 010dc3b7..dd9cf0bd 100644 --- a/src/core.cc +++ b/src/core.cc @@ -740,7 +740,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long END OBJ(execp, 0) scan_exec_arg(obj, arg); obj->parse = true; - obj->verbatim_output = true; obj->thread = false; obj->callbacks.print = &print_exec; obj->callbacks.free = &free_exec; @@ -781,7 +780,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long END OBJ_ARG(execpi, 0, "execpi needs arguments") scan_execi_arg(obj, arg); obj->parse = true; - obj->verbatim_output = true; obj->thread = false; obj->callbacks.print = &print_execi; obj->callbacks.free = &free_execi; @@ -794,7 +792,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long END OBJ_ARG(texecpi, 0, "texecpi needs arguments") scan_execi_arg(obj, arg); obj->parse = true; - obj->verbatim_output = true; obj->thread = true; obj->callbacks.print = &print_execi; obj->callbacks.free = &free_execi; @@ -1620,7 +1617,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long obj->callbacks.free = &gen_free_opaque; END OBJ_ARG(lua_parse, 0, "lua_parse needs arguments: [function parameters]") obj->data.s = strndup(arg, text_buffer_size.get(*state)); - obj->verbatim_output = true; obj->callbacks.print = &print_lua_parse; obj->callbacks.free = &gen_free_opaque; END OBJ_ARG(lua_bar, 0, "lua_bar needs arguments: , [function parameters]") diff --git a/src/text_object.cc b/src/text_object.cc index efb6dd4d..4663451d 100644 --- a/src/text_object.cc +++ b/src/text_object.cc @@ -197,7 +197,6 @@ int ifblock_stack_empty(void **opaque) void obj_be_plain_text(struct text_object *obj, const char *text) { obj->data.s = strdup(text); - obj->verbatim_output = 1; memset(&obj->callbacks, 0, sizeof(obj->callbacks)); obj->callbacks.print = &gen_print_obj_data_s; diff --git a/src/text_object.h b/src/text_object.h index a97d231d..03fc7115 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -100,9 +100,6 @@ struct text_object { long l; /* some long integer */ } data; - /* if non-zero, no substitute_newlines() is applied to object's output */ - char verbatim_output; - void *special_data; long line; struct obj_cb callbacks;