Changeset b1ed3e2


Ignore:
Timestamp:
Feb 4, 2011, 5:33:20 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
release-1.7
Children:
22662d7
Parents:
337383e
git-author:
David Benjamin <davidben@mit.edu> (01/25/11 16:58:31)
git-committer:
David Benjamin <davidben@mit.edu> (02/04/11 17:33:20)
Message:
Refactor some common code in colorpair_mgr

Reviewed-by: Alejandro R. Sedeño <asedeno@mit.edu>
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r7ba2ad4 rb1ed3e2  
    911911{
    912912  /* This could be a bitarray if we wanted to save memory. */
    913   short i, j;
    914   cpmgr->next = 8;
    915  
     913  short i;
    916914  /* The test is <= because we allocate COLORS+1 entries. */
    917915  cpmgr->pairs = owl_malloc((COLORS+1) * sizeof(short*));
    918916  for(i = 0; i <= COLORS; i++) {
    919917    cpmgr->pairs[i] = owl_malloc((COLORS+1) * sizeof(short));
     918  }
     919  owl_fmtext_reset_colorpairs(cpmgr);
     920}
     921
     922/* Reset used list */
     923void owl_fmtext_reset_colorpairs(owl_colorpair_mgr *cpmgr)
     924{
     925  short i, j;
     926
     927  cpmgr->next = 8;
     928    /* The test is <= because we allocated COLORS+1 entries. */
     929  for(i = 0; i <= COLORS; i++) {
    920930    for(j = 0; j <= COLORS; j++) {
    921931      cpmgr->pairs[i][j] = -1;
     
    923933  }
    924934  if (owl_global_get_hascolors(&g)) {
    925     for(i = 0; i < 8; i++) {
    926       short fg, bg;
    927       if (i >= COLORS) continue;
    928       pair_content(i, &fg, &bg);
    929       cpmgr->pairs[fg+1][bg+1] = i;
    930     }
    931   }
    932 }
    933 
    934 /* Reset used list */
    935 void owl_fmtext_reset_colorpairs(void)
    936 {
    937   if (owl_global_get_hascolors(&g)) {
    938     short i, j;
    939     owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g);
    940     cpmgr->next = 8;
    941    
    942     /* The test is <= because we allocated COLORS+1 entries. */
    943     for(i = 0; i <= COLORS; i++) {
    944       for(j = 0; j <= COLORS; j++) {
    945         cpmgr->pairs[i][j] = -1;
    946       }
    947     }
    948935    for(i = 0; i < 8; i++) {
    949936      short fg, bg;
  • mainwin.c

    r5cc7e5e rb1ed3e2  
    5353  markedmsgid = owl_global_get_markedmsgid(&g);
    5454  v = owl_global_get_current_view(&g);
    55   owl_fmtext_reset_colorpairs();
     55  owl_fmtext_reset_colorpairs(owl_global_get_colorpair_mgr(&g));
    5656
    5757  if (v==NULL) {
Note: See TracChangeset for help on using the changeset viewer.