- Timestamp:
- Jun 5, 2003, 2:26:51 PM (22 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:
- aac889a
- Parents:
- ae4cd12
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fmtext.c
rf2f9314 r5789230 5 5 static const char fileIdent[] = "$Id$"; 6 6 7 void owl_fmtext_init_null(owl_fmtext *f) { 7 void owl_fmtext_init_null(owl_fmtext *f) 8 { 8 9 f->textlen=0; 9 10 f->textbuff=owl_strdup(""); … … 15 16 16 17 17 void _owl_fmtext_set_attr(owl_fmtext *f, int attr, int first, int last) { 18 void _owl_fmtext_set_attr(owl_fmtext *f, int attr, int first, int last) 19 { 18 20 int i; 19 21 for (i=first; i<=last; i++) { … … 22 24 } 23 25 24 void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last) { 26 void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last) 27 { 25 28 int i; 26 29 for (i=first; i<=last; i++) { … … 29 32 } 30 33 31 void _owl_fmtext_set_color(owl_fmtext *f, int color, int first, int last) { 34 void _owl_fmtext_set_color(owl_fmtext *f, int color, int first, int last) 35 { 32 36 int i; 33 37 for (i=first; i<=last; i++) { … … 37 41 38 42 39 void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int color) { 43 void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int color) 44 { 40 45 int newlen; 41 46 … … 52 57 53 58 54 void owl_fmtext_append_normal(owl_fmtext *f, char *text) { 59 void owl_fmtext_append_normal(owl_fmtext *f, char *text) 60 { 55 61 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, OWL_COLOR_DEFAULT); 56 62 } 57 63 58 void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int color) { 64 void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int color) 65 { 59 66 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, color); 60 67 } 61 68 62 69 63 void owl_fmtext_append_bold(owl_fmtext *f, char *text) { 70 void owl_fmtext_append_bold(owl_fmtext *f, char *text) 71 { 64 72 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT); 65 73 } 66 74 67 75 68 void owl_fmtext_append_reverse(owl_fmtext *f, char *text) { 76 void owl_fmtext_append_reverse(owl_fmtext *f, char *text) 77 { 69 78 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE, OWL_COLOR_DEFAULT); 70 79 } 71 80 72 81 73 void owl_fmtext_append_reversebold(owl_fmtext *f, char *text) { 82 void owl_fmtext_append_reversebold(owl_fmtext *f, char *text) 83 { 74 84 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE | OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT); 75 85 } 76 86 77 87 78 void owl_fmtext_addattr(owl_fmtext *f, int attr) { 88 void owl_fmtext_addattr(owl_fmtext *f, int attr) 89 { 79 90 /* add the attribute to all text */ 80 91 int i, j; … … 86 97 } 87 98 88 void owl_fmtext_colorize(owl_fmtext *f, int color) { 99 void owl_fmtext_colorize(owl_fmtext *f, int color) 100 { 89 101 /* everywhere the color is OWL_COLOR_DEFAULT, change it to be 'color' */ 90 102 int i, j; … … 97 109 98 110 99 void owl_fmtext_append_ztext(owl_fmtext *f, char *text) { 111 void owl_fmtext_append_ztext(owl_fmtext *f, char *text) 112 { 100 113 int stacksize, curattrs, curcolor; 101 114 char *ptr, *txtptr, *buff, *tmpptr; … … 216 229 } else { 217 230 /* if we didn't understand it, we'll print it. This is different from zwgc 218 but zwgc seems to be smarter about some screw cases than I am */ 231 * but zwgc seems to be smarter about some screw cases than I am 232 */ 219 233 owl_fmtext_append_attr(f, "@", curattrs, curcolor); 220 234 txtptr++; … … 282 296 } 283 297 284 void owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop) { 298 /* This is used internally to fmtext. Use owl_fmtext_append_fmtext() 299 * (no initial underscore) externally */ 300 void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop) 301 { 285 302 int newlen, i; 286 303 … … 299 316 } 300 317 301 void owl_fmtext_append_spaces(owl_fmtext *f, int nspaces) { 318 void owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in) 319 { 320 _owl_fmtext_append_fmtext(f, in, 0, in->textlen); 321 322 } 323 324 void owl_fmtext_append_spaces(owl_fmtext *f, int nspaces) 325 { 302 326 int i; 303 327 for (i=0; i<nspaces; i++) { … … 310 334 * If format_fn is specified, passes it the list element value 311 335 * and it will return a string which this needs to free. */ 312 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*)) { 336 void owl_fmtext_append_list(owl_fmtext *f, owl_list *l, char *join_with, char *(format_fn)(void*)) 337 { 313 338 int i, size; 314 339 void *elem; … … 335 360 336 361 /* caller is responsible for freeing */ 337 char *owl_fmtext_print_plain(owl_fmtext *f) { 362 char *owl_fmtext_print_plain(owl_fmtext *f) 363 { 338 364 return owl_strdup(f->textbuff); 339 365 } 340 366 341 367 342 void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w) { 368 void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w) 369 { 343 370 char *tmpbuff; 344 371 int position, trans1, trans2, len, lastsame; … … 395 422 396 423 397 int owl_fmtext_truncate_lines(owl_fmtext *in, int aline, int lines, owl_fmtext *out) { 424 int owl_fmtext_truncate_lines(owl_fmtext *in, int aline, int lines, owl_fmtext *out) 425 { 398 426 /* start with line aline (where the first line is 0) and print 399 427 * 'lines' lines … … 420 448 offset=ptr1-in->textbuff; 421 449 if (!ptr2) { 422 owl_fmtext_append_fmtext(out, in, offset, in->textlen-1);450 _owl_fmtext_append_fmtext(out, in, offset, in->textlen-1); 423 451 return(-1); 424 452 } 425 owl_fmtext_append_fmtext(out, in, offset, (ptr2-ptr1)+offset);453 _owl_fmtext_append_fmtext(out, in, offset, (ptr2-ptr1)+offset); 426 454 ptr1=ptr2+1; 427 455 } … … 430 458 431 459 432 void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out) { 460 void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out) 461 { 433 462 char *ptr1, *ptr2, *last; 434 463 int len, offset; … … 468 497 469 498 offset=ptr1-in->textbuff; 470 owl_fmtext_append_fmtext(out, in, offset+acol, offset+acol+len);499 _owl_fmtext_append_fmtext(out, in, offset+acol, offset+acol+len); 471 500 472 501 ptr1=ptr2+1; … … 475 504 476 505 477 int owl_fmtext_num_lines(owl_fmtext *f) { 506 int owl_fmtext_num_lines(owl_fmtext *f) 507 { 478 508 int lines, i; 479 509 … … 492 522 493 523 494 char *owl_fmtext_get_text(owl_fmtext *f) { 524 char *owl_fmtext_get_text(owl_fmtext *f) 525 { 495 526 return(f->textbuff); 496 527 } 497 528 498 void owl_fmtext_set_char(owl_fmtext *f, int index, int ch) { 529 void owl_fmtext_set_char(owl_fmtext *f, int index, int ch) 530 { 499 531 /* set the charater at 'index' to be 'char'. If index is out of 500 532 * bounds don't do anything */ … … 503 535 } 504 536 505 void owl_fmtext_free(owl_fmtext *f) { 537 void owl_fmtext_free(owl_fmtext *f) 538 { 506 539 if (f->textbuff) owl_free(f->textbuff); 507 540 if (f->fmbuff) owl_free(f->fmbuff); … … 510 543 511 544 512 void owl_fmtext_copy(owl_fmtext *dst, owl_fmtext *src) { 545 void owl_fmtext_copy(owl_fmtext *dst, owl_fmtext *src) 546 { 513 547 dst->textlen=src->textlen; 514 548 dst->textbuff=owl_malloc(src->textlen+5); … … 521 555 522 556 523 int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string) { 524 /* highlight all instance of "string". Return the number of 525 * instances found. This is case insensitive. */ 557 /* highlight all instance of "string". Return the number of 558 * instances found. This is case insensitive. 559 */ 560 int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string) 561 { 526 562 527 563 int found, len; … … 545 581 } 546 582 547 int owl_fmtext_search(owl_fmtext *f, char *string) { 548 /* return 1 if the string is found, 0 if not. This is case 549 * insensitive */ 583 /* return 1 if the string is found, 0 if not. This is case 584 * insensitive 585 */ 586 int owl_fmtext_search(owl_fmtext *f, char *string) 587 { 550 588 551 589 if (stristr(f->textbuff, string)) return(1);
Note: See TracChangeset
for help on using the changeset viewer.