Canul Podkopayeva wrote:
>
> Why wont this builded code work?
>
> #include <curses.h>
>
> void main(void)
> {
> WINDOW *my;
> initscr();
> cbreak();
> my = newwin(12, 12, 12, 12);
> waddstr(my, "argg!");
> /* here, instead of adding a string it dosn't do * anything
> */
> refresh();
> endwin();
> }
>
There are three reasons to this:
1. You mix stdscr and window specific calls. refresh should be
wrefresh(my).
2. To see the result you have to wait. Use wgetch(my) before endwin.
Curses restores the screen on endwin().
3. You have not defined where you'd like the text to be printed.
And a small recommendation: If you don't need windows then don't use
them. Painting on the default window is easier as you don't need to keep
track of the current window pointer on each curses call.
---- with window ---
#include <curses.h>
void main()
{
WINDOW *win;
initscr();
win=newwin(12, 12, 12, 12);
wmvaddstr(win, 1, 1, "Test");
wrefresh(win);
wgetch(win);
endwin();
}
---- without window ---
#include <curses.h>
void main()
{
initscr();
mvaddstr(12, 12, "Test");
refresh();
getch();
endwin();
}
-----------------------
---
Henrik Nordstr�m