Changeset e0e0e5a
- Timestamp:
- Jul 31, 2010, 7:11:42 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- c93b8b5
- Parents:
- 6772d19
- git-author:
- David Benjamin <davidben@mit.edu> (07/25/10 17:35:41)
- git-committer:
- David Benjamin <davidben@mit.edu> (07/31/10 19:11:42)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmtext.c
r6772d19 re0e0e5a 175 175 } 176 176 177 /* Internal function. Append text from 'in' between index 'start' and178 * 'stop', inclusive, to the end of 'f'. This function works with179 * bytes.177 /* Internal function. Append text from 'in' between index 'start' 178 * inclusive and 'stop' exclusive, to the end of 'f'. This function 179 * works with bytes. 180 180 */ 181 181 static void _owl_fmtext_append_fmtext(owl_fmtext *f, const owl_fmtext *in, int start, int stop) … … 194 194 /* We will reset to defaults after appending the text. We may need 195 195 to set initial attributes. */ 196 newlen=strlen(f->textbuff)+(stop-start +1) + (4 * (a + fg + bg)) + 12;196 newlen=strlen(f->textbuff)+(stop-start) + (4 * (a + fg + bg)) + 12; 197 197 _owl_fmtext_realloc(f, newlen); 198 198 … … 207 207 g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff)); 208 208 209 strncat(f->textbuff, in->textbuff+start, stop-start +1);209 strncat(f->textbuff, in->textbuff+start, stop-start); 210 210 211 211 /* Reset attributes */ … … 402 402 ptr2 = strchr(ptr1, '\n'); 403 403 if (!ptr2) { 404 _owl_fmtext_append_fmtext(out, in, offset, (in->textlen) - 1); 404 /* Copy to the end of the buffer. */ 405 _owl_fmtext_append_fmtext(out, in, offset, in->textlen); 405 406 return(-1); 406 407 } 407 _owl_fmtext_append_fmtext(out, in, offset, (ptr2 - ptr1) + offset); 408 /* Copy up to, and including, the new line. */ 409 _owl_fmtext_append_fmtext(out, in, offset, (ptr2 - ptr1) + offset + 1); 408 410 ptr1 = ptr2 + 1; 409 411 } … … 475 477 owl_fmtext_append_spaces(out, padding); 476 478 if (ptr_c == ptr_e) { 477 /* We made it to the newline. */478 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff );479 /* We made it to the newline. Append up to, and including it. */ 480 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff + 1); 479 481 } 480 482 else if (chwidth > 1) { 481 483 /* Last char is wide, truncate. */ 482 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);484 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff); 483 485 owl_fmtext_append_normal(out, "\n"); 484 486 } 485 487 else { 486 /* Last char fits perfectly, We skip to the next char and back 487 * up a byte to make sure we get it all. 488 */ 488 /* Last char fits perfectly, We stop at the next char to make 489 * sure we get it all. */ 489 490 ptr_c = g_utf8_next_char(ptr_c); 490 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff - 1);491 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff); 491 492 } 492 493 }
Note: See TracChangeset
for help on using the changeset viewer.