Changeset 8fa9562
- Timestamp:
- Jan 20, 2007, 9:49:55 PM (18 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:
- 575877f
- Parents:
- 212764e
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
r12e5f17 r8fa9562 503 503 OWLCMD_ARGS("filter", owl_command_filter, OWL_CTX_ANY, 504 504 "create a message filter", 505 "filter <name> [ -c color ] [ <expression> ... ]",505 "filter <name> [ -c fgcolor ] [ -b bgcolor ] [ <expression> ... ]", 506 506 "The filter command creates a filter with the specified name,\n" 507 507 "or if one already exists it is replaced. Example filter\n" … … 533 533 " false\n" 534 534 "Spaces must be present before and after parenthesis. If the\n" 535 "optional color argument is used it specifies the colorthat\n"535 "optional color arguments are used they specifies the colors that\n" 536 536 "messages matching this filter should be displayed in.\n\n" 537 537 "SEE ALSO: view, viewclass, viewuser\n"), 538 538 539 539 OWLCMD_ARGS("colorview", owl_command_colorview, OWL_CTX_INTERACTIVE, 540 "change the color on the current filter",541 "colorview < color>",542 "The color of messages in the current filter will be changed\n"543 "to < color>. Use the 'show colors' command for a list\n"540 "change the colors on the current filter", 541 "colorview <fgcolor> [<bgcolor>]", 542 "The colors of messages in the current filter will be changed\n" 543 "to <fgcolor>,<bgcolor>. Use the 'show colors' command for a list\n" 544 544 "of valid colors.\n\n" 545 545 "SEE ALSO: 'show colors'\n"), … … 547 547 OWLCMD_ARGS("colorclass", owl_command_colorclass, OWL_CTX_INTERACTIVE, 548 548 "create a filter to color messages of the given class name", 549 "colorclass <class> < color>",549 "colorclass <class> <fgcolor> [<bgcolor>]", 550 550 "A filter will be created to color messages in <class>" 551 "in < color>. Use the 'show colors' command for a list\n"551 "in <fgcolor>,<bgcolor>. Use the 'show colors' command for a list\n" 552 552 "of valid colors.\n\n" 553 553 "SEE ALSO: 'show colors'\n"), … … 2253 2253 char *owl_command_colorview(int argc, char **argv, char *buff) 2254 2254 { 2255 if (argc !=2) {2255 if (argc < 2 || argc > 3) { 2256 2256 owl_function_makemsg("Wrong number of arguments to colorview command"); 2257 2257 return NULL; 2258 2258 } 2259 owl_function_color_current_filter(argv[1] );2259 owl_function_color_current_filter(argv[1], (argc == 3 ? argv[2] : NULL)); 2260 2260 return NULL; 2261 2261 } … … 2265 2265 char *filtname; 2266 2266 2267 if (argc !=3) {2267 if (argc < 3 || argc > 4) { 2268 2268 owl_function_makemsg("Wrong number of arguments to colorclass command"); 2269 2269 return NULL; … … 2271 2271 2272 2272 filtname=owl_function_classinstfilt(argv[1], NULL); 2273 (void) owl_function_color_filter(filtname, argv[2] );2273 (void) owl_function_color_filter(filtname, argv[2], (argc == 4 ? argv[3] : NULL)); 2274 2274 return NULL; 2275 2275 } -
filter.c
r446aa2b r8fa9562 21 21 f->name=owl_strdup(name); 22 22 f->polarity=0; 23 f->color=OWL_COLOR_DEFAULT; 23 f->fgcolor=OWL_COLOR_DEFAULT; 24 f->bgcolor=OWL_COLOR_DEFAULT; 24 25 f->cachedmsgid=-1; 25 26 26 27 /* first take arguments that have to come first */ 27 28 /* set the color */ 28 if (argc>=2 && !strcmp(argv[0], "-c")) { 29 while ( argc>=2 && ( !strcmp(argv[0], "-c") || 30 !strcmp(argv[0], "-b") ) ) { 29 31 if (owl_util_string_to_color(argv[1])==-1) { 30 32 owl_function_error("The color '%s' is not available, using default.", argv[1]); 31 33 } else { 32 f->color=owl_util_string_to_color(argv[1]); 34 switch (argv[0][1]) { 35 case 'c': 36 f->fgcolor=owl_util_string_to_color(argv[1]); 37 break; 38 case 'b': 39 f->bgcolor=owl_util_string_to_color(argv[1]); 40 break; 41 } 33 42 } 34 43 argc-=2; … … 159 168 } 160 169 161 void owl_filter_set_color(owl_filter *f, int color) 162 { 163 f->color=color; 164 } 165 166 int owl_filter_get_color(owl_filter *f) 167 { 168 return(f->color); 170 void owl_filter_set_fgcolor(owl_filter *f, int color) 171 { 172 f->fgcolor=color; 173 } 174 175 int owl_filter_get_fgcolor(owl_filter *f) 176 { 177 return(f->fgcolor); 178 } 179 180 void owl_filter_set_bgcolor(owl_filter *f, int color) 181 { 182 f->bgcolor=color; 183 } 184 185 int owl_filter_get_bgcolor(owl_filter *f) 186 { 187 return(f->bgcolor); 169 188 } 170 189 … … 196 215 strcat(out, ": "); 197 216 198 if (f-> color!=OWL_COLOR_DEFAULT) {217 if (f->fgcolor!=OWL_COLOR_DEFAULT) { 199 218 strcat(out, "-c "); 200 strcat(out, owl_util_color_to_string(f->color)); 219 strcat(out, owl_util_color_to_string(f->fgcolor)); 220 strcat(out, " "); 221 } 222 if (f->bgcolor!=OWL_COLOR_DEFAULT) { 223 strcat(out, "-b "); 224 strcat(out, owl_util_color_to_string(f->bgcolor)); 201 225 strcat(out, " "); 202 226 } -
fmtext.c
ra0a5179 r8fa9562 11 11 f->textbuff=owl_strdup(""); 12 12 f->fmbuff=owl_malloc(5); 13 f->colorbuff=owl_malloc(5); 13 f->fgcolorbuff=owl_malloc(5); 14 f->bgcolorbuff=owl_malloc(5); 14 15 f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE; 15 f->colorbuff[0]=OWL_COLOR_DEFAULT; 16 f->fgcolorbuff[0]=OWL_COLOR_DEFAULT; 17 f->bgcolorbuff[0]=OWL_COLOR_DEFAULT; 16 18 } 17 19 … … 41 43 * to index 'last 42 44 */ 43 void _owl_fmtext_set_ color(owl_fmtext *f, int color, int first, int last)45 void _owl_fmtext_set_fgcolor(owl_fmtext *f, int color, int first, int last) 44 46 { 45 47 int i; 46 48 for (i=first; i<=last; i++) { 47 f->colorbuff[i]=(unsigned char) color; 49 f->fgcolorbuff[i]=(unsigned char) color; 50 } 51 } 52 53 void _owl_fmtext_set_bgcolor(owl_fmtext *f, int color, int first, int last) 54 { 55 int i; 56 for (i=first; i<=last; i++) { 57 f->bgcolorbuff[i]=(unsigned char) color; 48 58 } 49 59 } … … 52 62 * 'color' 53 63 */ 54 void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int color)64 void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int fgcolor, int bgcolor) 55 65 { 56 66 int newlen; … … 59 69 f->textbuff=owl_realloc(f->textbuff, newlen+2); 60 70 f->fmbuff=owl_realloc(f->fmbuff, newlen+2); 61 f->colorbuff=owl_realloc(f->colorbuff, newlen+2); 71 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+2); 72 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+2); 62 73 63 74 strcat(f->textbuff, text); 64 75 _owl_fmtext_set_attr(f, attr, f->textlen, newlen); 65 _owl_fmtext_set_color(f, color, f->textlen, newlen); 76 _owl_fmtext_set_fgcolor(f, fgcolor, f->textlen, newlen); 77 _owl_fmtext_set_bgcolor(f, bgcolor, f->textlen, newlen); 66 78 f->textlen=newlen; 67 79 } … … 70 82 void owl_fmtext_append_normal(owl_fmtext *f, char *text) 71 83 { 72 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, OWL_COLOR_DEFAULT );84 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT); 73 85 } 74 86 75 87 /* Append normal text 'text' to 'f' with color 'color' */ 76 void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int color)77 { 78 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, color);88 void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int fgcolor, int bgcolor) 89 { 90 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_NONE, fgcolor, bgcolor); 79 91 } 80 92 … … 82 94 void owl_fmtext_append_bold(owl_fmtext *f, char *text) 83 95 { 84 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT );96 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT); 85 97 } 86 98 … … 88 100 void owl_fmtext_append_reverse(owl_fmtext *f, char *text) 89 101 { 90 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE, OWL_COLOR_DEFAULT );102 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE, OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT); 91 103 } 92 104 … … 94 106 void owl_fmtext_append_reversebold(owl_fmtext *f, char *text) 95 107 { 96 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE | OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT );108 owl_fmtext_append_attr(f, text, OWL_FMTEXT_ATTR_REVERSE | OWL_FMTEXT_ATTR_BOLD, OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT); 97 109 } 98 110 … … 114 126 void owl_fmtext_colorize(owl_fmtext *f, int color) 115 127 { 116 /* everywhere the color is OWL_COLOR_DEFAULT, change it to be 'color' */128 /* everywhere the fgcolor is OWL_COLOR_DEFAULT, change it to be 'color' */ 117 129 int i, j; 118 130 119 131 j=f->textlen; 120 132 for(i=0; i<j; i++) { 121 if (f->colorbuff[i]==OWL_COLOR_DEFAULT) f->colorbuff[i] = color; 133 if (f->fgcolorbuff[i]==OWL_COLOR_DEFAULT) f->fgcolorbuff[i] = color; 134 } 135 } 136 137 void owl_fmtext_colorizebg(owl_fmtext *f, int color) 138 { 139 /* everywhere the bgcolor is OWL_COLOR_DEFAULT, change it to be 'color' */ 140 int i, j; 141 142 j=f->textlen; 143 for(i=0; i<j; i++) { 144 if (f->bgcolorbuff[i]==OWL_COLOR_DEFAULT) f->bgcolorbuff[i] = color; 122 145 } 123 146 } … … 133 156 f->textbuff=owl_realloc(f->textbuff, newlen+1); 134 157 f->fmbuff=owl_realloc(f->fmbuff, newlen+1); 135 f->colorbuff=owl_realloc(f->colorbuff, newlen+1); 158 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1); 159 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1); 136 160 137 161 strncat(f->textbuff, in->textbuff+start, stop-start+1); … … 139 163 for (i=start; i<=stop; i++) { 140 164 f->fmbuff[f->textlen+(i-start)]=in->fmbuff[i]; 141 f->colorbuff[f->textlen+(i-start)]=in->colorbuff[i]; 165 f->fgcolorbuff[f->textlen+(i-start)]=in->fgcolorbuff[i]; 166 f->bgcolorbuff[f->textlen+(i-start)]=in->bgcolorbuff[i]; 142 167 } 143 168 f->textlen=newlen; … … 174 199 { 175 200 char *tmpbuff; 176 int position, trans1, trans2, len, lastsame;201 int position, trans1, trans2, trans3, len, lastsame; 177 202 178 203 if (w==NULL) { … … 188 213 /* find the last char with the current format and color */ 189 214 trans1=owl_util_find_trans(f->fmbuff+position, len-position); 190 trans2=owl_util_find_trans(f->colorbuff+position, len-position); 191 192 if (trans1<trans2) { 193 lastsame=position+trans1; 194 } else { 195 lastsame=position+trans2; 196 } 215 trans2=owl_util_find_trans(f->fgcolorbuff+position, len-position); 216 trans3=owl_util_find_trans(f->bgcolorbuff+position, len-position); 217 218 lastsame = (trans1 < trans2) ? trans1 : trans2; 219 lastsame = (lastsame < trans3) ? lastsame : trans3; 220 lastsame += position; 197 221 198 222 /* set the format */ … … 211 235 /* warning, this is sort of a hack */ 212 236 if (owl_global_get_hascolors(&g)) { 213 if (f->colorbuff[position]!=OWL_COLOR_DEFAULT) { 214 wattron(w, COLOR_PAIR(f->colorbuff[position])); 237 int pair, fg, bg; 238 fg = f->fgcolorbuff[position]; 239 bg = f->bgcolorbuff[position]; 240 owl_function_debugmsg("waddstr: fg(%i) bg(%i).", fg, bg); 241 242 pair = owl_fmtext_get_colorpair(fg, bg); 243 if (pair != -1) { 244 wattron(w, COLOR_PAIR(pair)); 215 245 } 216 246 } … … 355 385 dst->textbuff=owl_malloc(mallocsize); 356 386 dst->fmbuff=owl_malloc(mallocsize); 357 dst->colorbuff=owl_malloc(mallocsize); 387 dst->fgcolorbuff=owl_malloc(mallocsize); 388 dst->bgcolorbuff=owl_malloc(mallocsize); 358 389 memcpy(dst->textbuff, src->textbuff, src->textlen+1); 359 390 memcpy(dst->fmbuff, src->fmbuff, src->textlen); 360 memcpy(dst->colorbuff, src->colorbuff, src->textlen); 391 memcpy(dst->fgcolorbuff, src->fgcolorbuff, src->textlen); 392 memcpy(dst->bgcolorbuff, src->bgcolorbuff, src->textlen); 361 393 } 362 394 … … 415 447 if (!ptr) { 416 448 /* add all the rest of the text and exit */ 417 owl_fmtext_append_attr(f, txtptr, curattrs, curcolor );449 owl_fmtext_append_attr(f, txtptr, curattrs, curcolor, OWL_COLOR_DEFAULT); 418 450 return; 419 451 } else if (ptr[0]=='@') { … … 422 454 strncpy(buff, txtptr, ptr-txtptr); 423 455 buff[ptr-txtptr]='\0'; 424 owl_fmtext_append_attr(f, buff, curattrs, curcolor );456 owl_fmtext_append_attr(f, buff, curattrs, curcolor, OWL_COLOR_DEFAULT); 425 457 owl_free(buff); 426 458 … … 432 464 /* if we've hit our max stack depth, print the @ and move on */ 433 465 if (stacksize==32) { 434 owl_fmtext_append_attr(f, "@", curattrs, curcolor );466 owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT); 435 467 txtptr++; 436 468 continue; … … 439 471 /* if it's an @@, print an @ and continue */ 440 472 if (txtptr[1]=='@') { 441 owl_fmtext_append_attr(f, "@", curattrs, curcolor );473 owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT); 442 474 txtptr+=2; 443 475 continue; … … 447 479 tmpptr=strpbrk(txtptr, "(<[{ "); 448 480 if (!tmpptr || tmpptr[0]==' ') { 449 owl_fmtext_append_attr(f, "@", curattrs, curcolor );481 owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT); 450 482 txtptr++; 451 483 continue; … … 524 556 * but zwgc seems to be smarter about some screw cases than I am 525 557 */ 526 owl_fmtext_append_attr(f, "@", curattrs, curcolor );558 owl_fmtext_append_attr(f, "@", curattrs, curcolor, OWL_COLOR_DEFAULT); 527 559 txtptr++; 528 560 continue; … … 534 566 strncpy(buff, txtptr, ptr-txtptr); 535 567 buff[ptr-txtptr]='\0'; 536 owl_fmtext_append_attr(f, buff, curattrs, curcolor );568 owl_fmtext_append_attr(f, buff, curattrs, curcolor, OWL_COLOR_DEFAULT); 537 569 owl_free(buff); 538 570 … … 545 577 buff[0]=ptr[0]; 546 578 buff[1]='\0'; 547 owl_fmtext_append_attr(f, buff, curattrs, curcolor );579 owl_fmtext_append_attr(f, buff, curattrs, curcolor, OWL_COLOR_DEFAULT); 548 580 owl_free(buff); 549 581 txtptr++; … … 570 602 buff[0]=ptr[0]; 571 603 buff[1]='\0'; 572 owl_fmtext_append_attr(f, buff, curattrs, curcolor );604 owl_fmtext_append_attr(f, buff, curattrs, curcolor, OWL_COLOR_DEFAULT); 573 605 owl_free(buff); 574 606 txtptr++; … … 580 612 strncpy(buff, txtptr, ptr-txtptr+1); 581 613 buff[ptr-txtptr+1]='\0'; 582 owl_fmtext_append_attr(f, buff, curattrs, curcolor );614 owl_fmtext_append_attr(f, buff, curattrs, curcolor, OWL_COLOR_DEFAULT); 583 615 owl_free(buff); 584 616 txtptr=ptr+1; … … 621 653 if (f->textbuff) owl_free(f->textbuff); 622 654 if (f->fmbuff) owl_free(f->fmbuff); 623 if (f->colorbuff) owl_free(f->colorbuff); 624 } 625 655 if (f->fgcolorbuff) owl_free(f->fgcolorbuff); 656 if (f->bgcolorbuff) owl_free(f->bgcolorbuff); 657 } 658 659 /*** Color Pair manager ***/ 660 void owl_fmtext_init_colorpair_mgr(owl_colorpair_mgr *cpmgr) 661 { 662 // This could be a bitarray if we wanted to save memory. 663 int i, j, colors; 664 cpmgr->used = owl_malloc(COLOR_PAIRS * sizeof(char)); 665 memset(cpmgr->used, 0, COLOR_PAIRS * sizeof(char)); 666 667 colors = COLORS + 1; // 1 to account for "default". 668 cpmgr->pairs = owl_malloc(colors * sizeof(int*)); 669 for(i = 0; i < colors; i++) { 670 // Because we're going to have a pair set for any fg and the 671 // default bg, we don't need to account for default here. 672 cpmgr->pairs[i] = owl_malloc(COLORS * sizeof(int)); 673 for(j = 0; j < COLORS; j++) { 674 cpmgr->pairs[i][j] = -1; 675 } 676 } 677 } 678 679 /* Reset used list */ 680 void owl_fmtext_reset_colorpairs() 681 { 682 memset(owl_global_get_colorpair_mgr(&g)->used, 0, COLOR_PAIRS * sizeof(char)); 683 } 684 685 /* Assign pairs by request */ 686 int owl_fmtext_get_colorpair(int fg, int bg) 687 { 688 owl_colorpair_mgr *cpmgr; 689 short pair, i; 690 if (fg == OWL_COLOR_DEFAULT) fg = -1; 691 if (bg == OWL_COLOR_DEFAULT) { 692 pair = fg; 693 } else { 694 cpmgr = owl_global_get_colorpair_mgr(&g); 695 pair = cpmgr->pairs[fg+1][bg]; 696 if (pair != -1) { 697 short oldfg, oldbg; 698 pair_content(pair, &oldfg, &oldbg); 699 if (cpmgr->pairs[oldfg+1][oldbg] == pair) { 700 cpmgr->pairs[oldfg+1][oldbg] = -1; 701 } 702 init_pair(pair, fg, bg); 703 cpmgr->pairs[fg+1][bg] = pair; 704 cpmgr->used[pair] = 1; 705 } else { 706 // Skip the first COLORS, sicne they're static. 707 for(i = COLORS; i < COLOR_PAIRS; i++) { 708 if (0 == cpmgr->used[i]) { 709 pair = i; 710 break; 711 } 712 } 713 if (pair != -1) { 714 short oldfg, oldbg; 715 pair_content(pair, &oldfg, &oldbg); 716 if (cpmgr->pairs[oldfg+1][oldbg] == pair) { 717 cpmgr->pairs[oldfg+1][oldbg] = -1; 718 } 719 init_pair(pair, fg, bg); 720 cpmgr->pairs[fg+1][bg] = pair; 721 cpmgr->used[pair] = 1; 722 } else { 723 // Fail to skipping background. 724 pair = fg; 725 } 726 } 727 } 728 return pair; 729 } -
functions.c
r8203afd r8fa9562 2454 2454 return; 2455 2455 } 2456 owl_filter_set_color(f, owl_util_string_to_color(argv[3])); 2456 owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3])); 2457 owl_global_set_needrefresh(&g); 2458 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); 2459 return; 2460 } 2461 if (argc==4 && !strcmp(argv[2], "-b")) { 2462 f=owl_global_get_filter(&g, argv[1]); 2463 if (!f) { 2464 owl_function_error("The filter '%s' does not exist.", argv[1]); 2465 return; 2466 } 2467 if (owl_util_string_to_color(argv[3])==-1) { 2468 owl_function_error("The color '%s' is not available.", argv[3]); 2469 return; 2470 } 2471 owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3])); 2457 2472 owl_global_set_needrefresh(&g); 2458 2473 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 2545 2560 owl_fmtext_append_normal(&fm, " "); 2546 2561 if (owl_global_get_hascolors(&g)) { 2547 owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_ color(f));2562 owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f)); 2548 2563 } else { 2549 2564 owl_fmtext_append_normal(&fm, owl_filter_get_name(f)); … … 2924 2939 * be 'color' 2925 2940 */ 2926 void owl_function_color_current_filter(char * color)2941 void owl_function_color_current_filter(char *fgcolor, char *bgcolor) 2927 2942 { 2928 2943 char *name; 2929 2944 2930 2945 name=owl_view_get_filtname(owl_global_get_current_view(&g)); 2931 owl_function_color_filter(name, color);2946 owl_function_color_filter(name, fgcolor, bgcolor); 2932 2947 } 2933 2948 … … 2936 2951 * the "all" filter, return -2. Return 0 on success 2937 2952 */ 2938 int owl_function_color_filter(char *filtname, char * color)2953 int owl_function_color_filter(char *filtname, char *fgcolor, char *bgcolor) 2939 2954 { 2940 2955 owl_filter *f; … … 2952 2967 } 2953 2968 2954 if (owl_util_string_to_color( color)==-1) {2955 owl_function_error("No color named '%s' avilable." );2969 if (owl_util_string_to_color(fgcolor)==-1) { 2970 owl_function_error("No color named '%s' avilable.", fgcolor); 2956 2971 return(-1); 2957 2972 } 2958 owl_filter_set_color(f, owl_util_string_to_color(color)); 2973 2974 2975 if (bgcolor != NULL) { 2976 if (owl_util_string_to_color(bgcolor)==-1) { 2977 owl_function_error("No color named '%s' avilable.", bgcolor); 2978 return(-1); 2979 } 2980 owl_filter_set_bgcolor(f, owl_util_string_to_color(bgcolor)); 2981 } 2982 owl_filter_set_fgcolor(f, owl_util_string_to_color(fgcolor)); 2983 2959 2984 owl_global_set_needrefresh(&g); 2960 2985 owl_mainwin_redisplay(owl_global_get_mainwin(&g)); … … 2968 2993 owl_fmtext_init_null(&fm); 2969 2994 owl_fmtext_append_normal(&fm, "default: "); 2970 owl_fmtext_append_normal_color(&fm, "default\n", OWL_COLOR_DEFAULT );2995 owl_fmtext_append_normal_color(&fm, "default\n", OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT); 2971 2996 2972 2997 owl_fmtext_append_normal(&fm,"red: "); 2973 owl_fmtext_append_normal_color(&fm, "red\n", OWL_COLOR_RED );2998 owl_fmtext_append_normal_color(&fm, "red\n", OWL_COLOR_RED, OWL_COLOR_DEFAULT); 2974 2999 2975 3000 owl_fmtext_append_normal(&fm,"green: "); 2976 owl_fmtext_append_normal_color(&fm, "green\n", OWL_COLOR_GREEN );3001 owl_fmtext_append_normal_color(&fm, "green\n", OWL_COLOR_GREEN, OWL_COLOR_DEFAULT); 2977 3002 2978 3003 owl_fmtext_append_normal(&fm,"yellow: "); 2979 owl_fmtext_append_normal_color(&fm, "yellow\n", OWL_COLOR_YELLOW );3004 owl_fmtext_append_normal_color(&fm, "yellow\n", OWL_COLOR_YELLOW, OWL_COLOR_DEFAULT); 2980 3005 2981 3006 owl_fmtext_append_normal(&fm,"blue: "); 2982 owl_fmtext_append_normal_color(&fm, "blue\n", OWL_COLOR_BLUE );3007 owl_fmtext_append_normal_color(&fm, "blue\n", OWL_COLOR_BLUE, OWL_COLOR_DEFAULT); 2983 3008 2984 3009 owl_fmtext_append_normal(&fm,"magenta: "); 2985 owl_fmtext_append_normal_color(&fm, "magenta\n", OWL_COLOR_MAGENTA );3010 owl_fmtext_append_normal_color(&fm, "magenta\n", OWL_COLOR_MAGENTA, OWL_COLOR_DEFAULT); 2986 3011 2987 3012 owl_fmtext_append_normal(&fm,"cyan: "); 2988 owl_fmtext_append_normal_color(&fm, "cyan\n", OWL_COLOR_CYAN );3013 owl_fmtext_append_normal_color(&fm, "cyan\n", OWL_COLOR_CYAN, OWL_COLOR_DEFAULT); 2989 3014 2990 3015 owl_fmtext_append_normal(&fm,"white: "); 2991 owl_fmtext_append_normal_color(&fm, "white\n", OWL_COLOR_WHITE );3016 owl_fmtext_append_normal_color(&fm, "white\n", OWL_COLOR_WHITE, OWL_COLOR_DEFAULT); 2992 3017 2993 3018 owl_function_popless_fmtext(&fm); -
global.c
rcb769bb r8fa9562 64 64 } 65 65 g->colorpairs=COLOR_PAIRS; 66 owl_fmtext_init_colorpair_mgr(&(g->cpmgr)); 66 67 g->debug=OWL_DEBUG; 67 68 g->searchactive=0; … … 592 593 } 593 594 595 owl_colorpair_mgr *owl_global_get_colorpair_mgr(owl_global *g) { 596 return(&(g->cpmgr)); 597 } 598 594 599 /* puntlist */ 595 600 -
mainwin.c
r37eab7f r8fa9562 14 14 int i, p, q, lines, isfull, viewsize; 15 15 int x, y, savey, recwinlines, start; 16 int topmsg, curmsg, color;16 int topmsg, curmsg, fgcolor, bgcolor; 17 17 WINDOW *recwin; 18 18 owl_view *v; … … 24 24 curmsg=owl_global_get_curmsg(&g); 25 25 v=owl_global_get_current_view(&g); 26 owl_fmtext_reset_colorpairs(); 26 27 27 28 if (v==NULL) { … … 72 73 73 74 /* if we match filters set the color */ 74 color=OWL_COLOR_DEFAULT; 75 fgcolor=OWL_COLOR_DEFAULT; 76 bgcolor=OWL_COLOR_DEFAULT; 75 77 filtlist=owl_global_get_filterlist(&g); 76 78 q=owl_list_get_size(filtlist); … … 78 80 f=owl_list_get_element(filtlist, p); 79 81 if (owl_filter_message_match(f, m)) { 80 if (owl_filter_get_color(f)!=OWL_COLOR_DEFAULT) color=owl_filter_get_color(f); 82 if (owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) fgcolor=owl_filter_get_fgcolor(f); 83 if (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT) bgcolor=owl_filter_get_bgcolor(f); 81 84 } 82 85 } … … 92 95 owl_global_get_rightshift(&g), 93 96 owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1, 94 color);97 fgcolor, bgcolor); 95 98 } else { 96 99 /* otherwise print the whole thing */ … … 100 103 owl_global_get_rightshift(&g), 101 104 owl_global_get_cols(&g)+owl_global_get_rightshift(&g)-1, 102 color);105 fgcolor, bgcolor); 103 106 } 104 107 -
message.c
rf4d32cd r8fa9562 516 516 } 517 517 518 void owl_message_curs_waddstr(owl_message *m, WINDOW *win, int aline, int bline, int acol, int bcol, int color)518 void owl_message_curs_waddstr(owl_message *m, WINDOW *win, int aline, int bline, int acol, int bcol, int fgcolor, int bgcolor) 519 519 { 520 520 owl_fmtext a, b; … … 528 528 owl_fmtext_truncate_lines(&(m->fmtext), aline, bline-aline+1, &a); 529 529 owl_fmtext_truncate_cols(&a, acol, bcol, &b); 530 if (color!=OWL_COLOR_DEFAULT) { 531 owl_fmtext_colorize(&b, color); 530 if (fgcolor!=OWL_COLOR_DEFAULT) { 531 owl_fmtext_colorize(&b, fgcolor); 532 } 533 if (bgcolor!=OWL_COLOR_DEFAULT) { 534 owl_fmtext_colorizebg(&b, bgcolor); 532 535 } 533 536 -
owl.c
r212764e r8fa9562 177 177 /* define simple color pairs */ 178 178 if (has_colors() && COLOR_PAIRS>=8) { 179 init_pair(OWL_COLOR_BLACK, COLOR_BLACK, -1); 180 init_pair(OWL_COLOR_RED, COLOR_RED, -1); 181 init_pair(OWL_COLOR_GREEN, COLOR_GREEN, -1); 182 init_pair(OWL_COLOR_YELLOW, COLOR_YELLOW, -1); 183 init_pair(OWL_COLOR_BLUE, COLOR_BLUE, -1); 184 init_pair(OWL_COLOR_MAGENTA, COLOR_MAGENTA, -1); 185 init_pair(OWL_COLOR_CYAN, COLOR_CYAN, -1); 186 init_pair(OWL_COLOR_WHITE, COLOR_WHITE, -1); 179 int bg = COLOR_BLACK; 180 #ifdef HAVE_USE_DEFAULT_COLORS 181 bg = -1; 182 #endif 183 init_pair(OWL_COLOR_BLACK, COLOR_BLACK, bg); 184 init_pair(OWL_COLOR_RED, COLOR_RED, bg); 185 init_pair(OWL_COLOR_GREEN, COLOR_GREEN, bg); 186 init_pair(OWL_COLOR_YELLOW, COLOR_YELLOW, bg); 187 init_pair(OWL_COLOR_BLUE, COLOR_BLUE, bg); 188 init_pair(OWL_COLOR_MAGENTA, COLOR_MAGENTA, bg); 189 init_pair(OWL_COLOR_CYAN, COLOR_CYAN, bg); 190 init_pair(OWL_COLOR_WHITE, COLOR_WHITE, bg); 187 191 } 188 192 -
owl.h
rcb769bb r8fa9562 252 252 char *textbuff; 253 253 char *fmbuff; 254 char *colorbuff; 254 char *fgcolorbuff; 255 char *bgcolorbuff; 255 256 } owl_fmtext; 256 257 … … 415 416 int polarity; 416 417 owl_filterelement * root; 417 int color; 418 int fgcolor; 419 int bgcolor; 418 420 int cachedmsgid; /* cached msgid: should move into view eventually */ 419 421 } owl_filter; … … 513 515 owl_list errlist; 514 516 } owl_errqueue; 517 518 typedef struct _owl_colorpair_mgr { 519 char *used; 520 int **pairs; 521 } owl_colorpair_mgr; 515 522 516 523 typedef struct _owl_global { … … 556 563 int hascolors; 557 564 int colorpairs; 565 owl_colorpair_mgr cpmgr; 558 566 int searchactive; 559 567 int newmsgproc_pid; -
perl/modules/jabber.pl
re1b197e8 r8fa9562 73 73 74 74 $muc->Leave(); 75 76 75 $self->{_BARNOWL_MUCS} = [grep {$_->BaseJID ne $muc->BaseJID} $self->MUCs]; 77 76 } … … 427 426 $client->SetPresenceCallBacks( 428 427 available => sub { BarnOwl::Jabber::process_presence_available(@_) }, 429 #unavailable => sub { BarnOwl::Jabber::process_presence_available(@_) },428 unavailable => sub { BarnOwl::Jabber::process_presence_available(@_) }, 430 429 subscribe => sub { BarnOwl::Jabber::process_presence_subscribe(@_) }, 431 430 subscribed => sub { BarnOwl::Jabber::process_presence_subscribed(@_) }, … … 1007 1006 } 1008 1007 $props{replysendercmd} = $props{replycmd} = "jwrite $from -i $sid"; 1009 if(BarnOwl::getvar('debug') eq 'on') {1008 # if(BarnOwl::getvar('debug') eq 'on') { 1010 1009 BarnOwl::queue_message(BarnOwl::Message->new(%props)); 1011 }1010 # } 1012 1011 } 1013 1012
Note: See TracChangeset
for help on using the changeset viewer.