Changeset 0331c8f


Ignore:
Timestamp:
Jan 24, 2007, 2:23:32 AM (17 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
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:
99c7549
Parents:
eeeef20
Message:
Further simplifications.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    reeeef20 r0331c8f  
    663663  // This could be a bitarray if we wanted to save memory.
    664664  int i, j, colors;
    665   cpmgr->used = owl_malloc(COLOR_PAIRS * sizeof(char));
    666   memset(cpmgr->used, 0, COLOR_PAIRS * sizeof(char));
     665  cpmgr->next = COLORS;
    667666
    668667  colors = COLORS + 1; // 1 to account for "default".
     
    683682  int i, j, colors;
    684683  owl_colorpair_mgr *cpmgr = owl_global_get_colorpair_mgr(&g);
    685   memset(cpmgr->used, 0, COLOR_PAIRS * sizeof(char)); 
     684  cpmgr->next = COLORS;
    686685
    687686  colors = COLORS + 1; // 1 to account for "default".
     
    715714    cpmgr = owl_global_get_colorpair_mgr(&g);
    716715    pair = cpmgr->pairs[fg+1][bg];
    717     if (!(pair != -1 && cpmgr->used[pair])) {
     716    if (!(pair != -1 && pair < cpmgr->next)) {
    718717      // If we didn't find a pair, search for a free one to assign.
    719718      // Skip the first COLORS, since they're static.
    720719      // If we ever get 256 color curses, this will need more thought.
    721       for(i = COLORS; i < COLOR_PAIRS; i++) {
    722         if (!cpmgr->used[i]) {
    723           // Found a free pair
    724           pair = i;
    725           break;
    726         }
    727       }
     720      pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1;
    728721      if (pair != -1) {
    729722        // We found a free pair, initialize it.
    730723        init_pair(pair, fg, bg);
    731724        cpmgr->pairs[fg+1][bg] = pair;
    732         cpmgr->used[pair] = 1;
     725        cpmgr->next++;
    733726      } else {
    734727        // We still don't have a pair, drop the background color. Too bad.
Note: See TracChangeset for help on using the changeset viewer.