ncurses problems

From: Materialised (materialised_at_privacy.net)
Date: 03/01/04


Date: Mon, 01 Mar 2004 17:36:13 +0000

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


Relevant Pages

  • ncurses problems
    ... I am writing a program, that will create a window, with a subwindow ... WINDOW *subwin(WINDOW *orig, int nlines, int ncols, ... for some reason which I dont understand. ...
    (comp.os.linux.development.apps)
  • Re: ncurses problems
    ... > I am writing a program, that will create a window, with a subwindow ... > int lines, cols; ... > getmaxyx(stdscr, lines, cols); ... for some reason which I dont understand. ...
    (comp.os.linux.development.apps)
  • Re: ncurses problems
    ... > I am writing a program, that will create a window, with a subwindow ... > int lines, cols; ... > getmaxyx(stdscr, lines, cols); ... for some reason which I dont understand. ...
    (comp.unix.programmer)
  • Re: How add buton onto title bar of any external active window?
    ... I want to add buttons ontoany active window. ... int sm_CXSIZE; ... static int WindowsFeaturesWidth(HWND hwnd, DWORD style) ... LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ...
    (microsoft.public.win32.programmer.gdi)
  • Re: CreateProcess() its extermely slow
    ... I notice that if my application has no Window, ... int APIENTRY _tWinMain(HINSTANCE hInstance, ... LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, ... LPARAM lParam) ...
    (microsoft.public.vc.mfc)