Changeset c2c5c77
- Timestamp:
- Mar 28, 2007, 10:54:33 PM (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:
- 7f33c18
- Parents:
- af9b92e
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
filter.c
r1716fed rc2c5c77 217 217 if (f->fgcolor!=OWL_COLOR_DEFAULT) { 218 218 strcat(out, "-c "); 219 strcat(out, owl_util_color_to_string(f->fgcolor)); 219 if (f->fgcolor < 8) { 220 strcat(out, owl_util_color_to_string(f->fgcolor)); 221 } 222 else { 223 char* c = owl_sprintf("%i",f->fgcolor); 224 strcat(out, c); 225 owl_free(c); 226 } 220 227 strcat(out, " "); 221 228 } 222 229 if (f->bgcolor!=OWL_COLOR_DEFAULT) { 223 230 strcat(out, "-b "); 224 strcat(out, owl_util_color_to_string(f->bgcolor)); 231 if (f->bgcolor < 8) { 232 strcat(out, owl_util_color_to_string(f->bgcolor)); 233 } 234 else { 235 char* c = owl_sprintf("%i",f->bgcolor); 236 strcat(out, c); 237 owl_free(c); 238 } 225 239 strcat(out, " "); 226 240 } -
fmtext.c
ra387d12e rc2c5c77 12 12 f->textbuff=owl_malloc(5); 13 13 f->fmbuff=owl_malloc(5); 14 f->fgcolorbuff=owl_malloc(5 );15 f->bgcolorbuff=owl_malloc(5 );14 f->fgcolorbuff=owl_malloc(5 * sizeof(short)); 15 f->bgcolorbuff=owl_malloc(5 * sizeof(short)); 16 16 f->textbuff[0]=0; 17 17 f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE; … … 60 60 int i; 61 61 for (i=first; i<=last; i++) { 62 f->fgcolorbuff[i]=( unsigned char)color;62 f->fgcolorbuff[i]=(short)color; 63 63 } 64 64 } … … 68 68 int i; 69 69 for (i=first; i<=last; i++) { 70 f->bgcolorbuff[i]=( unsigned char)color;70 f->bgcolorbuff[i]=(short)color; 71 71 } 72 72 } … … 77 77 f->textbuff=owl_realloc(f->textbuff, newlen+1); 78 78 f->fmbuff=owl_realloc(f->fmbuff, newlen+1); 79 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1);80 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1);79 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, (newlen+1) * sizeof(short)); 80 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, (newlen+1) * sizeof(short)); 81 81 f->bufflen = newlen+1; 82 82 } … … 151 151 j=f->textlen; 152 152 for(i=0; i<j; i++) { 153 if (f->fgcolorbuff[i]==OWL_COLOR_DEFAULT) f->fgcolorbuff[i] = color;153 if (f->fgcolorbuff[i]==OWL_COLOR_DEFAULT) f->fgcolorbuff[i] = (short)color; 154 154 } 155 155 } … … 162 162 j=f->textlen; 163 163 for(i=0; i<j; i++) { 164 if (f->bgcolorbuff[i]==OWL_COLOR_DEFAULT) f->bgcolorbuff[i] = color;164 if (f->bgcolorbuff[i]==OWL_COLOR_DEFAULT) f->bgcolorbuff[i] = (short)color; 165 165 } 166 166 } … … 230 230 /* find the last char with the current format and color */ 231 231 trans1=owl_util_find_trans(f->fmbuff+position, len-position); 232 trans2=owl_util_find_trans (f->fgcolorbuff+position, len-position);233 trans3=owl_util_find_trans (f->bgcolorbuff+position, len-position);232 trans2=owl_util_find_trans_short(f->fgcolorbuff+position, len-position); 233 trans3=owl_util_find_trans_short(f->bgcolorbuff+position, len-position); 234 234 235 235 lastsame = (trans1 < trans2) ? trans1 : trans2; … … 252 252 /* warning, this is sort of a hack */ 253 253 if (owl_global_get_hascolors(&g)) { 254 int fg, bg; 255 short pair; 254 short fg, bg, pair; 256 255 fg = f->fgcolorbuff[position]; 257 256 bg = f->bgcolorbuff[position]; … … 259 258 pair = owl_fmtext_get_colorpair(fg, bg); 260 259 if (pair != -1) { 261 w attron(w, COLOR_PAIR(pair));260 wcolor_set(w,pair,NULL); 262 261 } 263 262 } … … 402 401 dst->textbuff=owl_malloc(mallocsize); 403 402 dst->fmbuff=owl_malloc(mallocsize); 404 dst->fgcolorbuff=owl_malloc(mallocsize );405 dst->bgcolorbuff=owl_malloc(mallocsize );403 dst->fgcolorbuff=owl_malloc(mallocsize * sizeof(short)); 404 dst->bgcolorbuff=owl_malloc(mallocsize * sizeof(short)); 406 405 memcpy(dst->textbuff, src->textbuff, src->textlen+1); 407 406 memcpy(dst->fmbuff, src->fmbuff, src->textlen); 408 memcpy(dst->fgcolorbuff, src->fgcolorbuff, src->textlen );409 memcpy(dst->bgcolorbuff, src->bgcolorbuff, src->textlen );407 memcpy(dst->fgcolorbuff, src->fgcolorbuff, src->textlen * sizeof(short)); 408 memcpy(dst->bgcolorbuff, src->bgcolorbuff, src->textlen * sizeof(short)); 410 409 } 411 410 … … 678 677 { 679 678 // This could be a bitarray if we wanted to save memory. 680 int i, j, colors; 681 cpmgr->next = COLORS; 682 683 colors = COLORS + 1; // 1 to account for "default". 684 cpmgr->pairs = owl_malloc(colors * sizeof(int*)); 685 for(i = 0; i < colors; i++) { 686 // Because we're going to have a pair set for any fg and the 687 // default bg, we don't need to account for default here. 688 cpmgr->pairs[i] = owl_malloc(COLORS * sizeof(int)); 689 for(j = 0; j < COLORS; j++) { 679 short i, j; 680 cpmgr->next = 8; 681 682 // The test is <= because we allocate COLORS+1 entries. 683 cpmgr->pairs = owl_malloc((COLORS+1) * sizeof(short*)); 684 for(i = 0; i <= COLORS; i++) { 685 cpmgr->pairs[i] = owl_malloc((COLORS+1) * sizeof(short)); 686 for(j = 0; j <= COLORS; j++) { 690 687 cpmgr->pairs[i][j] = -1; 691 688 } 689 } 690 for(i = 0; i < 8; i++) { 691 short fg, bg; 692 pair_content(i, &fg, &bg); 693 cpmgr->pairs[fg+1][bg+1] = i; 692 694 } 693 695 } … … 696 698 void owl_fmtext_reset_colorpairs() 697 699 { 698 int i, j, colors;700 short i, j; 699 701 owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g); 700 cpmgr->next = COLORS;701 702 colors = COLORS + 1; // 1 to account for "default".703 for(i = 0; i < colors; i++) {704 for(j = 0; j < COLORS; j++) {702 cpmgr->next = 8; 703 704 // The test is <= because we allocated COLORS+1 entries. 705 for(i = 0; i <= COLORS; i++) { 706 for(j = 0; j <= COLORS; j++) { 705 707 cpmgr->pairs[i][j] = -1; 706 708 } 709 } 710 for(i = 0; i < 8; i++) { 711 short fg, bg; 712 pair_content(i, &fg, &bg); 713 cpmgr->pairs[fg+1][bg+1] = i; 707 714 } 708 715 } … … 723 730 #endif 724 731 725 if (bg == default_bg) { 726 // default bg -> use color pairs initialized by owl.c 727 pair = fg; 728 } else { 729 // looking for a pair we already set up for this draw. 730 cpmgr = owl_global_get_colorpair_mgr(&g); 731 pair = cpmgr->pairs[fg+1][bg]; 732 if (!(pair != -1 && pair < cpmgr->next)) { 733 // If we didn't find a pair, search for a free one to assign. 734 // Skip the first COLORS, since they're static. 735 // If we ever get 256 color curses, this will need more thought. 736 pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1; 737 if (pair != -1) { 738 // We found a free pair, initialize it. 739 init_pair(pair, fg, bg); 740 cpmgr->pairs[fg+1][bg] = pair; 741 cpmgr->next++; 742 } else { 743 // We still don't have a pair, drop the background color. Too bad. 744 pair = fg; 745 } 732 // looking for a pair we already set up for this draw. 733 cpmgr = owl_global_get_colorpair_mgr(&g); 734 pair = cpmgr->pairs[fg+1][bg+1]; 735 if (!(pair != -1 && pair < cpmgr->next)) { 736 /* owl_global_set_needrefresh(&g);*/ 737 // If we didn't find a pair, search for a free one to assign. 738 pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1; 739 if (pair != -1) { 740 // We found a free pair, initialize it. 741 init_pair(pair, fg, bg); 742 cpmgr->pairs[fg+1][bg+1] = pair; 743 cpmgr->next++; 744 } 745 else if (bg != OWL_COLOR_DEFAULT) { 746 // We still don't have a pair, drop the background color. Too bad. 747 owl_function_debugmsg("colorpairs: color shortage - dropping background color."); 748 pair = owl_fmtext_get_colorpair(fg, OWL_COLOR_DEFAULT); 749 } 750 else { 751 // We still don't have a pair, defaults all around. 752 owl_function_debugmsg("colorpairs: color shortage - dropping foreground and background color."); 753 pair = 0; 746 754 } 747 755 } -
functions.c
raf9b92e rc2c5c77 1440 1440 wnoutrefresh(owl_global_get_curs_typwin(&g)); 1441 1441 wnoutrefresh(owl_global_get_curs_msgwin(&g)); 1442 1443 if (owl_popwin_is_active(owl_global_get_popwin(&g))) { 1444 owl_popwin_refresh(owl_global_get_popwin(&g)); 1445 } 1442 1446 1443 1447 sepbar(""); … … 3018 3022 { 3019 3023 owl_fmtext fm; 3020 3024 int i; 3025 3021 3026 owl_fmtext_init_null(&fm); 3022 3027 owl_fmtext_append_normal(&fm, "default: "); … … 3044 3049 owl_fmtext_append_normal_color(&fm, "white\n", OWL_COLOR_WHITE, OWL_COLOR_DEFAULT); 3045 3050 3051 for(i = 8; i < COLORS; ++i) { 3052 char* str1 = owl_sprintf("%4i: ",i); 3053 char* str2 = owl_sprintf("%i\n",i); 3054 owl_fmtext_append_normal(&fm,str1); 3055 owl_fmtext_append_normal_color(&fm, str2, i, OWL_COLOR_DEFAULT); 3056 owl_free(str1); 3057 owl_free(str2); 3058 } 3059 3046 3060 owl_function_popless_fmtext(&fm); 3047 3061 owl_fmtext_free(&fm); … … 3719 3733 owl_fmtext_free(&fm); 3720 3734 } 3735 3736 int owl_function_get_color_count() 3737 { 3738 return COLORS; 3739 } -
mainwin.c
r8fa9562 rc2c5c77 79 79 for (p=0; p<q; p++) { 80 80 f=owl_list_get_element(filtlist, p); 81 if (owl_filter_message_match(f, m)) { 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 if ((owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) || 82 (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT)) { 83 if (owl_filter_message_match(f, m)) { 84 if (owl_filter_get_fgcolor(f)!=OWL_COLOR_DEFAULT) fgcolor=owl_filter_get_fgcolor(f); 85 if (owl_filter_get_bgcolor(f)!=OWL_COLOR_DEFAULT) bgcolor=owl_filter_get_bgcolor(f); 86 } 84 87 } 85 88 } -
owl.c
r72c210f rc2c5c77 331 331 owl_function_debugmsg("startup: creating splash message"); 332 332 strcpy(startupmsg, "-----------------------------------------------------------------------\n"); 333 sprintf(buff, "Welcome to barnowl version %s. Press 'h' for on-line help. \n", OWL_VERSION_STRING);333 sprintf(buff, "Welcome to barnowl version %s. Press 'h' for on-line help. \n", OWL_VERSION_STRING); 334 334 strcat(startupmsg, buff); 335 335 strcat(startupmsg, " \n"); 336 strcat(startupmsg, "This is a development build of barnowl. If you are using this \n");337 strcat(startupmsg, "build regularly, please add yourself to barnowl-users@mit.edu \n");336 strcat(startupmsg, "This is a development build of barnowl. If you are using this \n"); 337 strcat(startupmsg, "build regularly, please add yourself to barnowl-users@mit.edu \n"); 338 338 strcat(startupmsg, " ^ ^ \n"); 339 339 strcat(startupmsg, " OvO \n"); -
owl.h
rb3a40c7 rc2c5c77 104 104 #define OWL_COLOR_CYAN 6 105 105 #define OWL_COLOR_WHITE 7 106 #define OWL_COLOR_DEFAULT 8106 #define OWL_COLOR_DEFAULT -1 107 107 108 108 #define OWL_EDITWIN_STYLE_MULTILINE 0 … … 252 252 char *textbuff; 253 253 char *fmbuff; 254 char*fgcolorbuff;255 char*bgcolorbuff;254 short *fgcolorbuff; 255 short *bgcolorbuff; 256 256 } owl_fmtext; 257 257 … … 526 526 typedef struct _owl_colorpair_mgr { 527 527 int next; 528 int **pairs;528 short **pairs; 529 529 } owl_colorpair_mgr; 530 530 -
perlglue.xs
r3066d23 rc2c5c77 296 296 owl_global_add_style(&g, s); 297 297 } 298 299 int 300 getnumcolors() 301 CODE: 302 RETVAL = owl_function_get_color_count(); 303 OUTPUT: 304 RETVAL 305 306 void 307 _remove_filter(filterName) 308 char *filterName 309 CODE: 310 { 311 /* Don't delete the current view, or the 'all' filter */ 312 if (strcmp(filterName, owl_view_get_filtname(owl_global_get_current_view(&g))) 313 && strcmp(filterName, "all")) { 314 owl_global_remove_filter(&g,filterName); 315 } 316 } -
util.c
rd524c83 rc2c5c77 390 390 } 391 391 392 int owl_util_find_trans_short(short *in, int len) 393 { 394 int i; 395 for (i=1; i<len; i++) { 396 if (in[i] != in[0]) return(i-1); 397 } 398 return(i); 399 } 400 392 401 /* downcase the string 'foo' */ 393 402 void downstr(char *foo) … … 488 497 int owl_util_string_to_color(char *color) 489 498 { 499 int c; 490 500 if (!strcasecmp(color, "black")) { 491 501 return(OWL_COLOR_BLACK); … … 507 517 return(OWL_COLOR_DEFAULT); 508 518 } 519 c = atoi(color); 520 if (c >= -1 && c < COLORS) { 521 return(c); 522 } 509 523 return(-1); 510 524 }
Note: See TracChangeset
for help on using the changeset viewer.