Changeset 3fa0181


Ignore:
Timestamp:
May 1, 2011, 5:30:33 PM (10 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
4fd211f (diff), 7b4f3be (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 7b4f3bea704ed82f2c36ba19fcf354d7442a5bb7 into 4fd211f3a533efcedaf4d0dc7c01e02087ad2e39
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r4479497 r7b4f3be  
    184184}
    185185
    186 static void _owl_fmtext_update_colorpair(short fg, short bg, short *pair)
    187 {
    188   if (owl_global_get_hascolors(&g)) {
    189     *pair = owl_fmtext_get_colorpair(fg, bg);
    190   }
    191 }
    192 
    193186static void _owl_fmtext_wcolor_set(WINDOW *w, short pair)
    194187{
    195   if (owl_global_get_hascolors(&g)) {
     188  if (has_colors()) {
    196189      wcolor_set(w,pair,NULL);
    197190      wbkgdset(w, COLOR_PAIR(pair));
     
    221214  bg = default_bgcolor;
    222215  _owl_fmtext_wattrset(w, attr);
    223   _owl_fmtext_update_colorpair(fg, bg, &pair);
     216  pair = owl_fmtext_get_colorpair(fg, bg);
    224217  _owl_fmtext_wcolor_set(w, pair);
    225218
     
    270263      if (bg == OWL_COLOR_DEFAULT) bg = default_bgcolor;
    271264      _owl_fmtext_wattrset(w, attr);
    272       _owl_fmtext_update_colorpair(fg, bg, &pair);
     265      pair = owl_fmtext_get_colorpair(fg, bg);
    273266      _owl_fmtext_wcolor_set(w, pair);
    274267
     
    662655           continue */
    663656      } else if (!strcasecmp(buff, "@color")
    664                  && owl_global_get_hascolors(&g)
    665657                 && owl_global_is_colorztext(&g)) {
    666658        g_free(buff);
     
    820812    }
    821813  }
    822   if (owl_global_get_hascolors(&g)) {
     814  if (has_colors()) {
    823815    for(i = 0; i < 8; i++) {
    824816      short fg, bg;
     
    835827  owl_colorpair_mgr *cpmgr;
    836828  short pair;
     829
     830  if (!has_colors())
     831    return 0;
    837832
    838833  /* Sanity (Bounds) Check */
     
    852847  if (!(pair != -1 && pair < cpmgr->next)) {
    853848    /* If we didn't find a pair, search for a free one to assign. */
    854     pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1;
     849    pair = (cpmgr->next < owl_util_get_colorpairs()) ? cpmgr->next : -1;
    855850    if (pair != -1) {
    856851      /* We found a free pair, initialize it. */
  • functions.c

    r4fd211f r7b4f3be  
    18171817          owl_global_get_cols(&g));
    18181818
    1819   if (owl_global_get_hascolors(&g)) {
     1819  if (has_colors()) {
    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 {
     
    22262226    f = fl->data;
    22272227    owl_fmtext_append_normal(&fm, "   ");
    2228     if (owl_global_get_hascolors(&g)) {
    2229       owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f));
    2230     } else {
    2231       owl_fmtext_append_normal(&fm, owl_filter_get_name(f));
    2232     }
     2228    owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f),
     2229                                   owl_filter_get_fgcolor(f),
     2230                                   owl_filter_get_bgcolor(f));
    22332231    owl_fmtext_append_normal(&fm, "\n");
    22342232  }
  • global.c

    r47e0a6a r7b4f3be  
    5151  g->direction=OWL_DIRECTION_DOWNWARDS;
    5252  g->zaway=0;
    53   if (has_colors()) {
    54     g->hascolors=1;
    55   }
    56   g->colorpairs=COLOR_PAIRS;
    5753  owl_fmtext_init_colorpair_mgr(&(g->cpmgr));
    5854  g->debug=OWL_DEBUG;
     
    574570owl_view *owl_global_get_current_view(owl_global *g) {
    575571  return(&(g->current_view));
    576 }
    577 
    578 /* has colors */
    579 
    580 int owl_global_get_hascolors(const owl_global *g) {
    581   if (g->hascolors) return(1);
    582   return(0);
    583 }
    584 
    585 /* color pairs */
    586 
    587 int owl_global_get_colorpairs(const owl_global *g) {
    588   return(g->colorpairs);
    589572}
    590573
  • 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 r7b4f3be  
    610610  char *startupargs;
    611611  int nextmsgid;
    612   int hascolors;
    613   int colorpairs;
    614612  owl_colorpair_mgr cpmgr;
    615613  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.