PDA

View Full Version : Can't write to stdscr



fronty
07-15-2007, 10:17 AM
When I today began learning ncurses API, I ran into a problem. I can't write into stdscr.
I wrote few short programs, but none of them did work. I tried to write with printw(), mvprintw(), addch() and mvaddch() functions, but they didn't work. I tried to also write with printf() function in ncurses mode, but nothing happent. Writing with printf() while not in ncurses mode works fine.
Version of ncurses library I'm using is 5.6. OS I'm using is Xubuntu GNU/Linux. Terminal emulator is Xfce-Terminal. Comipler is gcc 4.1.2. If someone needs more information, I can tell, or if I don't know, try to find out it.

brewbuck
07-15-2007, 11:29 AM
When I today began learning ncurses API, I ran into a problem. I can't write into stdscr.
I wrote few short programs, but none of them did work. I tried to write with printw(), mvprintw(), addch() and mvaddch() functions, but they didn't work. I tried to also write with printf() function in ncurses mode, but nothing happent. Writing with printf() while not in ncurses mode works fine.
Version of ncurses library I'm using is 5.6. OS I'm using is Xubuntu GNU/Linux. Terminal emulator is Xfce-Terminal. Comipler is gcc 4.1.2. If someone needs more information, I can tell, or if I don't know, try to find out it.

Probably ncurses closes all funny file descriptors, including stdscr, whatever that is. Just use stdout.

Salem
07-15-2007, 12:45 PM
Do basic ncurses programs work for you?
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

Cactus_Hugger
07-16-2007, 01:53 AM
Have you called initscr() ? Are you calling refresh() ? Could you post a minimal not-working example?

fronty
07-16-2007, 05:24 AM
Salem: No, they don't work.
Cactus_Hugger: Yes, I have called initscr() and refreshed window after printing.
And one minimal example:


/* Hello, World */

#include <ncurses.h>

int main(void) {
initscr();

printw("Hello, World!");
refresh();

endwin();
return 0;
}

zacs7
07-16-2007, 06:12 AM
fronty, got the ncurses library installed (ie not just ncurses-devel)

fronty
07-16-2007, 08:54 AM
I compiled only source package I found for version 5.6, so I think I have whole library installed. :/

Cactus_Hugger
07-16-2007, 10:05 PM
Your minimal sample may be running too quickly. Place a getch() right before the endwin() call.

fronty
07-18-2007, 05:40 AM
:/ Doesn't work. :/
It seems to me it writes to it, but somehow it doesn't show it on teminal.

Salem
07-18-2007, 08:43 AM
IIRC, there are a multitude of different terminal emulators on most Linux distros.
Have you tried other ones?

fronty
07-19-2007, 06:48 AM
Tried with xterm, and with it works. Must try to find out why it didn't work with Xfce-terminal.

Salem
07-19-2007, 09:00 AM
http://www.linuxmanpages.com/man5/terminfo.5.php