Problems with ncurses
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Problems with ncurses




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Problems with ncurses  
Calle


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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  
Eric Enright


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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  
Thomas Dickey


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM

Calle <calle8787@hotmail.com> wrote:
> I have some problems with ncurses.
> Could someone tell me why it doesn't print anything out?

The getch() refreshes stdscr, which overwrites the other windows.
See the discussion of doupdate() and wnoutrefresh().

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net





[ Post a follow-up to this message ]



    Re: Problems with ncurses  
Wayne C. Morris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

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

Back To The Top
Home | Usercp | Faq | Register