- char * title = "Window's geometry:\n";
- char * h_d = "\nHeight to save: ";
- char * h_pos = " (width in cells)";
- char * h_neg = " (negative diff: cells to screen width)";
- char * w_d = "\n\nWidth to save: ";
- char * w_pos = " (height in cells)";
- char * w_neg = " (negative diff: cells to screen height)";
- char * h_t = h_pos;
- char * w_t = w_pos;
- if (1 == win->target_height_type)
- {
- h_t = h_neg;
- }
- if (1 == win->target_width_type)
- {
- w_t = w_neg;
- }
- uint16_t maxl = strlen(title)
- + strlen(h_t) + strlen(h_d) + 6 /* 6 = n of chars to */
- + strlen(w_t) + strlen(w_d) + 6 + 1; /* write max int16_t */
- char text[maxl + 1];
- sprintf(text, "%s%s%d%s%s%d%s", title, h_d, win->target_height, h_t,
- w_d, win->target_width, w_t);
+ char * title = "Window's geometry:\n\n";
+ char * h_title = "Height to save: ";
+ char h_value[6 + 1]; /* 6: int16_t value max strlen */
+ sprintf(h_value, "%d", win->target_height);
+ char * h_plus = " (width in cells)\n\n";
+ char * h_minus = " (negative diff: cells to screen width)\n\n";
+ char * h_type = (1 == win->target_height_type) ? h_minus : h_plus;
+ char * w_title = "Width to save: ";
+ char w_value[6 + 1];
+ sprintf(w_value, "%d", win->target_width);
+ char * w_plus = "(height in cells)\n\n";
+ char * w_minus = " (negative diff: cells to screen height)\n\n";
+ char * w_type = (1 == win->target_width_type) ? w_minus : w_plus;
+ char * breaks_title = "Linebreak type: ";
+ char * breaks_type = (1 == win->linebreak) ? "wide" : "long";
+ breaks_type = (2 == win->linebreak) ? "compact" : breaks_type;
+ uint16_t text_size = strlen(title)
+ + strlen(h_title) + strlen(h_value) + strlen(h_type)
+ + strlen(w_title) + strlen(w_value) + strlen(w_type)
+ + strlen(breaks_title) + strlen(breaks_type);
+ char text[text_size + 1];
+ sprintf(text, "%s%s%s%s%s%s%s%s%s", title, h_title, h_value, h_type,
+ w_title, w_value, w_type, breaks_title, breaks_type);