- Timestamp:
- Jun 25, 2003, 9:34:51 AM (21 years ago)
- 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:
- ceb8cfb
- Parents:
- ae0a5fc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
text.c
rdafd919 rab31454 6 6 static const char fileIdent[] = "$Id$"; 7 7 8 int owl_text_truncate_lines(char *out, char *in, int aline, int lines) { 8 int owl_text_truncate_lines(char *out, char *in, int aline, int lines) 9 { 9 10 /* start with line aline (where the first line is 1) and print 10 11 * 'lines' lines … … 43 44 } 44 45 45 void owl_text_truncate_cols(char *out, char *in, int acol, int bcol) { 46 void owl_text_truncate_cols(char *out, char *in, int acol, int bcol) 47 { 46 48 char *ptr1, *ptr2, *tmpbuff, *last; 47 49 int len; … … 89 91 90 92 91 void owl_text_indent(char *out, char *in, int n) { 93 void owl_text_indent(char *out, char *in, int n) 94 { 92 95 char *ptr1, *ptr2, *last; 93 96 int i; … … 113 116 114 117 115 int owl_text_num_lines(char *in) { 118 int owl_text_num_lines(char *in) 119 { 116 120 int lines, i; 117 121 … … 129 133 130 134 /* caller must free the return */ 131 char *owl_text_htmlstrip(char *in) { 135 char *owl_text_htmlstrip(char *in) 136 { 132 137 char *ptr1, *end, *ptr2, *ptr3, *out; 133 138 … … 186 191 return(out); 187 192 } 193 194 /* caller must free the return */ 195 char *owl_text_wordwrap(char *in, int col) 196 { 197 char *out; 198 int cur, lastspace, len, lastnewline; 199 200 out=owl_strdup(in); 201 len=strlen(in); 202 cur=0; 203 lastspace=-1; 204 lastnewline=-1; 205 206 while (cur<(len-1)) { 207 if (out[cur]==' ') { 208 lastspace=cur; 209 cur++; 210 continue; 211 } else if (out[cur]=='\n') { 212 lastnewline=cur; 213 cur++; 214 continue; 215 } 216 217 /* do we need to wrap? */ 218 if ( (cur-(lastnewline+1)) > col ) { 219 if (lastspace==-1 || 220 (lastnewline>0 && (lastspace<=lastnewline))) { 221 /* we can't help, sorry */ 222 cur++; 223 continue; 224 } 225 226 /* turn the last space into a newline */ 227 out[lastspace]='\n'; 228 lastnewline=lastspace; 229 lastspace=-1; 230 cur++; 231 continue; 232 } 233 234 cur++; 235 continue; 236 } 237 return(out); 238 }
Note: See TracChangeset
for help on using the changeset viewer.