Changeset e062f97


Ignore:
Timestamp:
Feb 4, 2011, 5:32:37 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
099597c
Parents:
4d24650
git-author:
David Benjamin <davidben@mit.edu> (01/25/11 16:58:31)
git-committer:
David Benjamin <davidben@mit.edu> (02/04/11 17:32:37)
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

    r7e111f4 re062f97  
    862862{
    863863  /* This could be a bitarray if we wanted to save memory. */
    864   short i, j;
    865   cpmgr->next = 8;
    866  
     864  short i;
    867865  /* The test is <= because we allocate COLORS+1 entries. */
    868866  cpmgr->pairs = owl_malloc((COLORS+1) * sizeof(short*));
    869867  for(i = 0; i <= COLORS; i++) {
    870868    cpmgr->pairs[i] = owl_malloc((COLORS+1) * sizeof(short));
     869  }
     870  owl_fmtext_reset_colorpairs(cpmgr);
     871}
     872
     873/* Reset used list */
     874void owl_fmtext_reset_colorpairs(owl_colorpair_mgr *cpmgr)
     875{
     876  short i, j;
     877
     878  cpmgr->next = 8;
     879    /* The test is <= because we allocated COLORS+1 entries. */
     880  for(i = 0; i <= COLORS; i++) {
    871881    for(j = 0; j <= COLORS; j++) {
    872882      cpmgr->pairs[i][j] = -1;
     
    874884  }
    875885  if (owl_global_get_hascolors(&g)) {
    876     for(i = 0; i < 8; i++) {
    877       short fg, bg;
    878       if (i >= COLORS) continue;
    879       pair_content(i, &fg, &bg);
    880       cpmgr->pairs[fg+1][bg+1] = i;
    881     }
    882   }
    883 }
    884 
    885 /* Reset used list */
    886 void owl_fmtext_reset_colorpairs(void)
    887 {
    888   if (owl_global_get_hascolors(&g)) {
    889     short i, j;
    890     owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g);
    891     cpmgr->next = 8;
    892    
    893     /* The test is <= because we allocated COLORS+1 entries. */
    894     for(i = 0; i <= COLORS; i++) {
    895       for(j = 0; j <= COLORS; j++) {
    896         cpmgr->pairs[i][j] = -1;
    897       }
    898     }
    899886    for(i = 0; i < 8; i++) {
    900887      short fg, bg;
  • mainwin.c

    r5cc7e5e re062f97  
    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.