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

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

    + int start_of_line = 1;
    +
    + qd_draw_quotaroot_name(print_area,qr,
    + &L_current_line,
    + &current_col,&L_redrawing,
    + resize,list,
    + &mayclear,&start_of_line);
    +
    + qd_draw_eoln(print_area,&L_current_line,&current_col,
    + &mayclear,&start_of_line,&L_printing,0);
    +
    + }
    +
    + }
    +
    + if (status_text) {
    +
    + if (qd_exceed_or_printing(print_area,
    + &exceed,&L_current_line,&L_printing,
    + qd->top_line)) {
    +
    + int current_col = 0;
    + int mayclear = 1;
    + int start_of_line = 1;
    + int joined_line = 0;
    +
    + int col = mp_lookup_integer(list,qd_disp_resource_col);
    +
    + qd_draw_quotaroot_name(print_area,qr,
    + &L_current_line,
    + &current_col,&L_redrawing,
    + resize,list,
    + &mayclear,&start_of_line);
    +
    + if (current_col <= col) {
    +
    + qd_reach_col(print_area,&current_col,col,&start_of_line);
    +
    + }
    +
    +
    + if (!qd_draw_text(print_area,&L_current_line,&current_col,
    + &mayclear,&joined_line,&start_of_line,
    + status_text))
    + goto fail6;
    +
    +
    + qd_draw_eoln(print_area,&L_current_line,&current_col,
    + &mayclear,&start_of_line,&L_printing,0);
    +
    + }
    +
    + fail6:
    + free_string(&status_text);
    + }
    +
    + if (qr_name)
    + free_string(&qr_name);
    + free_mail_quotaroot(&qr);
    + } else if (cd && is_canceled(cd)) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_mail_quota: Update canceled\n"));
    + break;
    + }
    + }
    +
    + } else {
    +
    + if (qd_exceed_or_printing(print_area,
    + &exceed,&L_current_line,&L_printing,qd->top_line)) {
    +
    + struct string * s5 = format_string(CATGETS(elm_msg_cat, MeSet,
    + MeQuotaNotAvailable,
    + "Mail quota not available"));
    + int current_col = 0;
    +
    + int mayclear = 1;
    + int joined_line = 0;
    + int start_of_line = 1;
    +
    + if (!qd_draw_text(print_area,&L_current_line,&current_col,
    + &mayclear,&joined_line,&start_of_line,
    + s5))
    + goto fail5;
    +
    + qd_draw_eoln(print_area,&L_current_line,&current_col, + &mayclear,&start_of_line,&L_printing,1); +
    + fail5:
    + free_string(&s5);
    +
    + }
    + }
    +
    + free_string(&qr_NA);
    + L_add_line = 1;
    + }
    +
    +
    + if (cd && is_canceled(cd)) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_mail_quota: Update canceled\n"));
    + break;
    + }
    + }
    + }
    +
    +
    + /* ----- */
    +
    + DPRINT(Debug,12,(&Debug,"qd_draw_mail_quota:"));
    +
    + if (* add_p != L_add) {
    + DPRINT(Debug,12,(&Debug," * add_p=%d => %d",
    + * add_p,L_add));
    +
    + * add_p = L_add;
    + }
    +
    + if (* current_line_p != L_current_line) {
    + DPRINT(Debug,12,(&Debug," * current_line_p=%p => %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 ;
    + }
    +
    + if (* redrawing_p != L_redrawing) {
    + DPRINT(Debug,12,(&Debug," * redrawing_p=%d => %d",
    + * redrawing_p,L_redrawing));
    +
    + * redrawing_p = L_redrawing ;
    + }
    +
    + 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 ( * add_line_p != L_add_line ) {
    + DPRINT(Debug,12,(&Debug," * add_line_p=%d => %d",
    + * add_line_p,L_add_line));
    +
    + * add_line_p = L_add_line;
    + }
    +
    + DPRINT(Debug,12,(&Debug,"\n"));
    + }
    +
    + static void qd_set_top_quotarootl P_((struct quota_display * qd));
    + static void qd_set_top_quotarootl(qd)
    + struct quota_display * qd;
    + {
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qd_set_top_quotarootl",
    + "Bad magic number (quota_diplay)",0);
    +
    + qd->top_quotarootl = 0;
    +
    + if (qd->top_mail_quota < qd->mail_quota_count) {
    +
    + size_t i;
    +
    + for (i = 0;
    + i < qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_count; + i++) {
    +
    + if (0 == qd->mail_quota_list[qd->top_mail_quota].
    + mail_quotarootl_list[i].
    + virtual_ql_start_line)
    + break;
    +
    + if (qd->top_offset >=
    + qd->mail_quota_list[qd->top_mail_quota].
    + mail_quotarootl_list[i].
    + virtual_ql_start_line) {
    +
    + qd->top_quotarootl = i;
    +
    + } else
    + break;
    + }
    + }
    + }
    +
    + static void qd_change_page P_((struct quota_display * qd,
    + enum qd_step_mode qd_step,
    + int lines));
    + static void qd_change_page(qd,qd_step,lines)
    + struct quota_display * qd;
    + enum qd_step_mode qd_step;
    + int lines;
    + {
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qd_change_page",
    + "Bad magic number (quota_diplay)",0);
    +
    + switch (qd_step) {
    + case qd_step_prev:
    + if (qd->top_offset > 0) {
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_offset=%d",qd->top_offset)); +
    + qd->top_offset -= lines;
    + if (qd->top_offset < 0)
    + qd->top_offset = 0;
    +
    + DPRINT(Debug,10,(&Debug," => %d lines=%d\n",qd->top_offset,lines));
    + }
    +
    + if (qd->top_mail_quota > 0) {
    +
    + if (/* 1) Out of range */
    + qd->top_mail_quota >= qd->mail_quota_count ||
    + /* 2) virtual_mq_start_line not set */
    + 0 == qd->mail_quota_list[qd->top_mail_quota].virtual_mq_start_line ||
    + /* 3) Top offset is before start of this */
    + qd->top_offset < qd->mail_quota_list[qd->top_mail_quota].virtual_mq_start_line) {
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_mail_quota=%zu",qd->top_mail_quota));
    +
    + while (qd->top_mail_quota > 0 &&
    + (qd->top_mail_quota >= qd->mail_quota_count ||
    + 0 == qd->mail_quota_list[qd->top_mail_quota].virtual_mq_start_line ||
    + qd->top_offset < qd->mail_quota_list[qd->top_mail_quota].virtual_mq_start_line)) {
    + qd->top_mail_quota--;
    + }
    +
    + DPRINT(Debug,10,(&Debug," => %zu",qd->top_mail_quota));
    +
    + qd_set_top_quotarootl(qd);
    +
    + DPRINT(Debug,10,(&Debug,", top_quotarootl=%zu\n",qd->top_quotarootl));
    +
    + } else
    + goto check_current_1;
    +
    + } else {
    + check_current_1:
    +
    + if (qd->top_mail_quota < qd->mail_quota_count) {
    +
    + if (qd->top_quotarootl > 0) {
    +
    + if (/* 1) Out of range */
    + qd->top_quotarootl >= qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_count ||
    + /* virtual_ql_start_line not set */
    + 0 == qd->mail_quota_list[qd->top_mail_quota].
    + mail_quotarootl_list[qd->top_quotarootl].virtual_ql_start_line ||
    + /* 3) Top offset is before start of this */
    + qd->top_offset < qd->mail_quota_list[qd->top_mail_quota].
    + mail_quotarootl_list[qd->top_quotarootl].virtual_ql_start_line) {
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_mail_quota=%zu, top_quotarootl=%zu",
    + qd->top_mail_quota,qd->top_quotarootl));
    +
    + while (qd->top_quotarootl > 0 &&
    + (qd->top_quotarootl >= qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_count ||
    + 0 == qd->mail_quota_list[qd->top_mail_quota].
    + mail_quotarootl_list[qd->top_quotarootl].virtual_ql_start_line ||
    + qd->top_offset <= qd->mail_quota_list[qd->top_mail_quota].
    + mail_quotarootl_list[qd->top_quotarootl].virtual_ql_start_line)) {
    + qd->top_quotarootl--;
    + }
    +
    + DPRINT(Debug,10,(&Debug," => %zu\n",qd->top_quotarootl));
    +
    + }
    + }
    +
    + } else if (qd->top_quotarootl > 0) {
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_mail_quota=%zu, top_quotarootl=%zu",
    + qd->top_mail_quota,qd->top_quotarootl));
    + qd->top_quotarootl = 0;
    + DPRINT(Debug,10,(&Debug," => %zu\n",qd->top_quotarootl));
    + }
    + }
    +
    +
    + break;
    + case qd_step_this: break;
    +
    + case qd_step_next:
    + if (!qd->is_end) {
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_offset=%d",qd->top_offset));
    + qd->top_offset += lines;
    + DPRINT(Debug,10,(&Debug," => %d LINES=%d\n",qd->top_offset,lines));
    + }
    +
    + if (qd->top_mail_quota < qd->mail_quota_count-1) {
    +
    + size_t mq;
    + size_t new_top_mq = qd->top_mail_quota;
    +
    + for (mq = qd->top_mail_quota + 1; mq < qd->mail_quota_count; mq++) {
    + if (0 == qd->mail_quota_list[mq].virtual_mq_start_line)
    + break;
    + if (qd->mail_quota_list[mq].virtual_mq_start_line <= qd->top_offset)
    + new_top_mq = mq;
    + else
    + break;
    + }
    +
    + if (new_top_mq > qd->top_mail_quota) {
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_mail_quota=%zu",qd->top_mail_quota));
    + qd->top_mail_quota = new_top_mq;
    +
    + DPRINT(Debug,10,(&Debug," => %zu",qd->top_mail_quota));
    +
    + qd_set_top_quotarootl(qd);
    +
    + DPRINT(Debug,10,(&Debug,", top_quotarootl=%zu\n",qd->top_quotarootl));
    + } else
    + goto check_current_2;
    + } else {
    +
    +
    + check_current_2:
    +
    + if (qd->top_mail_quota < qd->mail_quota_count) {
    + if (qd->top_quotarootl < qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_count-1) {
    + size_t qrl;
    + size_t new_top_qrl = qd->top_quotarootl;
    +
    + for (qrl = qd->top_quotarootl +1; qrl < qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_count; qrl++) {
    + if (0 == qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_list[qrl].virtual_ql_start_line)
    + break;
    + if (qd->mail_quota_list[qd->top_mail_quota].mail_quotarootl_list[qrl].virtual_ql_start_line <=
    + qd->top_offset)
    + new_top_qrl = qrl;
    + else
    + break;
    + }
    +
    + if (new_top_qrl > qd->top_quotarootl) {
    + DPRINT(Debug,10,(&Debug,
    + "qd_chnage_page: top_mail_quota=%zu, top_quotarootl=%zu",
    + qd->top_mail_quota,qd->top_quotarootl));
    + qd->top_quotarootl = new_top_qrl;
    + DPRINT(Debug,10,(&Debug," => %zu\n",qd->top_quotarootl));
    + }
    + }
    + } else if (qd->top_quotarootl > 0) {
    + DPRINT(Debug,10,(&Debug,
    + "qd_change_page: top_mail_quota=%zu, top_quotarootl=%zu",
    + qd->top_mail_quota,qd->top_quotarootl));
    + qd->top_quotarootl = 0;
    + DPRINT(Debug,10,(&Debug," => %zu\n",qd->top_quotarootl));
    + }
    + }
    +
    + break;
    +
    + }
    + }
    +
    +
    + static void qd_draw_forward P_((struct menu_context * print_area,
    + struct quota_display * qd,
    + enum qd_step_mode qd_step,
    + int add,
    + int current_line,
    + struct cancel_data * cd,
    + struct menu_param * list));
    + static void qd_draw_forward(print_area,qd, qd_step, add, current_line,cd,list)
    + struct menu_context * print_area;
    + struct quota_display * qd;
    + enum qd_step_mode qd_step;
    + int add;
    + int current_line;
    + struct cancel_data * cd;
    + struct menu_param * list;
    + {
    + int add_to_top = 0;
    + int printing = 0;
    +
    + int LINES, COLUMNS;
    +
    + int redrawing = 0;
    + int redraw_current_line = current_line;
    +
    + struct resize_columns resize_cols = NULL_resize_columns;
    +
    + menu_get_sizes(print_area,&LINES, &COLUMNS);
    +
    + if (QUOTA_DISPLAY_magic != qd->magic)
    + panic("MBX PANIC",__FILE__,__LINE__,
    + "qd_draw_forward",
    + "Bad magic number (quota_diplay)",0);
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_draw_forward: add = %d\n",
    + add));
    +
    + if (current_line <= qd->top_line &&
    + add > 0) {
    + add_to_top = 1;
    + }
    +
    + /* Increment virtual_mq_start_line and virtual_ql_start_line
    + for display which is before top
    + */
    +
    + if (qd->mail_quota_list) {
    + size_t i;
    +
    + for (i = 0; i < qd-> mail_quota_count && i < qd->top_mail_quota; i++) {
    +
    + qd_top_reset_quota(& (qd-> mail_quota_list[i]),
    + qd->top_offset,add_to_top,add);
    + }
    +
    + if (qd->top_mail_quota < qd-> mail_quota_count) {
    +
    + const size_t i = qd->top_mail_quota;
    +
    + if (qd-> mail_quota_list[i].mail_quotarootl_list) {
    + size_t j;
    +
    + for (j = 0; j < qd-> mail_quota_list[i].mail_quotarootl_count &&
    + j < qd->top_quotarootl; j++) {
    +
    + qd_top_reset_quotarootl(& (qd-> mail_quota_list[i].mail_quotarootl_list[j]),
    + qd->top_offset,add_to_top,add);
    + }
    + }
    + }
    + }
    +
    + if (add_to_top) {
    + qd->top_offset += add;
    + printing = 1;
    + }
    +
    + if (current_line < 0) {
    + DPRINT(Debug,10,(&Debug,
    + "qd_draw_forward: current_line=%d RESETTING\n",
    + current_line));
    +
    + current_line = 0;
    + }
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_draw_forward: qd_step = %d",qd_step));
    + switch (qd_step) {
    + case qd_step_prev: DPRINT(Debug,10,(&Debug," qd_step_prev")); break;
    + case qd_step_this: DPRINT(Debug,10,(&Debug," qd_step_this")); break;
    + case qd_step_next: DPRINT(Debug,10,(&Debug," qd_step_this")); break;
    + }
    + DPRINT(Debug,10,(&Debug,"\n"));
    +
    + qd_change_page(qd,qd_step,LINES);
    +
    + qd->is_end = 0;
    +
    + do {
    + int before_top = 0;
    + int add_line = 0;
    +
    + if (redrawing) {
    + redrawing = 0;
    + printing = 0;
    +
    + current_line = redraw_current_line;
    + add = 0;
    +
    + if (current_line <= qd->top_line && current_line < LINES)
    + printing = 1;
    +
    + DPRINT(Debug,10,(&Debug,
    + "qd_draw_forward: current_line=%d printing=%d REDRAWING\n",
    + current_line,printing));
    +
    + qd_setup_columns(print_area,list,qd_setup_change,&resize_cols);
    +
    + } else {
    + redraw_current_line = current_line;
    +
    + }
    +
    + if (qd->mail_quota_list) {
    + if (qd->top_mail_quota < qd-> mail_quota_count) {
    + size_t i;
    +
    + qd_draw_mail_quota(print_area,qd,qd->top_mail_quota,qd->top_quotarootl,
    + &add,&current_line,&printing,&redrawing,&before_top,
    + add_to_top,cd,&resize_cols,list,&add_line); +
    + if (cd && is_canceled(cd)) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_forward: Update canceled\n"));
    + break;
    + }
    +
    + for (i = qd->top_mail_quota+1; i < qd-> mail_quota_count; i++) {
    + qd_draw_mail_quota(print_area,qd,i,0,
    + &add,&current_line,&printing,&redrawing,&before_top,
    + add_to_top,cd,&resize_cols,list,&add_line);
    +
    + if (cd && is_canceled(cd)) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_forward: Update canceled\n"));
    + break;
    + }
    + }
    + }
    + }
    +
    + if (cd && is_canceled(cd)) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_draw_forward: Update canceled\n"));
    + break;
    + }
    +
    + } while (redrawing);
    +
    + if (current_line < LINES && printing && !qd->is_end) {
    +
    + DPRINT(Debug,12,(&Debug,"qd_draw_forward: End of a mail quota screen\n"));
    +
    + qd->is_end = 1;
    +
    + }
    +
    + while (current_line < LINES) {
    + if (current_line >= qd->top_line) {
    + if (!printing) {
    + DPRINT(Debug,12,(&Debug,"qd_draw_forward: Gone to printing area on end of page, top_line=%d\n",
    + qd->top_line));
    + printing = 1;
    + }
    +
    + menu_ClearLine(print_area,current_line);
    + }
    +
    + current_line++;
    + }
    +
    + }
    +
    +
    + static int qd_step_len P_((int width, int step));
    + static int qd_step_len(width,step)
    + int width;
    + int step;
    + {
    + int a = width+1;
    +
    + if (a < step)
    + a = step;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_step_len=%d: width=%d step=%d\n",
    + a,width,step));
    +
    + return a;
    + }
    +
    + static void qd_setup_columns(ptr,list,initial,resize)
    + struct menu_context *ptr;
    + struct menu_param *list;
    + enum qd_setup_mode initial;
    + struct resize_columns * resize;
    + {
    + int LINES, COLUMNS;
    +
    + int step;
    +
    + menu_get_sizes(ptr,&LINES, &COLUMNS);
    +
    + step = COLUMNS/4;
    +
    + if (step < 5) {
    + step = 5;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: COLUMNS=%d step=%d\n",
    + COLUMNS,step));
    + } else if (step > max_column_step) {
    + step = max_column_step;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: COLUMNS=%d step=%d\n",
    + COLUMNS,step));
    + }
    +
    + switch (initial) {
    + int x;
    +
    + case qd_setup_initial:
    +
    + /* Quotaroot column */
    +
    + if (resize && resize->quotaroot_width > 0) {
    +
    + mp_list_set_integer(list,qd_disp_quotaroot_width,resize->quotaroot_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_quotaroot_width: %d\n", + resize->quotaroot_width));
    +
    + x = qd_step_len(resize->quotaroot_width,step);
    +
    +
    + } else {
    +
    + mp_list_set_integer(list,qd_disp_quotaroot_width,default_quotaroot_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_quotaroot_width: %d\n", + default_quotaroot_width));
    +
    + x = qd_step_len(default_quotaroot_width,step);
    +
    + }
    +
    + /* Resource column */
    +
    + mp_list_set_integer(list,qd_disp_resource_col,x);
    +
    + if (resize && resize->resource_width > 0) {
    +
    + mp_list_set_integer(list,qd_disp_resource_width,resize->resource_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_resource_width: %d\n", + resize->resource_width));
    +
    + x += qd_step_len(resize->resource_width,step);
    +
    + } else {
    +
    + mp_list_set_integer(list,qd_disp_resource_width,default_resource_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_resource_width: %d\n", + default_resource_width));
    +
    + x += qd_step_len(default_resource_width,step);
    +
    + }
    +
    + /* usage/limit columns */
    +
    + mp_list_set_integer(list,qd_disp_usage_col,x);
    +
    + if (resize) {
    + int usage_width = default_usage_width;
    + int limit_width = default_limit_width;
    +
    + if (resize->usage_width > 0)
    + usage_width = resize->usage_width;
    + if (resize->limit_width > 0)
    + limit_width = resize->limit_width;
    +
    + mp_list_set_integer(list,qd_disp_usage_width,usage_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_usage_width: %d\n",
    + usage_width));
    +
    + mp_list_set_integer(list,qd_disp_limit_width,limit_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_limit_width: %d\n",
    + limit_width));
    +
    + x += qd_step_len(usage_width+limit_width+1,step);
    +
    + } else {
    + mp_list_set_integer(list,qd_disp_usage_width,default_usage_width); +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_usage_width: %d\n",
    + default_usage_width));
    +
    + mp_list_set_integer(list,qd_disp_limit_width,default_limit_width); +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_limit_width: %d\n",
    + default_limit_width));
    +
    + x += qd_step_len(default_usage_width+default_limit_width+1,step);
    + }
    +
    + /* percent column */
    +
    + mp_list_set_integer(list,qd_disp_percent_col,x);
    +
    + if (resize && resize->percent_width) {
    + mp_list_set_integer(list,qd_disp_percent_width,resize->percent_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_percent_width: %d\n",
    + resize->percent_width));
    +
    + x += resize->percent_width;
    + } else {
    + mp_list_set_integer(list,qd_disp_percent_width,default_percent_width);
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: qd_disp_percent_width: %d\n",
    + default_percent_width));
    +
    + x += default_percent_width;
    + }
    +
    +
    + if (x >= COLUMNS) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: last column = %d >= COLUMNS = %d\n",
    + x,COLUMNS));
    + }
    +
    + break;
    +
    + case qd_setup_change: {
    +
    + int quotaroot_width = mp_lookup_integer(list,qd_disp_quotaroot_width); + int resource_width = mp_lookup_integer(list,qd_disp_resource_width);
    + int usage_width = mp_lookup_integer(list,qd_disp_usage_width);
    + int limit_width = mp_lookup_integer(list,qd_disp_limit_width);
    + int percent_width = mp_lookup_integer(list,qd_disp_percent_width);
    +
    + int resource_col = mp_lookup_integer(list,qd_disp_resource_col);
    + int usage_col = mp_lookup_integer(list,qd_disp_usage_col);
    + int percent_col = mp_lookup_integer(list,qd_disp_percent_col);
    +
    + int sum = quotaroot_width + resource_width + usage_width + limit_width + percent_width +4;
    +
    + int overflow = 0;
    + int reduce = 0;
    +
    + if (sum >= COLUMNS) {
    + reduce = sum-COLUMNS;
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: COLUMNS=%d total width = %d overflow, reduce=%d\n",
    + COLUMNS,sum,reduce));
    + overflow = 1;
    + }
    +
    + if (percent_col + percent_width >= COLUMNS) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: COLUMNS=%d percent_col=%d percent_width=%d overflow\n",
    + COLUMNS,percent_col,percent_width));
    + overflow = 1;
    + }
    +
    + if (usage_col+usage_width+1+limit_width+1 >= percent_col) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: percent_col=%d usage_col=%d usage_width=%d limit_width=%d overflow\n",
    + percent_col,usage_col,usage_width,limit_width));
    + overflow = 1;
    + }
    +
    + if (resource_col + resource_width +1 >= usage_col) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: usage_col=%d resource_col=%d resource_width=%d overflow\n",
    + usage_col,resource_col,resource_width));
    + overflow = 1;
    + }
    +
    + if (quotaroot_width+1 >= resource_col) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: resource_col=%d quotaroot_width=%d overflow\n",
    + quotaroot_width,resource_col));
    +
    + overflow = 1;
    + }
    +
    + if (resize && resize->quotaroot_width > 0) {
    + DPRINT(Debug,12,(&Debug,"qd_setup_columns: wanted quotaroot_width=%d => %d\n",
    + quotaroot_width, resize->quotaroot_width));
    +
    + overflow = 1;
    + }
    +
    + if (resize && resize->resource_width > 0) {
    + DPRINT(Debug,12,(&Debug,"qd_setup_columns: wanted resource_width=%d => %d\n",
    + resource_width,resize->resource_width));
    +
    + overflow = 1;
    + }
    +
    + if (resize && resize->usage_width > 0) {
    + DPRINT(Debug,12,(&Debug,"qd_setup_columns: wanted usage_width=%d => %d\n",
    + usage_width,resize->usage_width));
    +
    + overflow = 1;
    + }
    +
    + if (resize && resize->limit_width > 0) {
    + DPRINT(Debug,12,(&Debug,"qd_setup_columns: wanted limit_width=%d => %d\n",
    + limit_width,resize->limit_width));
    + overflow = 1;
    + }
    +
    + if (resize && resize->percent_width > 0) {
    + DPRINT(Debug,12,(&Debug,"qd_setup_columns: wanted percent_width=%d => %d\n",
    + percent_width,resize->percent_width));
    + overflow = 1;
    + }
    +
    + if (overflow) {
    +
    + int can_reduce = 0;
    +
    + if (reduce > 0) {
    +
    + DPRINT(Debug,12,(&Debug,"qd_setup_columns: can reduce"));
    +
    + if (quotaroot_width > default_quotaroot_width) {
    +
    + DPRINT(Debug,12,(&Debug," quotaroot_width"));
    +
    + can_reduce++;
    + }
    +
    + if (resource_width > default_resource_width) {
    + DPRINT(Debug,12,(&Debug," resource_width"));
    +
    + can_reduce++;
    + }
    +
    + if (usage_width > default_usage_width) {
    + DPRINT(Debug,12,(&Debug," usage_width"));
    +
    + can_reduce++;
    + }
    +
    + if (limit_width > default_limit_width) {
    + DPRINT(Debug,12,(&Debug," limit_width"));
    +
    + can_reduce++;
    + }
    +
    + if (percent_width > default_percent_width) {
    + DPRINT(Debug,12,(&Debug," percent_width"));
    +
    + can_reduce++;
    + }
    +
    + DPRINT(Debug,12,(&Debug,", count %d\n",
    + can_reduce));
    + }
    +
    +
    + /* Quotaroot column */
    +
    + if (reduce > 0 && quotaroot_width > default_quotaroot_width) {
    + int a = reduce;
    +
    + if (can_reduce > 0)
    + a = reduce / can_reduce;
    +
    + if (quotaroot_width < default_quotaroot_width+a)
    + a = quotaroot_width - default_quotaroot_width;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: quotaroot_width=%d",quotaroot_width));
    +
    + quotaroot_width -= a;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",quotaroot_width));
    + mp_list_set_integer(list,qd_disp_quotaroot_width,quotaroot_width);
    +
    + reduce -= a;
    +
    + if (can_reduce > 0)
    + can_reduce --;
    + } else if (resize && resize->quotaroot_width > 0) {
    + int a = 0;
    +
    + if (resize->quotaroot_width < quotaroot_width)
    + a = quotaroot_width - resize->quotaroot_width;
    + if (a > reduce)
    + a = reduce;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: quotaroot_width=%d",quotaroot_width));
    +
    + quotaroot_width = resize->quotaroot_width;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",quotaroot_width));
    + mp_list_set_integer(list,qd_disp_quotaroot_width,quotaroot_width);
    +
    + reduce -= a;
    + resize->quotaroot_width = 0;
    + }
    +
    + x = qd_step_len(quotaroot_width,step);
    +
    + /* Resource column */
    +
    + if (resource_col > x) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: resource_col=%d",resource_col));
    + resource_col = x;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",resource_col));
    + mp_list_set_integer(list,qd_disp_resource_col,resource_col);
    +
    + } else {
    + if (resource_col < quotaroot_width+1) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: resource_col=%d",resource_col));
    +
    + resource_col = quotaroot_width+1;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",resource_col));
    + mp_list_set_integer(list,qd_disp_resource_col,resource_col);
    + }
    +
    + x = resource_col;
    + }
    +
    + if (reduce > 0 && resource_width > default_resource_width) {
    + int a = reduce;
    +
    + if (can_reduce > 0)
    + a = reduce / can_reduce;
    +
    + if (resource_width < default_resource_width+a)
    + a = resource_width - default_resource_width;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: resource_width=%d",resource_width));
    +
    + resource_width -= a;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",resource_width));
    + mp_list_set_integer(list,qd_disp_resource_width,resource_width);
    +
    + reduce -= a;
    + if (can_reduce > 0)
    + can_reduce --;
    + } else if (resize && resize->resource_width > 0) {
    + int a = 0;
    +
    + if (resize->resource_width < resource_width)
    + a = resource_width - resize->resource_width;
    + if (a > reduce)
    + a = reduce;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: resource_width=%d",resource_width));
    +
    + resource_width = resize->resource_width;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",resource_width));
    + mp_list_set_integer(list,qd_disp_resource_width,resource_width);
    +
    + reduce -= a;
    + resize->resource_width = 0;
    + }
    +
    + x += qd_step_len(resource_width,step);
    +
    + /* usage/limit columns */
    +
    + if (usage_col > x) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: usage_col=%d",usage_col)); + usage_col = x;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",usage_col));
    + mp_list_set_integer(list,qd_disp_usage_col,usage_col);
    + } else {
    + if (usage_col < resource_col+resource_width+1) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: usage_col=%d",usage_col));
    +
    + usage_col = resource_col+resource_width+1;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",usage_col));
    + mp_list_set_integer(list,qd_disp_usage_col,usage_col);
    + }
    +
    + x = usage_col;
    + }
    +
    + if (reduce > 0 && usage_width > default_usage_width) {
    + int a = reduce;
    +
    + if (can_reduce > 0)
    + a = reduce / can_reduce;
    +
    + if (usage_width < default_usage_width+a)
    + a = usage_width - default_usage_width;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: usage_width=%d",usage_width));
    +
    + usage_width -= a;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",usage_width));
    + mp_list_set_integer(list,qd_disp_usage_width,usage_width);
    +
    + reduce -= a;
    + if (can_reduce > 0)
    + can_reduce--;
    + } else if (resize && resize->usage_width > 0) {
    + int a = 0;
    +
    + if (resize->usage_width < usage_width)
    + a = usage_width - resize->usage_width;
    + if (a > reduce)
    + a = reduce;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: usage_width=%d",usage_width));
    +
    + usage_width = resize->usage_width;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",usage_width));
    + mp_list_set_integer(list,qd_disp_usage_width,usage_width);
    +
    + reduce -= a;
    + resize->usage_width = 0;
    + }
    +
    + if (reduce > 0 && limit_width > default_limit_width) {
    + int a = reduce;
    +
    + if (can_reduce > 0)
    + a = reduce / can_reduce;
    +
    + if (limit_width < default_limit_width+a)
    + a = limit_width - default_limit_width;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: limit_width=%d",limit_width));
    +
    + limit_width -= a;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",limit_width));
    + mp_list_set_integer(list,qd_disp_limit_width,limit_width);
    +
    + reduce -= a;
    + if (can_reduce > 0)
    + can_reduce--;
    +
    + } else if (resize && resize->limit_width > 0) {
    + int a= 0;
    +
    + if (resize->limit_width < limit_width)
    + a = limit_width - resize->limit_width;
    + if (a > reduce)
    + a = reduce;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: limit_width=%d",limit_width));
    +
    + limit_width = resize->limit_width;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",limit_width));
    + mp_list_set_integer(list,qd_disp_limit_width,limit_width);
    +
    + reduce -= a;
    + resize->limit_width = 0;
    + }
    +
    + x += qd_step_len(usage_width+limit_width+1,step);
    +
    + /* percent column */
    +
    + if (percent_col > x) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: percent_col=%d",percent_col));
    + percent_col = x;
    +
    + DPRINT(Debug,12,(&Debug," => %d\n",percent_col));
    + mp_list_set_integer(list,qd_disp_percent_col,percent_col);
    + } else {
    + if (percent_col < usage_col+usage_width+1+limit_width+1) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: percent_col=%d",percent_col));
    +
    + percent_col = usage_col+usage_width+1+limit_width+1;
    + mp_list_set_integer(list,qd_disp_percent_col,percent_col); + }
    +
    + x = percent_col;
    + }
    +
    + if (reduce > 0 && percent_width > default_percent_width) {
    +
    + int a = reduce;
    +
    + if (percent_width < default_percent_width+a)
    + a = percent_width - default_percent_width;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: percent_width=%d",percent_width));
    +
    + percent_width -= a;
    + DPRINT(Debug,12,(&Debug," => %d\n",percent_width));
    + mp_list_set_integer(list,qd_disp_percent_width,percent_width); +
    + reduce -= a;
    + if (can_reduce > 0)
    + can_reduce--;
    +
    + } else if (resize && resize->percent_width > 0) {
    + int a = 0;
    +
    + if (resize->percent_width < percent_width)
    + a = percent_width - resize->percent_width;
    + if (a > reduce)
    + a = reduce;
    +
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: percent_width=%d",percent_width));
    +
    + percent_width = resize->percent_width;
    + DPRINT(Debug,12,(&Debug," => %d\n",percent_width));
    + mp_list_set_integer(list,qd_disp_percent_width,percent_width); +
    + reduce -= a;
    + resize->percent_width = 0;
    + }
    +
    +
    + if (x >= COLUMNS) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: last column = %d >= COLUMNS = %d\n",
    + x,COLUMNS));
    + }
    +
    + if (reduce > 0) {
    + DPRINT(Debug,12,(&Debug,
    + "qd_setup_columns: reduce = %d not available\n",
    + reduce));
    + }
    + }
    + }
    + break;
    + }
    + }
    +

    [continued in next message]

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