[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fwd: FW: Problems with pads]
From: |
jonw |
Subject: |
Re: [Fwd: FW: Problems with pads] |
Date: |
Tue, 17 Dec 2002 13:41:20 -0500 |
Hi Morris;
I am relatively new to pads with ncurses, but the problem you describe is
similar to something I just dealt with. If I understand your situation, you
would like to display both the string in the pad and outside of the pad at
the same time, without the pad message being deleted. I found that calling
refresh at initialization time causes alot of unexpected behaviour to go
away. Two points BTW;
1. The man page for ripoffline states;
Inside this initialization routine, the integer variables LINES and COLS
(defined in <curses.h>) are not guaranteed to be accurate and wrefresh
or doupdate must not be called. It is allowable to call wnoutrefresh during
the initialization routine.
I did call wrefresh inside the init routine and it did seem to work.
2. I did use libncurses-5.3 so the problem you are experiencing may be
version related.
Here is the modified program;
#include <stdio.h>
#include <stdlib.h>
#include <ncurses/curses.h> /* ensure ncurses is being used, jonw */
WINDOW * pad, * line;
static void curses_close( void )
{
clear(); refresh(); endwin();
}
static int do_line( WINDOW * w, int cols )
{
line = w;
waddstr( w, "Rip off!" );
wrefresh( line ); // This causes an end to all keyboard input
/* worked for me, jonw */
return 0;
}
int
main( int argc, char ** argv )
{
ripoffline( 1, do_line );
initscr();
cbreak();
noecho();
refresh( ); /* this seems to always help, jonw */
atexit( curses_close );
// Refresh the ripped-off line. This causes an end to all keyboard
// input if placed in do_line()
// wrefresh( line );
pad = newpad( 100, 100 );
//trace( TRACE_MAXIMUM );
// Write some text into the pad and display it. pnoutrefresh does
// nothing so use prefresh instead
mvwaddstr( pad, 3, 3, "Text in pad added with mvwaddstr" );
prefresh( pad, 0,0,0,0,10,60 );
// Wait for input. If this is just getch(), pad text does not appear.
getch( ); /* pad test appeared for me, jonw */
//wgetch( line );
// Add some text ouside the pad view area. Pad text now disappears!
/* pad text did not disappear, I hope this is what you want William, jonw
*/
move( 12, 12 );
addstr( "Text in main area added with addstr" );
getch();
// Put the pad text back. Now we have both text areas!
/* yes, I agree, jonw */
// (pnotrefresh() does nothing here)
prefresh( pad, 0,0,0,0,10,60 );
// getch() doesn't obliterate pad this time.
getch();
return 0;
}
Hope this helps. It all depends if I understood your situation. Let me know
how well it worked for you.
Thanks,
jonw
> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden Behalf Of
> Morris, William
> Sent: December 17, 2002 6:09 AM
> To: address@hidden
> Subject: Problems with pads
>
> Hello
>
> Can anyone put me right in the use of "pads"?
>
> I added a pad to a program which needs to show a portion of some data.
> The data in the pad never appeared. So I have the simple code below
> which tries to make a pad do what I expect. The comments in the code
> explain what happens. I would like to be able to:
>
> 1. get input from the main window or other windows
> 2. use addstr/waddstr (and variants) to add to areas inside and outside
> the pad view area.
>
> I'm running QNX6.2 (realtime OS with POSIX features) curses version-5.2.
> I tried compiling up the 5.3 release. The library (libncurses.a)
> compiled, but other components failed. After compiling/linking against
> the 5.3 library, text strings were printed in a garbled fashion and the
> pad text appeared in the rip-off line.
>
> Thanks in advance
> William Morris
>
> -------------------------------------
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <curses.h>
>
> WINDOW * pad, * line;
>
> static void curses_close( void )
> {
> clear(); refresh(); endwin();
> }
> static int do_line( WINDOW * w, int cols )
> {
> line = w;
> waddstr( w, "Rip off!" );
> //wrefresh( line ); This causes an end to all keyboard input
> return 0;
> }
> int
> main( int argc, char ** argv )
> {
> ripoffline( 1, do_line );
> initscr();
> cbreak();
> noecho();
> atexit( curses_close );
> // Refresh the ripped-off line. This causes an end to all keyboard
> // input if placed in do_line()
> wrefresh( line );
>
> pad = newpad( 100, 100 );
> //trace( TRACE_MAXIMUM );
>
> // Write some text into the pad and display it. pnoutrefresh does
> // nothing so use prefresh instead
> mvwaddstr( pad, 3, 3, "Text in pad added with mvwaddstr" );
> prefresh( pad, 0,0,0,0,10,60 );
>
> // Wait for input. If this is just getch(), pad text does not appear.
> wgetch( line );
> // getch();
>
> // Add some text ouside the pad view area. Pad text now disappears!
> move( 12, 12 );
> addstr( "Text in main area added with addstr" );
> getch();
>
> // Put the pad text back. Now we have both text areas!
> // (pnotrefresh() does nothing here)
> prefresh( pad, 0,0,0,0,10,60 );
>
> // getch() doesn't obliterate pad this time.
> getch();
> return 0;
> }
>
> ---
> William Morris
> address@hidden
>
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-ncurses
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Fwd: FW: Problems with pads],
jonw <=