Changeset a0a5179 for fmtext.c


Ignore:
Timestamp:
Nov 19, 2003, 11:19:03 PM (20 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f1645da
Parents:
52f3507
Message:
blist works for AIM even if the zephyr .anyone can't be read
AIM Buddy debugging
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r252a5c2 ra0a5179  
    157157  for (i=0; i<nspaces; i++) {
    158158    owl_fmtext_append_normal(f, " ");
    159   }
    160 }
    161 
    162 /* requires that the list values are strings or NULL.
    163  * joins the elements together with join_with.
    164  * If format_fn is specified, passes it the list element value
    165  * and it will return a string which this needs to free. */
    166 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*))
    167 {
    168   int i, size;
    169   void *elem;
    170   char *text;
    171 
    172   size = owl_list_get_size(l);
    173   for (i=0; i<size; i++) {
    174     elem = (char*)owl_list_get_element(l,i);
    175     if (elem && format_fn) {
    176       text = format_fn(elem);
    177       if (text) {
    178         owl_fmtext_append_normal(f, text);
    179         owl_free(text);
    180       }
    181     } else if (elem) {
    182       owl_fmtext_append_normal(f, elem);
    183     }
    184     if ((i < size-1) && join_with) {
    185       owl_fmtext_append_normal(f, join_with);
    186     }
    187159  }
    188160}
     
    362334}
    363335
     336/* set the charater at 'index' to be 'char'.  If index is out of
     337 * bounds don't do anything */
    364338void owl_fmtext_set_char(owl_fmtext *f, int index, int ch)
    365339{
    366   /* set the charater at 'index' to be 'char'.  If index is out of
    367    * bounds don't do anything */
    368340  if ((index < 0) || (index > f->textlen-1)) return;
    369341  f->textbuff[index]=ch;
    370 }
    371 
    372 /* Free all memory allocated by the object */
    373 void owl_fmtext_free(owl_fmtext *f)
    374 {
    375   if (f->textbuff) owl_free(f->textbuff);
    376   if (f->fmbuff) owl_free(f->fmbuff);
    377   if (f->colorbuff) owl_free(f->colorbuff);
    378342}
    379343
     
    623587  }
    624588}
     589
     590/* requires that the list values are strings or NULL.
     591 * joins the elements together with join_with.
     592 * If format_fn is specified, passes it the list element value
     593 * and it will return a string which this needs to free. */
     594void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*))
     595{
     596  int i, size;
     597  void *elem;
     598  char *text;
     599
     600  size = owl_list_get_size(l);
     601  for (i=0; i<size; i++) {
     602    elem = (char*)owl_list_get_element(l,i);
     603    if (elem && format_fn) {
     604      text = format_fn(elem);
     605      if (text) {
     606        owl_fmtext_append_normal(f, text);
     607        owl_free(text);
     608      }
     609    } else if (elem) {
     610      owl_fmtext_append_normal(f, elem);
     611    }
     612    if ((i < size-1) && join_with) {
     613      owl_fmtext_append_normal(f, join_with);
     614    }
     615  }
     616}
     617
     618/* Free all memory allocated by the object */
     619void owl_fmtext_free(owl_fmtext *f)
     620{
     621  if (f->textbuff) owl_free(f->textbuff);
     622  if (f->fmbuff) owl_free(f->fmbuff);
     623  if (f->colorbuff) owl_free(f->colorbuff);
     624}
     625
Note: See TracChangeset for help on using the changeset viewer.