emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to use a float value with either GLYPH_DEBUG or NSTRACE


From: Keith David Bershatsky
Subject: How to use a float value with either GLYPH_DEBUG or NSTRACE
Date: Mon, 21 Aug 2017 10:07:47 -0700

The following snippet yields the correct the result.  However, I would like to 
see the float values for RED, BLUE, and GREEN in the terminal when running 
NSTRACE and/or GLYPH_DEBUG.  I believe that I am limited to things that FORMAT 
accepts, however, I cannot figure out how to incorporate a float value in a 
NSTRACE or/or GLYPH_DEBUG statement.

It would be greatly appreciated if someone could please give me an example of 
how to use a float value as an argument for either GLYPH_DEBUG or NSTRACE.

BACKGROUND:  I am working on my own feature requests (Emacs Bug #17684 and 
#22873).

  struct frame *f = XFRAME (WINDOW_FRAME (w));
  struct face *face;
  /* The default face, possibly remapped. */
  face = FACE_FROM_ID (f, lookup_basic_face (f, DEFAULT_FACE_ID));
  NSColor *background_color = ns_lookup_indexed_color (face->background, f);
  Lisp_Object color_vector;
  EmacsCGFloat red, green, blue, alpha, gray;
  char buf[1024];
  const char *str;
  if ([[background_color colorSpaceName] isEqualToString: NSNamedColorSpace])
      if ((str =[[background_color colorNameComponent] UTF8String]))
        {
          color_vector = build_string ((char *)str);
          goto done;
        }
    [[background_color colorUsingDefaultColorSpace]
        getRed: &red green: &green blue: &blue alpha: &alpha];
  if (red == green && red == blue)
    {
      [[background_color colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
            getWhite: &gray alpha: &alpha];
      snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
                lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
      color_vector = build_string (buf);
      goto done;
    }
  snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
            lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
  color_vector = build_string (buf);
  done:
  NSTRACE_MSG ("BACKGROUND COLOR: %s", buf);


Thanks,

Keith



reply via email to

[Prev in Thread] Current Thread [Next in Thread]