- Timestamp:
- Mar 27, 2007, 10:04:10 PM (16 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 61abb18
- Parents:
- 702aee7
- git-author:
- Nelson Elhage <nelhage@mit.edu> (03/27/07 22:04:03)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (03/27/07 22:04:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
message.c
r963542b ra387d12e 13 13 static const char fileIdent[] = "$Id$"; 14 14 15 static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE]; 16 static owl_fmtext_cache * fmtext_cache_next = fmtext_cache; 17 18 void owl_message_init_fmtext_cache () 19 { 20 int i; 21 for(i = 0; i < OWL_FMTEXT_CACHE_SIZE; i++) { 22 owl_fmtext_init_null(&(fmtext_cache[i].fmtext)); 23 fmtext_cache[i].message = NULL; 24 } 25 } 26 27 owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/ 28 { 29 if(fmtext_cache_next->message != NULL) { 30 owl_message_invalidate_format(fmtext_cache_next->message); 31 } 32 owl_fmtext_cache * f = fmtext_cache_next; 33 fmtext_cache_next++; 34 if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE) 35 fmtext_cache_next = fmtext_cache; 36 return f; 37 } 38 15 39 void owl_message_init(owl_message *m) 16 40 { … … 19 43 m->delete=0; 20 44 m->zwriteline=NULL; 21 m->invalid_format=1;22 45 23 46 owl_message_set_hostname(m, ""); … … 29 52 m->timestr[strlen(m->timestr)-1]='\0'; 30 53 31 /* initialize the fmtext */ 32 owl_fmtext_init_null(&(m->fmtext)); 54 m->fmtext = NULL; 33 55 } 34 56 … … 106 128 void owl_message_invalidate_format(owl_message *m) 107 129 { 108 m->invalid_format=1; 130 if(m->fmtext) { 131 m->fmtext->message = NULL; 132 owl_fmtext_clear(&(m->fmtext->fmtext)); 133 m->fmtext=NULL; 134 } 109 135 } 110 136 … … 112 138 { 113 139 owl_message_format(m); 114 return(&(m->fmtext ));140 return(&(m->fmtext->fmtext)); 115 141 } 116 142 … … 120 146 owl_view *v; 121 147 122 if (m->invalid_format) { 148 if (!m->fmtext) { 149 m->fmtext = owl_message_next_fmtext(); 150 m->fmtext->message = m; 123 151 /* for now we assume there's just the one view and use that style */ 124 152 v=owl_global_get_current_view(&g); 125 153 s=owl_view_get_style(v); 126 154 127 owl_fmtext_free(&(m->fmtext)); 128 owl_fmtext_init_null(&(m->fmtext)); 129 owl_style_get_formattext(s, &(m->fmtext), m); 130 m->invalid_format=0; 155 owl_style_get_formattext(s, &(m->fmtext->fmtext), m); 131 156 } 132 157 } … … 392 417 char *owl_message_get_text(owl_message *m) 393 418 { 394 return(owl_fmtext_get_text(&(m->fmtext )));419 return(owl_fmtext_get_text(&(m->fmtext->fmtext))); 395 420 } 396 421 … … 437 462 if (m == NULL) return(0); 438 463 owl_message_format(m); 439 return(owl_fmtext_num_lines(&(m->fmtext )));464 return(owl_fmtext_num_lines(&(m->fmtext->fmtext))); 440 465 } 441 466 … … 504 529 owl_fmtext_init_null(&b); 505 530 506 owl_fmtext_truncate_lines(&(m->fmtext ), aline, bline-aline+1, &a);531 owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a); 507 532 owl_fmtext_truncate_cols(&a, acol, bcol, &b); 508 533 if (fgcolor!=OWL_COLOR_DEFAULT) { … … 698 723 owl_message_format(m); /* is this necessary? */ 699 724 700 return (owl_fmtext_search(&(m->fmtext ), string));725 return (owl_fmtext_search(&(m->fmtext->fmtext), string)); 701 726 } 702 727 … … 989 1014 owl_list_free_simple(&(m->attributes)); 990 1015 991 owl_ fmtext_free(&(m->fmtext));992 } 1016 owl_message_invalidate_format(m); 1017 }
Note: See TracChangeset
for help on using the changeset viewer.