Changeset 3a7cf49


Ignore:
Timestamp:
Jan 4, 2008, 2:31:55 PM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
6d77f1f
Parents:
830c36e
Message:
* Rework some logic in fmtext's column truncating code.
* fix what appears to be an off-by-one error, though I can't explain why
  it never manifested in trunk.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r987a93c r3a7cf49  
    399399 * ends at 'bcol' or sooner.  The first column is number 0.  The new
    400400 * message is placed in 'out'.  The message is * expected to end in a
    401  * new line for now
     401 * new line for now. NOTE: This needs to be modified to deal with
     402 * backing up if we find a SPACING COMBINING MARK at the end of a
     403 * line. If that happens, we should back up to the last non-mark
     404 * character and stop there.
    402405 */
    403406void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out)
     
    426429    chwidth = 0;
    427430    ptr_c = ptr_s;
    428     while(col <= bcol && ptr_c < ptr_e) {
     431    while(ptr_c < ptr_e) {
    429432      gunichar c = g_utf8_get_char(ptr_c);
    430433      if (!_owl_fmtext_is_format_char(c)) {
    431434        chwidth = mk_wcwidth(c);
    432      
    433         if (col + chwidth > bcol)
    434           break;
     435        if (col + chwidth > bcol) break;
     436       
    435437        if (col >= acol) {
    436438          if (st == 0) {
     
    448450      /* lead padding */
    449451      owl_fmtext_append_spaces(out, padding);
    450       if (ptr_c[0] & 0x80) {
    451         if (col + chwidth == bcol)
    452           ptr_c = g_utf8_next_char(ptr_c);
    453         _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - 1 - in->textbuff);     
    454         owl_fmtext_append_normal(out, "\n");
     452      if (ptr_c == ptr_e) {
     453        /* We made it to the newline. */
     454        owl_function_debugmsg("fmtc: reached newline");
     455        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
    455456      }
    456457      else {
    457         _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
     458        if (chwidth > 1) {
     459          /* Last char is wide, truncate. */
     460          owl_function_debugmsg("fmtc: truncating.");
     461          _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);
     462          owl_fmtext_append_normal(out, "\n");
     463        }
     464        else {
     465          /* Last char fits perfectly, leave alone.*/
     466          owl_function_debugmsg("fmtc: fits fine.");
     467          _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
     468        }
    458469      }
    459470    }
  • message.c

    r47519e1b r3a7cf49  
    535535  owl_fmtext_init_null(&b);
    536536 
    537   owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a);
     537  owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline, &a);
    538538  owl_fmtext_truncate_cols(&a, acol, bcol, &b);
    539539  owl_fmtext_colorize(&b, fgcolor);
Note: See TracChangeset for help on using the changeset viewer.