• Patch: Elm ME+ 2.5 PLalpha50 -> Elm ME+ 2.5 PLalpha51 [5/6] (2/5)

    From Kari Hurtta@21:1/5 to All on Tue Feb 11 20:06:30 2020
    [continued from previous message]

    + struct menu_param PARAM[qd_disp_COUNT+1];
    + struct menu_anon_param self;
    +
    +
    + /* Drawing algorithm */
    +
    + size_t top_mail_quota;
    + size_t top_quotarootl;
    +
    + int top_line; /* Start line after title */
    + int top_offset;
    +
    + unsigned int is_end:1;
    + };
    +
    + enum qd_step_mode { qd_step_prev = -1, qd_step_this = 0, qd_step_next };
    +
    + static void qd_draw_eoln P_((struct menu_context * print_area,
    + int * current_line_p,
    + int * current_col_p,
    + int * mayclear_p,
    + int * start_of_line_p,
    + int * printing_p,
    + int empty_line));
    + static void qd_draw_eoln(print_area,current_line_p,current_col_p,
    + mayclear_p,start_of_line_p,printing_p,empty_line)
    + struct menu_context * print_area;
    + int * current_line_p;
    + int * current_col_p;
    + int * mayclear_p;
    + int * start_of_line_p;
    + int * printing_p;
    + int empty_line;
    + {
    + int L_current_line = * current_line_p;
    + int L_current_col = * current_col_p;
    + int L_mayclear = * mayclear_p;
    + int L_start_of_line = * start_of_line_p;
    + int L_printing = * printing_p;
    +
    + int LINES, COLUMNS;
    +
    + menu_get_sizes(print_area, &LINES, &COLUMNS);
    +
    + if (L_current_col < COLUMNS) {
    +
    + if (L_current_line < LINES) {
    +
    + menu_MoveCursor(print_area,L_current_line,L_current_col);
    +
    + if (L_mayclear) {
    + menu_CleartoEOLN(print_area);
    +
    + }
    +
    + } else {
    + if (L_printing) {
    + DPRINT(Debug,12,(&Debug,"qd_draw_eoln: Gone out of screen, LINES=%d\n",
    + LINES));
    + L_printing = 0;
    + }
    + }
    +
    + if (!L_start_of_line) {
    +
    + if (L_printing) {
    + menu_Writechar(print_area,'\r');
    + menu_Writechar(print_area,'\n');
    + }
    +
    + L_current_line++;
    + }
    +
    + } else {
    + DPRINT(Debug,12,(&Debug,"qd_draw_eoln: L_current_col = %d >= COLUMNS = %d\n",
    + L_current_col,COLUMNS));
    + }
    +
    + L_mayclear = 0;
    + L_start_of_line = 1;
    + L_current_col = 0;
    +
    + while (empty_line > 0) {
    + empty_line--;
    +
    + if (L_current_line < LINES) {
    + menu_ClearLine(print_area,L_current_line);
    + } else {
    +
    + if (L_printing) {
    + DPRINT(Debug,12,(&Debug,"qd_draw_eoln: Gone out of screen, LINES=%d\n",
    + LINES));
    + L_printing = 0;
    + }
    + }
    +
    + L_current_line ++;
    + }
    +
    +
    + DPRINT(Debug,12,(&Debug,"qd_draw_eoln: "));
    +
    + if (* current_line_p != L_current_line) {
    + DPRINT(Debug,12,(&Debug, " * current_line_p = %d => %d",
    + * current_line_p,L_current_line));
    +
    + * current_line_p = L_current_line;
    + }
    +
    + if (* current_col_p != L_current_col) {
    + DPRINT(Debug,12,(&Debug, " * current_col_p = %d => %d",
    + * current_col_p,L_current_col));
    +
    + * current_col_p = L_current_col;
    + }
    +
    + if (* mayclear_p != L_mayclear) {
    + DPRINT(Debug,12,(&Debug, " * mayclear_p = %d => %d",
    + * mayclear_p,L_mayclear));
    +
    + * mayclear_p = L_mayclear;
    + }
    +
    + if (* start_of_line_p != L_start_of_line) {
    + DPRINT(Debug,12,(&Debug, " * start_of_line_p = %d => %d",
    + * start_of_line_p,L_start_of_line));
    +
    + * start_of_line_p = L_start_of_line;
    + }
    +
    + if (* printing_p != L_printing) {
    + DPRINT(Debug,12,(&Debug," * printing_p = %d => %d",
    + * printing_p,L_printing));
    +
    + * printing_p = L_printing;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + }
    +
    +
    + static int qd_exceed_or_printing P_((struct menu_context * print_area,
    + int * exceed_p,
    + int * current_line_p,
    + int * printing_p,
    + const int top_line));
    + static int qd_exceed_or_printing(print_area,
    + exceed_p,current_line_p,printing_p,
    + top_line)
    + struct menu_context * print_area;
    + int * exceed_p;
    + int * current_line_p;
    + int * printing_p;
    + const int top_line;
    + {
    + int ret = 0;
    + int L_exceed = * exceed_p;
    + int L_current_line = * current_line_p;
    + int L_printing = * printing_p;
    +
    + int LINES, COLUMNS;
    +
    + menu_get_sizes(print_area,&LINES, &COLUMNS);
    +
    + if (L_exceed)
    + L_exceed--;
    + else if (L_current_line >= top_line &&
    + L_current_line < LINES) {
    +
    + ret = 1;
    +
    + } else if (L_current_line >= LINES) {
    + if (L_printing) {
    + DPRINT(Debug,12,(&Debug,"qd_exceed_or_printing: Gone out of screen, LINES=%d\n",
    + LINES));
    + L_printing = 0;
    + }
    + } else {
    + L_current_line++;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"qd_exceed_or_printing=%d",ret));
    +
    + if (* exceed_p != L_exceed) {
    + DPRINT(Debug,12,(&Debug," * exceed_p = %d => %d",
    + * exceed_p,L_exceed));
    + * exceed_p = L_exceed;
    + }
    +
    + if (* current_line_p != L_current_line) {
    + DPRINT(Debug,12,(&Debug," * current_line_p = %d => %d",
    + * current_line_p,L_current_line));
    + * current_line_p = L_current_line;
    + }
    +
    + if (* printing_p != L_printing) {
    + DPRINT(Debug,12,(&Debug," * printing_p = %d => %d",
    + * printing_p,L_printing));
    +
    + * printing_p = L_printing;
    + }
    +
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + return ret;
    + }
    +
    +
    + static int qd_draw_text P_((struct menu_context * print_area,
    + int * current_line_p,
    + int * current_col_p,
    + int * mayclear_p,
    + int * joined_line_p,
    + int * start_of_line_p,
    + const struct string * s1));
    + static int qd_draw_text(print_area,
    + current_line_p,current_col_p,
    + mayclear_p,joined_line_p,
    + start_of_line_p,s1)
    + struct menu_context * print_area;
    + int * current_line_p;
    + int * current_col_p;
    + int * mayclear_p;
    + int * joined_line_p;
    + int * start_of_line_p;
    + const struct string * s1;
    + {
    + int ret = 0;
    +
    + int L_current_line = * current_line_p;
    + int L_current_col = * current_col_p;
    + int L_mayclear = * mayclear_p;
    + int L_joined_line = * joined_line_p;
    + int L_start_of_line = * start_of_line_p;
    +
    + int pos = 0;
    +
    + enum span_result span_res = span_ok;
    +
    + int s1_len = string_len(s1);
    +
    + int LINES, COLUMNS;
    +
    + menu_get_sizes(print_area,&LINES, &COLUMNS);
    +
    + DPRINT(Debug,12,(&Debug, "qd_draw_text: s1=%S\n",s1));
    +
    + while (span_res >= span_ok && span_EOS != span_res &&
    + pos < s1_len
    + ) {
    + int new_line = 0;
    + int old_pos UNUSED_VAROK = pos;
    +
    +
    + span_res = span_words(print_area,
    + L_current_line,&L_current_col,s1,
    + &pos,&L_mayclear,
    + 0 /* Flags */,
    + COLUMNS /* max width */,
    + s1_len /* max_len */,
    + L_joined_line,
    + 0 /* p_start_COL */,
    + 0 /* p_width -- no limit */,
    + 1 /* wrap_indicator */);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_text: pos=%d => %d span_res=%d ",
    + old_pos,pos,span_res));
    +
    + switch (span_res) {
    + case span_failure: DPRINT(Debug,12,(&Debug,"failure"));
    + if (L_start_of_line) {
    + DPRINT(Debug,12,(&Debug,"\n"));
    + goto fail;
    + }
    + new_line = 1; break;
    + case span_ok: DPRINT(Debug,12,(&Debug,"ok")); break;
    + case span_FF_seen: DPRINT(Debug,12,(&Debug,"span_FF_seen"));
    + new_line = 1; break;
    + case span_EOS: DPRINT(Debug,12,(&Debug,"span_EOS")); break;
    + case span_NL_seen: DPRINT(Debug,12,(&Debug,"span_NL_seen"));
    + new_line = 1; break;
    + case span_wrapping: DPRINT(Debug,12,(&Debug,"span_wrapping"));
    + new_line = 1; break;
    + case span_wordwrapped: DPRINT(Debug,12,(&Debug,"span_wordwrapped"));
    + new_line = 1; break;
    + }
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + L_start_of_line = 0;
    + L_joined_line = 1;
    +
    + if (L_mayclear) {
    + menu_CleartoEOLN(print_area);
    + L_mayclear = 0;
    + }
    +
    + if (new_line) {
    + if (L_current_line >= LINES-1)
    + goto fail;
    +
    + menu_Writechar(print_area,'\r');
    + menu_Writechar(print_area,'\n');
    +
    + L_current_line++;
    + L_current_col = 0;
    + L_mayclear = 1;
    + L_start_of_line = 1;
    + }
    + }
    +
    + ret = pos >= s1_len;
    +
    + fail:
    +
    + DPRINT(Debug,12,(&Debug,"qd_draw_text=%d: ",ret));
    +
    + if (* current_line_p != L_current_line) {
    + DPRINT(Debug,12,(&Debug, " * current_line_p = %d => %d",
    + * current_line_p,L_current_line));
    +
    + * current_line_p = L_current_line;
    + }
    +
    + if (* current_col_p != L_current_col) {
    + DPRINT(Debug,12,(&Debug, " * current_col_p = %d => %d",
    + * current_col_p,L_current_col));
    +
    + * current_col_p = L_current_col;
    + }
    +
    + if (* mayclear_p != L_mayclear) {
    + DPRINT(Debug,12,(&Debug, " * mayclear_p = %d => %d",
    + * mayclear_p,L_mayclear));
    +
    + * mayclear_p = L_mayclear;
    + }
    +
    + if (* joined_line_p != L_joined_line) {
    + DPRINT(Debug,12,(&Debug, " * joined_line_p = %d => %d",
    + * joined_line_p,L_joined_line));
    +
    + * joined_line_p = L_joined_line;
    + }
    +
    + if (* start_of_line_p != L_start_of_line) {
    + DPRINT(Debug,12,(&Debug, " * start_of_line_p = %d => %d",
    + * start_of_line_p,L_start_of_line));
    +
    + * start_of_line_p = L_start_of_line;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + return ret;
    + }
    +
    + static void gd_top_reset_start_line P_((int *virtual_start_line,
    + int top_offset,int add_to_top,
    + int add));
    + static void gd_top_reset_start_line(virtual_start_line,top_offset,
    + add_to_top,add)
    + int *virtual_start_line;
    + int top_offset;
    + int add_to_top;
    + int add;
    + {
    + int L_virtual_start_line = *virtual_start_line;
    +
    + /* If block is before current top_quotarootl,
    + then it's virtual_start_line < current top_offset
    + */
    +
    + DPRINT(Debug,12,(&Debug,"gd_top_reset_start_line: "));
    +
    + if (L_virtual_start_line >= top_offset) {
    +
    + DPRINT(Debug,12,(&Debug," top_offset=%d",top_offset));
    +
    + /* Reset data */
    +
    + L_virtual_start_line = 0;
    +
    + } else if (add_to_top) {
    +
    + DPRINT(Debug,12,(&Debug," add=%d",add));
    +
    + /* This may cause that
    +
    + L_virtual_start_line >= qd->top_offset
    +
    + but
    +
    + top_offset is incremented later
    + */
    + L_virtual_start_line += add;
    + }
    +
    + if (*virtual_start_line != L_virtual_start_line) {
    + DPRINT(Debug,12,(&Debug," *virtual_start_line = %d => %d",
    + *virtual_start_line,L_virtual_start_line));
    +
    + *virtual_start_line = L_virtual_start_line;
    + }
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + }
    +
    + static void qd_top_reset_quotarootl P_((struct mail_quota_list_display *mqld, + int top_offset,int add_to_top,
    + int add));
    + static void qd_top_reset_quotarootl(mqld,top_offset,add_to_top,add)
    + struct mail_quota_list_display *mqld;
    + int top_offset;
    + int add_to_top;
    + int add;
    + {
    + /* If struct mail_quota_list_display is before current top_quotarootl,
    + then it's virtual_ql_start_line < current top_offset
    +
    +
    + This may cause that
    +
    + qd-> mail_quota_list[i].mail_quotarootl_list[j].virtual_ql_start_line + >= qd->top_offset
    +
    + but
    +
    + qd->top_offset is incremented later
    + */
    +
    + gd_top_reset_start_line(& (mqld->virtual_ql_start_line),
    + top_offset,add_to_top,add);
    +
    + gd_top_reset_start_line(& (mqld->virtual_tb_start_line),
    + top_offset,add_to_top,add);
    +
    +
    + }
    +
    + static void qd_top_reset_quota P_((struct mail_quota_display *mqd,
    + int top_offset,
    + int add_to_top,
    + int add));
    +
    + static void qd_top_reset_quota(mqd,top_offset,add_to_top,add)
    + struct mail_quota_display *mqd;
    + int top_offset;
    + int add_to_top;
    + int add;
    + {
    + /* If struct mail_quota_display is before current top_mail_quota,
    + then it's virtual_mq_start_line < current top_offset
    + */
    +
    + if (mqd->virtual_mq_start_line >= top_offset) {
    +
    + /* Reset data */
    +
    + mqd->virtual_mq_start_line = 0;
    +
    + } else if (add_to_top) {
    + /* This may cause that
    +
    + qd-> mail_quota_list[i].virtual_mq_start_line >= qd->top_offset
    +
    + but
    +
    + qd->top_offset is incremented later
    + */
    +
    + mqd->virtual_mq_start_line += add;
    + }
    +
    + if (mqd->mail_quotarootl_list) {
    + size_t j;
    +
    + for (j = 0; j < mqd->mail_quotarootl_count; j++) {
    +
    + qd_top_reset_quotarootl(& (mqd->mail_quotarootl_list[j]),
    + top_offset,add_to_top,add);
    + }
    + }
    +
    + }
    +
    + static void qd_draw_to_start_line P_((struct menu_context * print_area,
    + int * current_line_p,
    + int * printing_p,
    + const int start_line,
    + const int top_line));
    + static void qd_draw_to_start_line(print_area,
    + current_line_p,printing_p,
    + start_line,top_line)
    + struct menu_context * print_area;
    + int * current_line_p;
    + int * printing_p;
    + const int start_line;
    + const int top_line;
    + {
    + int L_current_line = * current_line_p;
    + int L_printing = * printing_p;
    +
    + int LINES, COLUMNS;
    +
    + menu_get_sizes(print_area,&LINES, &COLUMNS);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_to_start_line: L_current_line=%d L_printing=%d start_line=%d top_line=%d\n",
    + L_current_line,L_printing,start_line,top_line));
    +
    + while (L_current_line < start_line &&
    + L_current_line < LINES) {
    +
    + if (L_current_line >= top_line &&
    + L_current_line < LINES) {
    +
    + if (!L_printing) {
    + DPRINT(Debug,12,(&Debug,"qd_draw_to_start_line: Gone to printing area, top_line=%d\n",
    + top_line));
    + L_printing = 1;
    + }
    +
    + menu_ClearLine(print_area,L_current_line);
    +
    + }
    +
    + L_current_line++;
    + }
    +
    + if (L_current_line >= LINES &&
    + L_current_line < start_line) {
    +
    + if (L_printing) {
    + DPRINT(Debug,12,(&Debug,"qd_draw_to_start_line: Gone out of screen, LINES=%d\n",
    + LINES));
    + L_printing = 0;
    + }
    +
    + L_current_line = start_line;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"qd_draw_to_start_line:"));
    +
    + if (* current_line_p != L_current_line) {
    + DPRINT(Debug,12,(&Debug," * current_line_p = %d => %d",
    + * current_line_p,L_current_line));
    + * current_line_p = L_current_line;
    + }
    +
    + if (* printing_p != L_printing) {
    + DPRINT(Debug,12,(&Debug," * printing_p = %d => %d",
    + * printing_p,L_printing));
    +
    + * printing_p = L_printing;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + }
    +
    + static int virtual_start_set P_((int current_line,int top_line,
    + int *virtual_start_line, int top_offset));
    +
    + static int virtual_start_set(current_line,top_line,virtual_start_line,top_offset)
    + int current_line;
    + int top_line;
    + int *virtual_start_line;
    + int top_offset;
    + {
    + int L_virtual_start_line = *virtual_start_line;
    + int ret;
    +
    + DPRINT(Debug,12,(&Debug,
    + "virtual_start_set: current_line=%d top_line=%d L_virtual_start_line=%d top_offset=%d\n",
    + current_line,top_line,L_virtual_start_line,top_offset));
    +
    + if (L_virtual_start_line > 0) {
    + ret = 1;
    + } else {
    + L_virtual_start_line = top_offset + current_line - top_line;
    +
    + ret = 0;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"virtual_start_set=%d:",ret));
    + if (*virtual_start_line != L_virtual_start_line) {
    + DPRINT(Debug,12,(&Debug," *virtual_start_line = %d => %d",
    + *virtual_start_line,L_virtual_start_line));
    +
    + *virtual_start_line = L_virtual_start_line;
    + }
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + return ret;
    + }
    +
    + static int qd_start_line P_((int current_line,int top_line,
    + int *virtual_start_line, int top_offset,
    + int add));
    + static int qd_start_line(current_line,top_line,virtual_start_line,
    + top_offset,add)
    + int current_line;
    + int top_line;
    + int *virtual_start_line;
    + int top_offset;
    + int add;
    + {
    + int L_virtual_start_line = *virtual_start_line;
    + int start_line;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_start_line: current_line=%d top_line=%d L_virtual_start_line=%d top_offset=%d add=%d\n",
    + current_line,top_line,L_virtual_start_line,top_offset,add));
    +
    + if (current_line < top_line + L_virtual_start_line - top_offset &&
    + add > 0) {
    +
    + L_virtual_start_line += add;
    +
    + }
    +
    + start_line = top_line + L_virtual_start_line - top_offset;
    +
    + DPRINT(Debug,12,(&Debug,"qd_start_line=%d: ",start_line));
    +
    + if (*virtual_start_line != L_virtual_start_line) {
    + DPRINT(Debug,12,(&Debug," *virtual_start_line = %d => %d",
    + *virtual_start_line,L_virtual_start_line));
    +
    + *virtual_start_line = L_virtual_start_line;
    + }
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + return start_line;
    + }
    +
    + static void qd_update_start_line P_((int current_line,
    + int * start_line,
    + int * virtual_start_line,
    + int * add));
    + static void qd_update_start_line(current_line,start_line,virtual_start_line,add)
    + int current_line;
    + int * start_line;
    + int * virtual_start_line;
    + int * add;
    + {
    + int L_start_line = * start_line;
    + int L_virtual_start_line = * virtual_start_line;
    + int L_add = * add;
    +
    + DPRINT(Debug,12,(&Debug, "qd_update_start_line: current_line=%d",
    + current_line));
    +
    + if (current_line > L_start_line) {
    +
    + int diff = current_line - L_start_line;
    +
    + DPRINT(Debug,12,(&Debug, " diff=%d",diff));
    +
    + if (L_virtual_start_line > 0) {
    +
    + L_add += diff;
    +
    + }
    +
    + L_virtual_start_line += diff;
    +
    + L_start_line += diff;
    + }
    +
    + if (* start_line != L_start_line) {
    + DPRINT(Debug,12,(&Debug, " * start_line = %d => %d",
    + * start_line,L_start_line));
    +
    + * start_line = L_start_line;
    + }
    +
    + if (* virtual_start_line != L_virtual_start_line) {
    + DPRINT(Debug,12,(&Debug, " * virtual_start_line = %d => %d",
    + * virtual_start_line,L_virtual_start_line));
    +
    + * virtual_start_line = L_virtual_start_line;
    + }
    +
    + if (* add != L_add) {
    + DPRINT(Debug,12,(&Debug, " * add = %d => %d",
    + * add,L_add));
    +
    + * add = L_add;
    + }
    +
    + DPRINT(Debug,12,(&Debug, "\n"));
    + }
    +
    + static int top_start_reached P_((const int top_offset,
    + const int add,
    + int * before_top_p,
    + const int add_to_top,
    + int * virtual_start_line_p,
    + int * exceed_p
    + ));
    + static int top_start_reached(top_offset,add,before_top_p,
    + add_to_top,virtual_start_line_p,exceed_p)
    + const int top_offset;
    + const int add;
    + int * before_top_p;
    + const int add_to_top;
    + int * virtual_start_line_p;
    + int * exceed_p;
    + {
    + int L_before_top = * before_top_p;
    + int L_virtual_start_line = * virtual_start_line_p;
    + int L_exceed = * exceed_p;
    + int ret = 0;
    +
    + int the_add = 0;
    +
    + if (add_to_top && add > 0)
    + the_add = add;
    +
    + if (L_before_top) {
    +
    + if (L_virtual_start_line > 0) {
    +
    + if (L_virtual_start_line + the_add >= top_offset) {
    + DPRINT(Debug,12,(&Debug,"top_start_reached: L_virtual_start_line=%d (add %d) reached\n",
    + L_virtual_start_line,the_add));
    +
    + L_before_top = 0;
    + L_exceed = 0;
    + ret = 1;
    +
    + } else {
    +
    + L_virtual_start_line += the_add;
    + L_exceed = top_offset - L_virtual_start_line;
    +
    + }
    + } else {
    + DPRINT(Debug,12,(&Debug,"top_start_reached: L_virtual_start_line not set, assuming that it is reached\n"));
    +
    + L_before_top = 0;
    + L_exceed = 0;
    + ret = 1;
    + }
    +
    + } else {
    + ret = 1;
    + L_exceed = 0;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"top_start_reached=%d",ret));
    +
    + if (* before_top_p != L_before_top) {
    + DPRINT(Debug,12,(&Debug," * before_top_p=%d => %d",
    + * before_top_p,L_before_top));
    +
    + * before_top_p = L_before_top;
    + }
    +
    + if (* virtual_start_line_p != L_virtual_start_line) {
    + DPRINT(Debug,12,(&Debug,"* virtual_start_line_p=%d => %d",
    + * virtual_start_line_p,L_virtual_start_line));
    +
    + * virtual_start_line_p = L_virtual_start_line;
    + }
    +
    + if (* exceed_p != L_exceed) {
    + DPRINT(Debug,12,(&Debug," * exceed_p=%d => %d",
    + * exceed_p,L_exceed));
    +
    + * exceed_p = L_exceed;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    +
    + return ret;
    + }
    +
    + enum qd_column {
    + qd_quotaroot,
    + qd_resource,
    + qd_usage,
    + qd_limit,
    + qd_percent };
    +
    + static struct resize_columns {
    +
    + int quotaroot_width;
    + int resource_width;
    + int usage_width;
    + int limit_width;
    + int percent_width;
    +
    + } NULL_resize_columns = {
    + 0,0,0,0,0
    + };
    +
    + enum qd_setup_mode { qd_setup_change = 0, qd_setup_initial = 1 };
    +
    + static void qd_setup_columns P_((struct menu_context *ptr,
    + struct menu_param *list,
    + enum qd_setup_mode initial,
    + struct resize_columns * resize
    + ));
    +
    +
    + enum qd_align { qd_align_left, qd_align_center, qd_align_rigth };
    +
    +
    + static void qd_reach_col P_((struct menu_context * print_area,
    + int * current_line_p,
    + const int col,
    + int * start_of_line_p
    + ));
    + static void qd_reach_col(print_area,current_line_p,col,start_of_line_p)
    + struct menu_context * print_area;
    + int * current_line_p;
    + const int col;
    + int * start_of_line_p;
    + {
    + int L_current_col = * current_line_p;
    + int L_start_of_line = * start_of_line_p;
    +
    + int LINES, COLUMNS;
    +
    + menu_get_sizes(print_area,&LINES, &COLUMNS);
    +
    + if ( L_current_col < col && L_current_col < COLUMNS) {
    +
    + L_start_of_line = 0;
    +
    + while (L_current_col < col && L_current_col < COLUMNS) {
    + menu_Writechar(print_area,' ');
    + L_current_col++;
    + }
    +
    +
    + }
    +
    + DPRINT(Debug,12,(&Debug,"qd_reach_col:"));
    +
    +
    + if (* current_line_p != L_current_col) {
    + DPRINT(Debug,12,(&Debug,
    + " * current_line_p = %d => %d",
    + * current_line_p,L_current_col));
    +
    + * current_line_p = L_current_col;
    + }
    +
    + if (* start_of_line_p != L_start_of_line) {
    + DPRINT(Debug,12,(&Debug,
    + " * start_of_line_p = %d => %d",
    + * start_of_line_p,L_start_of_line));
    + * start_of_line_p = L_start_of_line;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + }
    +
    +
    + static void qd_draw_cell P_((struct menu_context * print_area,
    + const enum qd_column column,
    + int * current_line_p,
    + int * current_col_p,
    + int * redrawing_p,
    + struct string * text,
    + struct resize_columns * resize,
    + struct menu_param * list,
    + const int text_flags,
    + const enum qd_align align,
    + int * mayclear_p,
    + int * start_of_line_p
    + ));
    + static void qd_draw_cell(print_area,column,current_line_p,current_col_p,
    + redrawing_p,text,resize,list,text_flags,align,
    + mayclear_p,start_of_line_p)
    + struct menu_context * print_area;
    + const enum qd_column column;
    + int * current_line_p;
    + int * current_col_p;
    + int * redrawing_p;
    + struct string * text;
    + struct resize_columns * resize;
    + struct menu_param * list;
    + const int text_flags;
    + const enum qd_align align;
    + int * mayclear_p;
    + int * start_of_line_p;
    + {
    + int L_current_line = * current_line_p;
    + int L_current_col = * current_col_p;
    + int L_redrawing = * redrawing_p;
    + int L_mayclear = * mayclear_p;
    + int L_start_of_line = * start_of_line_p;
    +
    + int LINES, COLUMNS;
    +
    + menu_get_sizes(print_area,&LINES, &COLUMNS);
    +
    + if (L_current_line < LINES && L_current_col < COLUMNS) {
    + int width = COLUMNS - L_current_col;
    + int col = L_current_col;
    + const char * col_name UNUSED_VAROK = "??";
    +
    + menu_MoveCursor(print_area, L_current_line,L_current_col);
    +
    + switch (column) {
    + case qd_quotaroot:
    + col_name = "quotaroot";
    + col = 0;
    + width = mp_lookup_integer(list,qd_disp_quotaroot_width);
    + break;
    + case qd_resource:
    + col_name = "resource";
    + col = mp_lookup_integer(list,qd_disp_resource_col);
    + width = mp_lookup_integer(list,qd_disp_resource_width);
    + break;
    + case qd_usage:
    + col_name = "usage";
    + col = mp_lookup_integer(list,qd_disp_usage_col);
    + width = mp_lookup_integer(list,qd_disp_usage_width);
    + break;
    + case qd_limit:
    + col_name = "limit";
    + col = mp_lookup_integer(list,qd_disp_usage_col) +
    + mp_lookup_integer(list,qd_disp_usage_width) + 1;
    + width = mp_lookup_integer(list,qd_disp_limit_width);
    + break;
    + case qd_percent:
    + col_name = "percent";
    + col = mp_lookup_integer(list,qd_disp_percent_col);
    + width = mp_lookup_integer(list,qd_disp_percent_width);
    + break;
    + }
    +
    + if (L_current_col <= col) {
    + int L = string_len(text);
    + int visible_len = 0;
    + int tail_len = 0;
    + int temp UNUSED_VAROK;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: column=%d %s col=%d width=%d, text len=%d text=%S\n",
    + column,col_name,col,width,L,text));
    +
    + if (L_current_col < col && L_current_col < COLUMNS) {
    +
    + qd_reach_col(print_area,&L_current_col,col,&L_start_of_line); +
    + }
    +
    + if ((temp = L_current_col + width) > COLUMNS) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: Overflow L_current_col %d + width %d = %d > COLUMNS %d -- width=%d",
    + L_current_col,width,temp,COLUMNS,width));
    +
    + width = COLUMNS - L_current_col;
    + DPRINT(Debug,12,(&Debug," => %d\n",
    + width));
    + }
    +
    + menu_StartXX(print_area,text_flags);
    +
    + if (L > 0 && width > 0) {
    + int pos = 0;
    + char * tail = "";
    +
    +
    + struct string * S =
    + curses_printable_clip(text,&pos,L,
    + &visible_len,width);
    +
    + if (S) {
    +
    + int need = visible_len + ( L - pos ); /* Not correct actually */
    +
    + if (pos < L && width > 3) {
    + free_string(&S);
    + pos = 0;
    +
    + S =
    + curses_printable_clip(text,&pos,L,
    + &visible_len,width);
    +
    + tail = "...";
    + tail_len = 3;
    + } else if (pos == L && visible_len < width) {
    + int fill = 0;
    + int x;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: visible_len=%d < width=%d align=%d",
    + visible_len,width,align));
    + switch (align) {
    + case qd_align_left:
    + DPRINT(Debug,12,(&Debug," qd_align_left"));
    + fill = 0;
    + break;
    + case qd_align_center:
    + DPRINT(Debug,12,(&Debug," qd_align_center"));
    + fill = (width - visible_len) /2;
    + break;
    + case qd_align_rigth:
    + DPRINT(Debug,12,(&Debug," qd_align_rigth"));
    + fill = width - visible_len;
    + break;
    + }
    +
    + DPRINT(Debug,12,(&Debug," fill=%d",fill));
    +
    + if (fill > 0) {
    + DPRINT(Debug,12,(&Debug,
    + " L_current_col=%d",
    + L_current_col));
    + for (x = 0; x < fill; x++) {
    + menu_Writechar(print_area,' ');
    + L_current_col++;
    + }
    +
    + DPRINT(Debug,12,(&Debug," => %d",L_current_col)); + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + }
    +
    + if (visible_len > 0) {
    + menu_Write_to_screen(print_area,
    + FRM("%S"),S);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: L_current_col=%d",
    + L_current_col));
    +
    + L_start_of_line = 0;
    + L_current_col += visible_len;
    +
    + DPRINT(Debug,12,(&Debug," => %d column=%d %s text=%S\n",
    + L_current_col,column,col_name,S));
    +
    + }
    +
    + free_string(&S);
    +
    + if (need > width) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: need=%d > width=%d",
    + need,width));
    +
    + switch (column) {
    + case qd_quotaroot:
    + if (resize) {
    + DPRINT(Debug,12,(&Debug,
    + ", resize quotaroot_width=%d",resize->quotaroot_width));
    + if (need > resize->quotaroot_width) {
    + resize->quotaroot_width = need;
    + DPRINT(Debug,12,(&Debug," => %d",resize->quotaroot_width));
    + L_redrawing = 1;
    + }
    + }
    + break;
    + case qd_resource:
    + if (resize) {
    + DPRINT(Debug,12,(&Debug,
    + ", resize resource_width=%d",resize->resource_width));
    + if (need > resize->resource_width) {
    + resize->resource_width = need;
    + DPRINT(Debug,12,(&Debug," => %d",resize->resource_width));
    + L_redrawing = 1;
    + }
    + }
    + break;
    + case qd_usage:
    + if (resize) {
    + DPRINT(Debug,12,(&Debug,
    + ", resize usage_width=%d",resize->usage_width));
    + if (need > resize->usage_width) {
    + resize->usage_width = need;
    + DPRINT(Debug,12,(&Debug," => %d",resize->usage_width));
    + L_redrawing = 1;
    + }
    + }
    + break;
    + case qd_limit:
    + if (resize) {
    + DPRINT(Debug,12,(&Debug,
    + ", resize limit_width=%d",resize->limit_width));
    + if (need > resize->limit_width) {
    + resize->limit_width = need;
    + DPRINT(Debug,12,(&Debug," => %d",resize->limit_width));
    + }
    + }
    + break;
    + case qd_percent:
    + break;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + }
    +
    +
    + } else if (width >= 3) {
    + tail = "-?-";
    + tail_len = 3;
    + }
    +
    + if (tail && tail_len > 0 && width >= visible_len + tail_len) {
    +
    + menu_PutLine0(print_area,L_current_line,L_current_col,tail);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: L_current_col=%d",
    + L_current_col));
    +
    + L_start_of_line = 0;
    + L_current_col += tail_len;
    +
    + DPRINT(Debug,12,(&Debug," => %d column=%d %s tail=%s\n", + L_current_col,column,col_name,tail));
    +
    + }
    +
    +
    + if (L_current_col < col + width) {
    +
    + L_start_of_line = 0;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: L_current_col=%d",
    + L_current_col));
    +
    + while (L_current_col < col + width) {
    + menu_Writechar(print_area,' ');
    + L_current_col++;
    + }
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",L_current_col));
    + }
    +
    + } else if (L_current_col >= COLUMNS) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: Overflow L_current_col=%d >= COLUMNS=%d column=%d %s\n",
    + L_current_col,COLUMNS,column,col_name));
    + }
    +
    +
    + menu_EndXX(print_area,text_flags);
    +
    +
    + } else {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_cell: Overflow L_current_col=%d > col=%d column=%d %s\n",
    + L_current_col,col,column,col_name));
    + }
    +
    + } else {
    +

    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)