Changeset 9efa5bd


Ignore:
Timestamp:
May 1, 2011, 5:29:25 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
7b4f3be
Parents:
4fd211f
git-author:
David Benjamin <davidben@mit.edu> (04/26/11 21:07:08)
git-committer:
David Benjamin <davidben@mit.edu> (05/01/11 17:29:25)
Message:
Clamp the number of color pairs to 256 without ext-color

Debian doesn't build their ncurses with ext-color support, so it only
supports 256 colorpairs. However, ncurses still reports the full 32768
value, and color pairs end up trampling over each other.

When 256 is exceeded, the existing colorpair reset logic will now kick
in and fix things. Reword a comment accordingly.

While I'm here, get rid of the colorpairs member in owl_global. ncurses'
works just fine.

Reported-by: Mats Ahlgren <mats_a@mit.edu>
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r4479497 r9efa5bd  
    852852  if (!(pair != -1 && pair < cpmgr->next)) {
    853853    /* If we didn't find a pair, search for a free one to assign. */
    854     pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1;
     854    pair = (cpmgr->next < owl_util_get_colorpairs()) ? cpmgr->next : -1;
    855855    if (pair != -1) {
    856856      /* We found a free pair, initialize it. */
  • functions.c

    r4fd211f r9efa5bd  
    18191819  if (owl_global_get_hascolors(&g)) {
    18201820    owl_fmtext_append_normal(&fm, "Color: Yes\n");
    1821     owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_global_get_colorpairs(&g));
     1821    owl_fmtext_appendf_normal(&fm, "Number of color pairs: %i\n", owl_util_get_colorpairs());
    18221822    owl_fmtext_appendf_normal(&fm, "Can change colors: %s\n", can_change_color() ? "yes" : "no");
    18231823  } else {
  • global.c

    r47e0a6a r9efa5bd  
    5454    g->hascolors=1;
    5555  }
    56   g->colorpairs=COLOR_PAIRS;
    5756  owl_fmtext_init_colorpair_mgr(&(g->cpmgr));
    5857  g->debug=OWL_DEBUG;
     
    581580  if (g->hascolors) return(1);
    582581  return(0);
    583 }
    584 
    585 /* color pairs */
    586 
    587 int owl_global_get_colorpairs(const owl_global *g) {
    588   return(g->colorpairs);
    589582}
    590583
  • owl.c

    ra2a8833 r9efa5bd  
    444444  /* update the terminal if we need to */
    445445  owl_window_redraw_scheduled();
    446   /* On colorpair shortage, reset and redraw /everything/. NOTE: if
    447    * the current screen uses too many colorpairs, this draws
    448    * everything twice. But this is unlikely; COLOR_PAIRS is 64 with
    449    * 8+1 colors, and 256^2 with 256+1 colors. (+1 for default.) */
     446  /* On colorpair shortage, reset and redraw /everything/. NOTE: if we
     447   * still overflow, this be useless work. With 8-colors, we get 64
     448   * pairs. With 256-colors, we get 32768 pairs with ext-colors
     449   * support and 256 otherwise. */
    450450  cpmgr = owl_global_get_colorpair_mgr(&g);
    451451  if (cpmgr->overflow) {
    452     owl_function_debugmsg("colorpairs: color shortage; reset pairs and redraw. COLOR_PAIRS = %d", COLOR_PAIRS);
     452    owl_function_debugmsg("colorpairs: used all %d pairs; reset pairs and redraw.",
     453                          owl_util_get_colorpairs());
    453454    owl_fmtext_reset_colorpairs(cpmgr);
    454455    owl_function_full_redisplay();
  • owl.h

    r283ff1e r9efa5bd  
    611611  int nextmsgid;
    612612  int hascolors;
    613   int colorpairs;
    614613  owl_colorpair_mgr cpmgr;
    615614  pid_t newmsgproc_pid;
  • util.c

    re56303f r9efa5bd  
    715715}
    716716
     717int owl_util_get_colorpairs(void) {
     718#ifndef NCURSES_EXT_COLORS
     719  /* Without ext-color support (an ABI change), ncurses only supports 256
     720   * different color pairs. However, it gives us a larger number even if your
     721   * ncurses is compiled without ext-color. */
     722  return MIN(COLOR_PAIRS, 256);
     723#else
     724  return COLOR_PAIRS;
     725#endif
     726}
     727
    717728gulong owl_dirty_window_on_signal(owl_window *w, gpointer sender, const gchar *detailed_signal)
    718729{
Note: See TracChangeset for help on using the changeset viewer.