[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getting input not working
From: |
Peter Jay Salzman |
Subject: |
Re: getting input not working |
Date: |
Mon, 3 Mar 2003 19:45:50 -0800 |
User-agent: |
Mutt/1.4i |
ok, after thinking about it, i realized the answer to my question is
"yes, stdin is redirected away from the keyboard and to a file".
that's why getch() is failing. it's reading from the wrong stream.
if i'm on the right track, is there a way to reconnect stdin to the
keyboard?
pete
begin Peter Jay Salzman <address@hidden>
> hi there,
>
> this is ncurses on debian testing.
>
> my program takes words from stdin and orders them into a binary tree.
> very similar to "self referential structures" from kernighan/ritchie's
> "the C programming language" (pg 139). like:
>
> a.out < file_of_words
>
> after the words are ordered into a binary tree, i'm using ncurses to
> print the tree.
>
> here's (very) pared down ncurses code:
>
>
>
> void ncurses_print_tree(struct node *node_ptr)
> {
> WINDOW *win;
> int c = 65;
>
> initscr();
>
> win = newwin(0, 0, 0, 0);
>
> while ( 1 )
> {
> c = wgetch(win);
> wrefresh(win);
> mvwprintw(win, 0, 0, "%c", c);
> }
>
> delwin(win);
> endwin();
> }
>
>
> i expect my keystrokes to be displayed in the upper left corner of the
> xterm. instead, all that's being displayed is "-1". this is "ERR", as
> defined in ncurses.h.
>
> i check win for NULL, and i'm able to mvwprintw() stuff to the screen.
> it looks like the program isn't "waiting" to collect my input.
>
> i'm wondering if i've somehow "ruined" stdin by collecting input on
> stdin. i've tried using fflush(stdin) to make sure there's nothing
> there, but still no success.
>
> when i debug the program, gdb steps over getch() as if it weren't there.
>
> any idea why collecting input may be failing?
>
> pete
>
> --
> First they ignore you, then they laugh at you, then they fight you,
> then you win. -- Gandhi, being prophetic about Linux.
>
> Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
>
>
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-ncurses
--
First they ignore you, then they laugh at you, then they fight you,
then you win. -- Gandhi, being prophetic about Linux.
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D