Exemple #1
0
void lynx_set_color( int a )
{
  if ( lynx_has_color && LYShowColor > 1 )
  {
    LYwin->_attrs = lynx_color_cfg_attr( a ) | ( a + 1 < COLOR_PAIRS ? get_color_pair( a + 1 ) : 0 );
  }
  return;
}
Exemple #2
0
int encode_color_attr( int color_attr )
{
  int result;
  int code = 0;
  int offs = 1;
  if ( color_attr & 0x200000 )
    code |= 1;
  if ( color_attr & 0x140000 )
    code |= 2;
  if ( color_attr & 0x20000 )
    code |= 4;
  result = lynx_color_cfg_attr( code );
  if ( offs + code < COLOR_PAIRS )
  {
    result |= get_color_pair( offs + code );
  }
  return result;
}
Exemple #3
0
static void
apply_style (WINDOW *w, ui_file_style style)
{
  /* Reset.  */
  wattron (w, A_NORMAL);
  wattroff (w, A_BOLD);
  wattroff (w, A_DIM);
  wattroff (w, A_REVERSE);
  if (last_color_pair != -1)
    wattroff (w, COLOR_PAIR (last_color_pair));
  wattron (w, COLOR_PAIR (0));

  const ui_file_style::color &fg = style.get_foreground ();
  const ui_file_style::color &bg = style.get_background ();
  if (!fg.is_none () || !bg.is_none ())
    {
      int fgi, bgi;
      if (get_color (fg, &fgi) && get_color (bg, &bgi))
	{
#ifdef __MINGW32__
	  /* MS-Windows port of ncurses doesn't support implicit
	     default foreground and background colors, so we must
	     specify them explicitly when needed, using the colors we
	     saw at startup.  */
	  if (fgi == -1)
	    fgi = ncurses_norm_attr & 15;
	  if (bgi == -1)
	    bgi = (ncurses_norm_attr >> 4) & 15;
#endif
	  int pair = get_color_pair (fgi, bgi);
	  if (last_color_pair != -1)
	    wattroff (w, COLOR_PAIR (last_color_pair));
	  wattron (w, COLOR_PAIR (pair));
	  last_color_pair = pair;
	}
    }