How to get colors from a screen position?

Help
2007-05-29
2013-04-25
  • Nilo R C Paim

    Nilo R C Paim - 2007-05-29

    Hi,

    First of all, congratulations. PDCurses is a great stuff.

    I would like to get the foreground and backuground colors for a specified screen position.

    I tried to do a mvinch(), getting a chtype. But what should I do for getting the colors? I could not find any examples about.

    I'm currently using MinGW under Win2k.

    TIA.

     
    • Warren W. Gay VE3WWG

      1. int attr_get(attr_t *attrs, short *pair, void *opts);
      2. int pair_content(short pair, short *f, short *b);

      First find out the color pair, then find out what
      the color pair represents (foreground and
      background). I haven't tested pdcurses in this,
      but this works for ncurses.

      Warren.

       
    • William McBrine

      William McBrine - 2007-05-29

      Not attr_get() -- that's for the current attribute rather than the attribute at a given position.

      You can get the pair number via the PAIR_NUMBER() macro. So...

      short fg, bg;
      chtype ch = mvinch(y, x);
      pair_content(PAIR_NUMBER(ch), &fg, &bg);

       
      • Nilo R C Paim

        Nilo R C Paim - 2007-05-29

        Thanks to Warren and William.

        In fact, William's hint solves my problem.

        Thanks, guys. Keep your good job.

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks