William McBrine wrote:
Yes, it would help to have more context. But I think I do something
On Mon, 11 Sep 2006, Pavol Severa wrote:
I'd like text printed with printf() to appear and stay on stdscr. What
is a reasonable way to do it?
More context, please.
In general, you shouldn't mix stdio with curses, especially not in
PDCurses. But there's usually little reason to. Depending on exactly what
you're trying to do: one approach might be to replace all the printf()
calls with printw(); or, #define printf printw. printw() can do all that
printf() can (same format strings).
So far my plan is (not implemented yet):
1.create a temporary file
2.redirect stdout to the file using freopen
3.read the file and write it to stdscr
4.close and delete the file
Should I do it that way?
No. There's gotta be an easier way than that. :-)
The context in my case is to display a help file, or output from a data
analysis program. I create a temporary file. I do not redirect stdout,
but you probably could. I just fprintf to the temporary file. I then
read the temporary file, line by line. I don't write to stdscr, I have a
separate display WINDOW. After displaying the temporary file, it gets
deleted. I'm sure this all is not new.
William is right, it's not easy. You have to keep track of lots of
details. You may be able to do something much simpler. The reason I do
it this way, is it lets the user scroll up and down in the file. Also,
some of the text displayed is wide, so it lets the user pan left and
right. A separate window under the display window has a list of commands
the user can enter to move around in the file. The temporary file is
just sitting there for a while, so you can move around in it, and
display different portions.