• Patch: Elm ME+ 2.5 PLalpha62 -> Elm ME+ 2.5 PLalpha63 [7/7] (2/4)

    From Kari Hurtta@21:1/5 to All on Wed Jan 3 13:53:51 2024
    [continued from previous message]

    + DPRINT(Debug,10,(&Debug,
    + "span_alt_data_helper: start of range (range changed) without range\n"));
    +
    + data->start_of_range = 0;
    + }
    +
    +
    + if (data->joined_line) {
    + DPRINT(Debug,10,(&Debug,
    + "span_alt_data_helper: this is joined line\n"));
    + }
    +
    +
    + switch (alt_data_type) {
    + case string_alt_none:
    + case string_alt_text:
    + goto out;
    +
    + case string_alt_entity: {
    +
    + /* Not very good ---- */
    +
    + if ( character_ok) {
    + charset_t utf8 = MIME_name_to_charset("UTF-8",0);
    +
    + if (*res_buffer)
    + free_string(res_buffer);
    + *res_buffer = new_string(utf8 ? utf8 : display_charset);
    +
    + /* This can fail silently */
    + add_unicode_to_string(*res_buffer,1,&ch);
    +
    + DPRINT(Debug,10,(&Debug,
    + "span_alt_data_helper: Set string\n"));
    +
    + DEBUG_PRINT_STRING(Debug,12,
    + "span_alt_data_helper: buffer = ",
    + " : buffer > ",
    + *res_buffer);
    +
    +
    +
    + } else {
    +
    + int ref_key_pg_flags = 0;
    + const struct string * ref_key =
    + out_entity_reference_key(alt_data_value.entity,
    + & ref_key_pg_flags);
    +
    + if (*res_buffer)
    + free_string(res_buffer);
    + *res_buffer = dup_string(ref_key);
    + *res_pg_flags |= ref_key_pg_flags;
    +
    + data->buffer_x = 0;
    +
    + DPRINT(Debug,10,(&Debug,
    + "span_alt_data_helper: Set string\n"));
    +
    + DEBUG_PRINT_STRING(Debug,12,
    + "span_alt_data_helper: buffer = ",
    + " : buffer > ",
    + *res_buffer);
    + }
    +
    + }
    + break;
    + }
    + }
    + break;
    + }
    +
    + out:
    +
    + DPRINT(Debug,9,(&Debug,"span_alt_data_helper = %d\n",
    + ret));
    +
    + return ret;
    + }
    +
    + enum span_result span_helper (ctx,pager_range,info,buffer,data)
    + struct menu_context * ctx;
    + struct pager_range * pager_range;
    + struct pg_wrap_info * info;
    + struct string * buffer;
    + struct span_helper_data * data;
    + {
    + enum span_result span_line_result = span_failure;
    +
    + int buffer_len = string_len(buffer);
    + int LINES, COLUMNS;
    + uint16 ch = 0; /* First character may be needed */
    + int L_mayclear;
    +
    + if (SPAN_HELPER_DATA_magic != data->magic)
    + panic("PAGER PANIC",__FILE__,__LINE__,
    + "span_helper",
    + "Bad magic number",0);
    +
    + L_mayclear = data->mayclear;
    +
    + menu_get_sizes(ctx, &LINES, &COLUMNS);
    +
    + if (buffer_len > 0)
    + ch = give_unicode_from_string(buffer,0);
    +
    +
    + switch(span_helper_prefix(ctx,pager_range,info,data,ch,&span_line_result)) {
    + case spanh_exit:
    +
    + DPRINT(Debug,9,(&Debug,"span_helper: "));
    +
    if (data->buffer_x >= buffer_len) {
    DPRINT(Debug,9,(&Debug,
    "no buffer left (buffer_x=%d buffer_len=%d), ",
    data->buffer_x,buffer_len));
    goto buffer_handled;
    }
    +
    + break;

    ! case spanh_main: {
    ! int center_cur_col = data->cur_col;
    ! int center_buffer_x = data->buffer_x;
    !
    ! int WP = /* pager_indicate_wrapping */ data->wrap_indicator;
    !
    ! int max_width = COLUMNS;
    !
    ! /* 3) Writes actual text */
    !
    if (data->start_of_line) {
    DPRINT(Debug,10,(&Debug,
    "span_helper: No pager range on beginning of line\n"));
    ***************
    *** 371,412 ****
    DPRINT(Debug,10,(&Debug,
    "span_helper: this is joined line\n"));
    }
    -
    - if (0 != (data->range_flags & PR_CENTER_THIS) &&
    - COLUMNS > buffer_len &&
    - data->p_start_COL == data->cur_col) {
    -
    - /* Does not work correctly with double with characters
    - also does not work with control characters
    - */
    -
    - int pos = (COLUMNS - buffer_len) / 2;
    -
    - if (pos > data->cur_col) {
    - DPRINT(Debug,10,(&Debug,
    - "span_helper: centering this line, col=%d => %d\n",
    - data->cur_col,pos));
    -
    -
    - /* Make sure that garbage from previous
    - output is not left */
    - if (L_mayclear) {
    - menu_MoveCursor(ctx,data->cur_line,data->cur_col);
    -
    - menu_CleartoEOLN(ctx);
    - L_mayclear = 0;
    - }
    -
    - menu_MoveCursor(ctx,data->cur_line,pos);
    - data->cur_col = pos;
    - data->p_start_COL = pos;
    - }
    - }
    -

    ! if (0 != (data->range_flags & PR_WORD_WRAP)
    ||
    ! (data->force_word_wrap && 0 == (data->range_flags & PR_PREFORMAT))
    ) {

    span_line_result = span_words(ctx,
    --- 674,683 ----
    DPRINT(Debug,10,(&Debug,
    "span_helper: this is joined line\n"));
    }

    ! if (ison(data->range_flags,PR_WORD_WRAP)
    ||
    ! (data->force_word_wrap && isoff(data->range_flags,PR_PREFORMAT))
    ) {

    span_line_result = span_words(ctx,
    ***************
    *** 414,424 ****
    buffer,&(data->buffer_x),
    &L_mayclear,
    data->this_flags,
    ! COLUMNS /* max_width*/,
    buffer_len /* max_len */,
    data->joined_line,
    data->p_start_COL,
    ! 0 == (data->range_flags &
    PR_MAX_WIDTH) ?
    data->p_width : 0,
    WP);
    --- 685,695 ----
    buffer,&(data->buffer_x),
    &L_mayclear,
    data->this_flags,
    ! max_width /* max_width*/,
    buffer_len /* max_len */,
    data->joined_line,
    data->p_start_COL,
    ! isoff(data->range_flags,
    PR_MAX_WIDTH) ?
    data->p_width : 0,
    WP);
    ***************
    *** 439