 |
|
 |
|
06-26-04 03:11 PM
I have some problems with ncurses.
Could someone tell me why it doesn't print anything out?
#include <ncurses.h>
int main()
{
initscr();
cbreak();
noecho();
start_color();
int lines, cols;
WINDOW *win;
getmaxyx(stdscr, lines, cols);
win = newwin(lines, cols, 0, 0);
init_pair(1, COLOR_RED, COLOR_BLACK);
attrset(COLOR_PAIR(1) | A_BOLD);
wattrset(win, COLOR_PAIR(1));
wrefresh(win);
mvwprintw(win, (lines + 0), (cols), "Line 1");
mvwprintw(win, (lines + 1), (cols), "Line 2");
mvwprintw(win, (lines + 2), (cols), "Line 3");
mvwprintw(win, (lines + 3), (cols), "Line 4");
wrefresh(win);
getch();
endwin();
return 0;
}
Thank you for your help!
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Problems with ncurses |
 |
 |
|
|
06-26-04 03:11 PM
Calle wrote:
>I have some problems with ncurses.
>Could someone tell me why it doesn't print anything out?
>
>#include <ncurses.h>
>
>int main()
>{
> initscr();
> cbreak();
> noecho();
> start_color();
>
> int lines, cols;
> WINDOW *win;
>
> getmaxyx(stdscr, lines, cols);
>
> win = newwin(lines, cols, 0, 0);
> init_pair(1, COLOR_RED, COLOR_BLACK);
> attrset(COLOR_PAIR(1) | A_BOLD);
> wattrset(win, COLOR_PAIR(1));
>
> wrefresh(win);
Adding:
refresh();
here makes it work almost how you want,
> mvwprintw(win, (lines + 0), (cols), "Line 1");
> mvwprintw(win, (lines + 1), (cols), "Line 2");
> mvwprintw(win, (lines + 2), (cols), "Line 3");
> mvwprintw(win, (lines + 3), (cols), "Line 4");
On my 80x24 terminal this tries to print the four lines at:
80x24, 80x25, 80x26 and 80x27, which are all out of bounds.
Valid coordinates are
y = 0 to (lines - 1), and
x = 0 to (cols - 1)
>
> wrefresh(win);
>
> getch();
>
> endwin();
> return 0;
>}
>
>Thank you for your help!
Hope that helps!
--
Eric Enright /"\
ericAtiptsoftDcom \ / ASCII Ribbon Campaign
X Against HTML E-Mail
Public Key: 0xBEDF636F / \
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Problems with ncurses |
 |
 |
|
|
 |
|
 |
|
|
 |
Re: Problems with ncurses |
 |
 |
|
|
06-26-04 03:11 PM
In article <f81f4cdc.0406231436.2e202dad@posting.google.com>,
calle8787@hotmail.com (Calle) wrote:
> I have some problems with ncurses.
> Could someone tell me why it doesn't print anything out?
[snip]
> win = newwin(lines, cols, 0, 0);
[snip]
> mvwprintw(win, (lines + 0), (cols), "Line 1");
> mvwprintw(win, (lines + 1), (cols), "Line 2");
> mvwprintw(win, (lines + 2), (cols), "Line 3");
> mvwprintw(win, (lines + 3), (cols), "Line 4");
Window coordinates start at (0, 0). You're trying to write starting at
(lines, cols), which is outside the window you created.
[ Post a follow-up to this message ]
|
|
|
 |
|
|
|
|
Sponsored Links |
 |
 |
|
|
 |
All times are GMT. The time now is 08:47 AM. |
 |
|
|
 |
|
 |
|
|
 |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
|
|
|
|
Medical and Health forum | Computer Games Reviews | Graphics design forum
|
 |
|
 |
|