tags:

views:

36

answers:

1

When I am inside Vim, and i type ":ls", Vim lists the buffers. Most likely it is going into "cooked mode" using def_prog_mode() and endwin(). WHat I'd like to know how does it print the values now. The best i've come out with is using system("echo ....")which would be quite laborious. I've tried printf - no effect, and printw.

I need to do the same kind of thing in my apps, rather than create Windows or popups, I'd like to list internal information like Vim does.

Here's a sample of what I've tried. http://gist.github.com/587622 Compile it using:

gcc -o a.out -lncurses a.c && ./a.out
+1  A: 

You probably just need to flush the stdio buffer using fflush. That is, after using printf to write some text, call fflush(stdout) to make sure the text gets sent to the terminal. ncurses is probably calling setbuf or setvbuf to enable block buffered IO to the terminal and this is not considered part of the tty modes saved and restored.

Geoff Reedy
Yup worked great! Didn't think of `fflush` since I am actually using ruby and haven't written in C for 18 years. Thanks.
rahul
I've got this working fine. However, I see that in microemacs when you type C-x c to go to shell, it does not clear the screen. Vim does and so does my prog, due to `endwin()`. If I remove `endwin` the screen is not cleared. but upon return, it remains scrolled up. I've tried def_shell_mode (???) but that messes up. So how to keep the existing windows and panels showing, and revert cleanly. thx.
rahul
okay, got it, we have to stop and restart ncurses.
rahul