- Timestamp:
- Dec 24, 2007, 2:53:11 AM (17 years ago)
- Branches:
- master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 762512d
- Parents:
- 5bc0f68
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmtext.c
rfa3290d r28ee32b 315 315 void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out) 316 316 { 317 char *ptr 1, *ptr2, *last;318 int len, offset;317 char *ptr_s, *ptr_e, *ptr_c, *last; 318 int col, cnt; 319 319 320 320 last=in->textbuff+in->textlen-1; 321 ptr 1=in->textbuff;322 while (ptr 1<=last) {323 ptr 2=strchr(ptr1, '\n');324 if (!ptr 2) {321 ptr_s=in->textbuff; 322 while (ptr_s<=last) { 323 ptr_e=strchr(ptr_s, '\n'); 324 if (!ptr_e) { 325 325 /* but this shouldn't happen if we end in a \n */ 326 326 break; 327 327 } 328 328 329 if (ptr 2==ptr1) {329 if (ptr_e==ptr_s) { 330 330 owl_fmtext_append_normal(out, "\n"); 331 ptr 1++;331 ptr_s++; 332 332 continue; 333 333 } 334 334 335 col = 0; 336 cnt = 0; 337 ptr_c = ptr_s; 338 while(col < bcol && ptr_c < ptr_e) { 339 gunichar c = g_utf8_get_char(ptr_c); 340 if (g_unichar_iswide(c)) { 341 if (col + 2 > bcol) break; 342 else col += 2; 343 } 344 else if (g_unichar_type(c) == G_UNICODE_NON_SPACING_MARK) ; /*do nothing*/ 345 /* We may need more special cases here... unicode spacing is hard. */ 346 else { 347 if (col + 1 > bcol) break; 348 else ++col; 349 } 350 ptr_c = g_utf8_next_char(ptr_c); 351 if (col >= acol) ++cnt; 352 if (col <= acol) ptr_s = ptr_c; 353 } 354 _owl_fmtext_append_fmtext(out, in, ptr_s - in->textbuff, ptr_c - in->textbuff); 355 ptr_s=ptr_e+1; 356 357 #if 0 335 358 /* we need to check that we won't run over here */ 336 359 len=bcol-acol; 337 if (len > (ptr 2-(ptr1+acol))) {360 if (len > (ptr_e-(ptr_s+acol))) { 338 361 /* the whole line fits with room to spare, don't take a full 'len' */ 339 len=ptr 2-(ptr1+acol);340 } 341 if (len>last-ptr 1) {362 len=ptr_e-(ptr_s+acol); 363 } 364 if (len>last-ptr_s) { 342 365 /* the whole rest of the text fits with room to spare, adjust for it */ 343 len-=(last-ptr 1);366 len-=(last-ptr_s); 344 367 } 345 368 if (len<=0) { 346 369 /* saftey check */ 347 370 owl_fmtext_append_normal(out, "\n"); 348 ptr 1=ptr2+1;371 ptr_s=ptr_e+1; 349 372 continue; 350 373 } 351 374 352 offset =ptr1-in->textbuff;375 offset = ptr_s - in->textbuff; 353 376 _owl_fmtext_append_fmtext(out, in, offset+acol, offset+acol+len); 354 377 355 ptr1=ptr2+1; 378 ptr_s=ptr_e+1; 379 #endif 356 380 } 357 381 }
Note: See TracChangeset
for help on using the changeset viewer.