unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: How to use a float value with either GLYPH_DEBUG or NSTRACE
Date: Mon, 21 Aug 2017 10:07:47 -0700	[thread overview]
Message-ID: <m2r2w4vogs.wl%esq@lawlist.com> (raw)

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	other threads:[~2017-08-21 17:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 17:07 Keith David Bershatsky [this message]
2017-08-21 20:07 ` How to use a float value with either GLYPH_DEBUG or NSTRACE Alan Third
  -- strict thread matches above, loose matches on Subject: below --
2017-08-21 20:51 Keith David Bershatsky
2017-08-21 21:30 ` Noam Postavsky
2017-08-21 23:55   ` Paul Eggert
2017-08-21 21:45 Keith David Bershatsky
2017-08-22  4:30 Keith David Bershatsky
2017-08-22  8:23 ` Anders Lindgren
2017-08-22 11:32   ` Noam Postavsky
2017-08-22 11:51     ` Anders Lindgren
2017-08-22 15:47     ` Paul Eggert
2017-08-22 17:04 Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2r2w4vogs.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).