Professional Web Applications Themes

ncurses problems - UNIX Programming

Hi every one I am writing a program, that will create a window, with a subwindow inside of it. The layout will hopefully look something like this --------------------------------- | | | | | | | Window 1 | | | | | | | --------------------------------- | | | Sub Window | --------------------------------- I am using the follwing code... int main (void) { WINDOW *win1, *win2, *win3; int lines, cols; initscr(); if(has_colors()) start_color(); getmaxyx(stdscr, lines, cols); win1 = newwin(lines, cols, 0, 0); win2 = subwin(win1, 1, cols, lines -2, 0 ); box(win2, ACS_VLINE, ACS_HLINE); init_pair(1,COLOR_WHITE,COLOR_BLACK); init_pair(2,COLOR_WHITE, COLOR_RED); init_pair(3,COLOR_YELLOW, COLOR_GREEN); attrset(COLOR_PAIR(1) | ...

  1. #1

    Default ncurses problems

    Hi every one
    I am writing a program, that will create a window, with a subwindow
    inside of it.
    The layout will hopefully look something like this

    ---------------------------------
    | |
    | |
    | |
    | Window 1 |
    | |
    | |
    | |
    ---------------------------------
    | |
    | Sub Window |
    ---------------------------------

    I am using the follwing code...

    int main (void)
    {
    WINDOW *win1, *win2, *win3;
    int lines, cols;

    initscr();
    if(has_colors())
    start_color();

    getmaxyx(stdscr, lines, cols);
    win1 = newwin(lines, cols, 0, 0);
    win2 = subwin(win1, 1, cols, lines -2, 0 );
    box(win2, ACS_VLINE, ACS_HLINE);
    init_pair(1,COLOR_WHITE,COLOR_BLACK);
    init_pair(2,COLOR_WHITE, COLOR_RED);
    init_pair(3,COLOR_YELLOW, COLOR_GREEN);
    attrset(COLOR_PAIR(1) | A_BOLD);
    wattrset(win1, COLOR_PAIR(2));
    wattrset(win2, COLOR_PAIR(3));

    wrefresh(win1);
    touchwin(win1);
    wrefresh(win2);
    mvwprintw(win2, 1, 0, "Test");
    wrefresh(win1);
    touchwin(win1);
    wrefresh(win2);
    endwin();//end of curses
    exit(EXIT_SUCCESS);
    }

    My problem is with the line
    win2 = subwin(win1, 1, cols, lines -2, 0 );

    If i change the second argument to anything other than 1, my program
    core dumps, and I dont understand why because subwin is prototyped as

    WINDOW *subwin(WINDOW *orig, int nlines, int ncols,
    int begin_y, int begin_x);

    according to the man pages.

    Also the line

    mvwprintw(win2, 1, 0, "Test");

    Doesnt print, for some reason which I dont understand.

    I hope someone can point out where I am going wrong.

    Thanks in advance

    --
    Materialised
    Materialised Guest

  2. #2

    Default Re: ncurses problems

    Materialised wrote: 
    Sorry, fixed the problem, 5 mins after I postyed,

    Look before you leap huh.
    Materialised Guest

  3. #3

    Default Re: ncurses problems

    "Materialised" <net> wrote in message
    news:c2014g$1nrmrt$news.uni-berlin.de... 
    > Sorry, fixed the problem, 5 mins after I postyed,
    >
    > Look before you leap huh.[/ref]

    So, what was the problem? I hate, "this is left to the reader's
    imagination as an exercise" posts.

    Norm

    Norm Guest

  4. #4

    Default Re: ncurses problems

    Norm Dresner wrote: 
    >>
    >>Sorry, fixed the problem, 5 mins after I postyed,
    >>
    >>Look before you leap huh.[/ref]
    >
    >
    > So, what was the problem? I hate, "this is left to the reader's
    > imagination as an exercise" posts.
    >
    > Norm
    >[/ref]
    The problem was I was trying to create a window out of the bounds of the
    parent window :)

    --
    Materialised

    Please note the email address this message uses in its headers is a spam
    trap.
    If you wish to contact me, you can do so at the following address:
    bWlja0Bjb2RlZ3VydXMub3Jn

    www.CodeGurus.org
    Materialised Guest

Similar Threads

  1. Replies: 0
    Last Post: October 4th, 01:05 AM
  2. #25752 [NEW]: ncurses includes in ext/ncurses/php_ncurses.h conflicts with BSD curses.
    By suga at netbsd dot com dot br in forum PHP Development
    Replies: 0
    Last Post: October 3rd, 11:41 PM
  3. [ANN] ncurses-ruby-0.8
    By Tobias Peters in forum Ruby
    Replies: 0
    Last Post: September 2nd, 08:20 PM
  4. ncurses
    By maillist@bestworldweb.homelinux.com in forum Ruby
    Replies: 0
    Last Post: July 15th, 12:48 AM
  5. Problems with ncurses in X
    By Paladin in forum Debian
    Replies: 4
    Last Post: July 3rd, 03:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139