Lines, Corners, and Underlining not working

Help
NerdFencer
2008-11-23
2013-04-25
  • NerdFencer

    NerdFencer - 2008-11-23

    I just swapped out the ncurses library for pdcurses for hangman, and im having issues with the display of lines, corners, and underlining.  Here is what is displaying...

    a appears in this word 2 times

    lqqqqqqqqqqk
    x         lvk
    x         mwj
    x        lwvwk
    x        xx xx
    x         tqu
    x         x x
    x         j m
    x
    mqqqqqqqqq

    a__a___

    q's are supposed to be horizontal lines, x's vertical, l,j,m,k are supposed to be corners, and the remaining chars in the text are t's
    all of these are also unexpectedly inverted, with the BG color being the normal FG color, and vice versa

    These are drawn using constants as seen in the code below...
        for (int i = 1;i<=10;i++) {
            mvaddch(0+line,i,ACS_HLINE);
            mvaddch(i/1.2+line,0,ACS_VLINE);
            mvaddch(9+line,i-1,ACS_HLINE);
        }
        mvaddch(line,0,ACS_ULCORNER);
        mvaddch(line,11,ACS_URCORNER);
        mvaddch(9+line,0,ACS_LLCORNER);
        switch (life) {
            case 4:
                mvaddch(6+line,10,ACS_VLINE);
                mvaddch(6+line,12,ACS_VLINE);
                mvaddch(7+line,10,ACS_LRCORNER);
                mvaddch(7+line,12,ACS_LLCORNER);
            case 3:
                mvaddch(3+line,9,ACS_ULCORNER);
                mvaddch(4+line,9,ACS_VLINE);
                mvaddch(3+line,13,ACS_URCORNER);
                mvaddch(4+line,13,ACS_VLINE);
            case 2:
                mvaddch(3+line,11,ACS_BTEE);
                for (int i = 10; i<14; i+=2) {
                    mvaddch(3+line,i,ACS_TTEE);
                    mvaddch(4+line,i,ACS_VLINE);
                    mvaddch(5+line,i,ACS_VLINE);
                }
                mvaddch(5+line,10,ACS_LTEE);
                mvaddch(5+line,12,ACS_RTEE);
                mvaddch(5+line,11,ACS_HLINE);
            case 1:
                mvaddch(1+line,11,ACS_BTEE);
                mvaddch(1+line,10,ACS_ULCORNER);
                mvaddch(1+line,12,ACS_URCORNER);
                mvaddch(2+line,10,ACS_LLCORNER);
                mvaddch(2+line,12,ACS_LRCORNER);
                mvaddch(2+line,11,ACS_TTEE);
            default:
                break;
        }

    the a's are supposed to  be underlined, and are drawn here...

        attron(A_UNDERLINE);
        for (int i = 0;i<dispword.size();i++) {
            if (dispword[i]=='_') {
                attroff(A_UNDERLINE);
                mvaddch(line,i,'_');
                attron(A_UNDERLINE);
            } else if (dispword[i] != ' ') {
                mvaddch(line,i,dispword[i]);
            }
        }
        attroff(A_UNDERLINE);

    in case it matters, I am running 64 bit xubuntu

    Can somebody help me?

     
    • William McBrine

      William McBrine - 2008-11-24

      It might help if you could post (or post a link to) the entire program, along with your build procedure. There's not enough here to test with. But to make a wild guess, you might be including the curses.h from one package and linking against the other.

      Also, not that it helps with your problem, but you should check out the hline() and vline() family of functions.

       
      • NerdFencer

        NerdFencer - 2008-11-24

        I have posted a compressed copy of the program here...
        http://nerdfencer.com/Documents/Hangman.zip

        All functions dealing with curses are in display.cpp
        The bash script compile is what im using to compile it

        Thanks for taking a look :D

         
    • William McBrine

      William McBrine - 2008-11-25

      Yeah, it's like I said: You changed display.cpp to include "curses/curses.h" (the PDCurses .h file), but you're still linking ncurses in your "compile": "-lncurses". You need "-lXCurses", or a direct link to the compiled PDCurses library.

       
    • NerdFencer

      NerdFencer - 2008-11-26

      Thanks, i linked it with -lXCurses and it worked, but now the marker for where the last edit was (cursor?) looks bad, is there a way to disable it?

       
    • William McBrine

      William McBrine - 2008-11-27

      curs_set(0)

       
      • NerdFencer

        NerdFencer - 2008-11-27

        Thanks, it works perfectly now :D

        Now to start futzing with other aspects of pdcurses...

         
    • NerdFencer

      NerdFencer - 2008-11-27

      Actually...
      I just noticed that the window that comes up has the title "PDCurses", how do I set the window title text?

       
    • William McBrine

      William McBrine - 2008-11-27

      PDC_set_title()

      You know, these are in the manual.

       

Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks