Changeset db1af5f for fmtext.c


Ignore:
Timestamp:
Jan 7, 2009, 5:28:19 PM (16 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
50f8932
Parents:
e2a620b
Message:
Fix a bug rendering multi-byte characters in the last column of the window.

When the last character on a line was not wide, the code assumed that
it consumed one byte. This caused multi-byte characters to render
improperly. Now we find the start of the next character to ensure we
get the whole thing. [Fixes: #56]

Reported by: andersk

Also, clarified some comments and did a bit of code hoisting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r2aaca94 rdb1af5f  
    169169
    170170/* Internal function.  Append text from 'in' between index 'start' and
    171  * 'stop' to the end of 'f'
     171 * 'stop', inclusive, to the end of 'f'. This function works with
     172 * bytes.
    172173 */
    173174void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop) /*noproto*/
     
    474475        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
    475476      }
     477      else if (chwidth > 1) {
     478        /* Last char is wide, truncate. */
     479        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);
     480        owl_fmtext_append_normal(out, "\n");
     481      }
    476482      else {
    477         if (chwidth > 1) {
    478           /* Last char is wide, truncate. */
    479           _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);
    480           owl_fmtext_append_normal(out, "\n");
    481         }
    482         else {
    483           /* Last char fits perfectly, leave alone.*/
    484           _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
    485         }
     483        /* Last char fits perfectly, We skip to the next char and back
     484         * up a byte to make sure we get it all.
     485         */
     486        ptr_c = g_utf8_next_char(ptr_c);
     487        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);
    486488      }
    487489    }
Note: See TracChangeset for help on using the changeset viewer.