Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r6f6330b r1490327  
    9090}
    9191
     92/* Append normal, uncolored text specified by format string to 'f' */
     93void owl_fmtext_appendf_normal(owl_fmtext *f, char *fmt, ...)
     94{
     95  va_list ap;
     96  char *buff;
     97
     98  va_start(ap, fmt);
     99  buff = g_strdup_vprintf(fmt, ap);
     100  va_end(ap);
     101  if (!buff)
     102    return;
     103  owl_fmtext_append_attr(f, buff, OWL_FMTEXT_ATTR_NONE, OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT);
     104}
     105
    92106/* Append normal text 'text' to 'f' with color 'color' */
    93107void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int fgcolor, int bgcolor)
     
    169183
    170184/* Internal function.  Append text from 'in' between index 'start' and
    171  * 'stop' to the end of 'f'
     185 * 'stop', inclusive, to the end of 'f'. This function works with
     186 * bytes.
    172187 */
    173188void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop) /*noproto*/
     
    474489        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff);
    475490      }
     491      else if (chwidth > 1) {
     492        /* Last char is wide, truncate. */
     493        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);
     494        owl_fmtext_append_normal(out, "\n");
     495      }
    476496      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         }
     497        /* Last char fits perfectly, We skip to the next char and back
     498         * up a byte to make sure we get it all.
     499         */
     500        ptr_c = g_utf8_next_char(ptr_c);
     501        _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);
    486502      }
    487503    }
     
    763779 * If format_fn is specified, passes it the list element value
    764780 * and it will return a string which this needs to free. */
    765 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*))
     781void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(char *))
    766782{
    767783  int i, size;
    768   void *elem;
     784  char *elem;
    769785  char *text;
    770786
Note: See TracChangeset for help on using the changeset viewer.